diff options
author | Pedro Alves <palves@redhat.com> | 2008-09-22 15:21:30 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2008-09-22 15:21:30 +0000 |
commit | 181e7f9393edb01de72d25e208a6ef4f069fb36f (patch) | |
tree | 1e6c460894d9f33dbfafd225515cabefc66f8523 | |
parent | d6b48e9c8beee5d3ab78ac1979f6af0d6de9ae30 (diff) | |
download | gdb-181e7f9393edb01de72d25e208a6ef4f069fb36f.zip gdb-181e7f9393edb01de72d25e208a6ef4f069fb36f.tar.gz gdb-181e7f9393edb01de72d25e208a6ef4f069fb36f.tar.bz2 |
Remove the attach_flag global, and make it per-inferior.
* inferior.h (attach_flag): Delete.
(inferior_process): Declare.
* solib.c (update_solib_list): Adjust.
* gnu-nat.c (gnu_create_inferior, gnu_attach): Adjust.
* inf-ptrace.c (inf_ptrace_detach): Adjust.
(inf_ptrace_files_info): Get it from the current inferior.
* inf-ttrace.c (inf_ttrace_attach): Adjust.
(inf_ttrace_files_info): Get it from the current
inferior.
* inflow.c (terminal_inferior, terminal_ours_1, set_sigint_trap)
(clear_sigint_trap): Get it from the current process.
* remote.c (extended_remote_attach_1)
(extended_remote_create_inferior_1): Adjust.
* top.c (quit_confirm, quit_target): Get it from the current inferior.
* procfs.c (do_detach): Adjust.
(procfs_wait): Get it from the event inferior.
(procfs_files_info): Get it from the current inferior.
* nto-procfs.c (procfs_files_info): Likewise.
(procfs_attach): Adjust. Set the attach_flag here.
(do_attach): Don't set it here.
(procfs_detach): Don't clear it.
(procfs_mourn_inferior): Don't clear it.
* solib-osf.c (osf_solib_create_inferior_hook): Adjust.
* target.c (attach_flag): Delete.
(generic_mourn_inferior): Don't clear it.
* win32-nat.c (get_win32_debug_event): Get it from the event
process.
(do_initial_win32_stuff): Add attaching argument. Set attach_flag
in the inferior accordingly.
(win32_attach): Don't set the attach_flag here. Pass 1 to
do_intial_win32_stuff.
(win32_files_info): Get it from the current inferior.
(win32_create_inferior): Dont clear attach_flag here. Pass 0 to
do_intial_win32_stuff.
-rw-r--r-- | gdb/ChangeLog | 39 | ||||
-rw-r--r-- | gdb/gnu-nat.c | 7 | ||||
-rw-r--r-- | gdb/inf-ptrace.c | 10 | ||||
-rw-r--r-- | gdb/inf-ttrace.c | 8 | ||||
-rw-r--r-- | gdb/inferior.h | 9 | ||||
-rw-r--r-- | gdb/inflow.c | 15 | ||||
-rw-r--r-- | gdb/nto-procfs.c | 11 | ||||
-rw-r--r-- | gdb/procfs.c | 15 | ||||
-rw-r--r-- | gdb/remote.c | 7 | ||||
-rw-r--r-- | gdb/solib-osf.c | 5 | ||||
-rw-r--r-- | gdb/solib.c | 22 | ||||
-rw-r--r-- | gdb/target.c | 6 | ||||
-rw-r--r-- | gdb/top.c | 6 | ||||
-rw-r--r-- | gdb/win32-nat.c | 24 | ||||
-rw-r--r-- | gdb/windows-nat.c | 24 |
15 files changed, 133 insertions, 75 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 753757d..55b0a63 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,44 @@ 2008-09-22 Pedro Alves <pedro@codesourcery.com> + Remove the attach_flag global, and make it per-inferior. + + * inferior.h (attach_flag): Delete. + (inferior_process): Declare. + * solib.c (update_solib_list): Adjust. + * gnu-nat.c (gnu_create_inferior, gnu_attach): Adjust. + * inf-ptrace.c (inf_ptrace_detach): Adjust. + (inf_ptrace_files_info): Get it from the current inferior. + * inf-ttrace.c (inf_ttrace_attach): Adjust. + (inf_ttrace_files_info): Get it from the current + inferior. + * inflow.c (terminal_inferior, terminal_ours_1, set_sigint_trap) + (clear_sigint_trap): Get it from the current process. + * remote.c (extended_remote_attach_1) + (extended_remote_create_inferior_1): Adjust. + * top.c (quit_confirm, quit_target): Get it from the current inferior. + * procfs.c (do_detach): Adjust. + (procfs_wait): Get it from the event inferior. + (procfs_files_info): Get it from the current inferior. + * nto-procfs.c (procfs_files_info): Likewise. + (procfs_attach): Adjust. Set the attach_flag here. + (do_attach): Don't set it here. + (procfs_detach): Don't clear it. + (procfs_mourn_inferior): Don't clear it. + * solib-osf.c (osf_solib_create_inferior_hook): Adjust. + * target.c (attach_flag): Delete. + (generic_mourn_inferior): Don't clear it. + * win32-nat.c (get_win32_debug_event): Get it from the event + process. + (do_initial_win32_stuff): Add attaching argument. Set attach_flag + in the inferior accordingly. + (win32_attach): Don't set the attach_flag here. Pass 1 to + do_intial_win32_stuff. + (win32_files_info): Get it from the current inferior. + (win32_create_inferior): Dont clear attach_flag here. Pass 0 to + do_intial_win32_stuff. + +2008-09-22 Pedro Alves <pedro@codesourcery.com> + Make the stop_soon global be per-inferior instead. * infcmd.c (attach_command_post_wait): Adjust. diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 3753523..f214abb 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2093,7 +2093,6 @@ gnu_create_inferior (char *exec_file, char *allargs, char **env, inf_attach (inf, pid); - attach_flag = 0; push_target (&gnu_ops); inf->pending_execs = 2; @@ -2145,6 +2144,7 @@ gnu_attach (char *args, int from_tty) int pid; char *exec_file; struct inf *inf = cur_inf (); + struct inferior *inferior; if (!args) error_no_arg (_("process-id to attach")); @@ -2173,14 +2173,13 @@ gnu_attach (char *args, int from_tty) push_target (&gnu_ops); - add_inferior (pid); + inferior = add_inferior (pid); + inferior->attach_flag = 1; inf_update_procs (inf); inferior_ptid = ptid_build (pid, 0, inf_pick_first_thread ()); - attach_flag = 1; - /* We have to initialize the terminal settings now, since the code below might try to restore them. */ target_terminal_init (); diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index 797a70a..57af79a 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -212,6 +212,7 @@ inf_ptrace_attach (char *args, int from_tty) char *exec_file; pid_t pid; char *dummy; + struct inferior *inf; if (!args) error_no_arg (_("process-id to attach")); @@ -244,14 +245,14 @@ inf_ptrace_attach (char *args, int from_tty) ptrace (PT_ATTACH, pid, (PTRACE_TYPE_ARG3)0, 0); if (errno != 0) perror_with_name (("ptrace")); - attach_flag = 1; #else error (_("This system does not support attaching to a process")); #endif inferior_ptid = pid_to_ptid (pid); - add_inferior (pid); + inf = add_inferior (pid); + inf->attach_flag = 1; /* Always add a main thread. If some target extends the ptrace target, it should decorate the ptid later with more info. */ @@ -307,7 +308,6 @@ inf_ptrace_detach (char *args, int from_tty) ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, sig); if (errno != 0) perror_with_name (("ptrace")); - attach_flag = 0; #else error (_("This system does not support detaching from a process")); #endif @@ -611,8 +611,10 @@ inf_ptrace_thread_alive (ptid_t ptid) static void inf_ptrace_files_info (struct target_ops *ignore) { + struct inferior *inf = current_inferior (); + printf_filtered (_("\tUsing the running image of %s %s.\n"), - attach_flag ? "attached" : "child", + inf->attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid)); } diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c index b34e02e..643cfa2 100644 --- a/gdb/inf-ttrace.c +++ b/gdb/inf-ttrace.c @@ -710,6 +710,7 @@ inf_ttrace_attach (char *args, int from_tty) pid_t pid; char *dummy; ttevent_t tte; + struct inferior *inf; if (!args) error_no_arg (_("process-id to attach")); @@ -742,9 +743,9 @@ inf_ttrace_attach (char *args, int from_tty) if (ttrace (TT_PROC_ATTACH, pid, 0, TT_KILL_ON_EXIT, TT_VERSION, 0) == -1) perror_with_name (("ttrace")); - attach_flag = 1; - add_inferior (pid); + inf = add_inferior (pid); + inf->attach_flag = 1; /* Set the initial event mask. */ memset (&tte, 0, sizeof (tte)); @@ -1221,8 +1222,9 @@ inf_ttrace_xfer_partial (struct target_ops *ops, enum target_object object, static void inf_ttrace_files_info (struct target_ops *ignore) { + struct inferior *inf = current_inferior (); printf_filtered (_("\tUsing the running image of %s %s.\n"), - attach_flag ? "attached" : "child", + inf->attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid)); } diff --git a/gdb/inferior.h b/gdb/inferior.h index 66e7d47..43f9022 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -351,11 +351,6 @@ extern int proceed_to_finish; extern struct regcache *stop_registers; -/* Nonzero if the child process in inferior_ptid was attached rather - than forked. */ - -extern int attach_flag; - /* True if we are debugging displaced stepping. */ extern int debug_displaced; @@ -424,6 +419,10 @@ struct inferior /* See the definition of stop_kind above. */ enum stop_kind stop_soon; + /* Nonzero if this child process was attached rather than + forked. */ + int attach_flag; + /* Private data used by the target vector implementation. */ struct private_inferior *private; }; diff --git a/gdb/inflow.c b/gdb/inflow.c index 6a77531..2ba2a34 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -277,15 +277,16 @@ terminal_inferior (void) if (job_control) { + struct inferior *inf = current_inferior (); #ifdef HAVE_TERMIOS result = tcsetpgrp (0, inferior_process_group); - if (!attach_flag) + if (!inf->attach_flag) OOPSY ("tcsetpgrp"); #endif #ifdef HAVE_SGTTY result = ioctl (0, TIOCSPGRP, &inferior_process_group); - if (!attach_flag) + if (!inf->attach_flag) OOPSY ("TIOCSPGRP"); #endif } @@ -334,6 +335,8 @@ terminal_ours_1 (int output_only) if (!terminal_is_ours) { + struct inferior *inf = current_inferior (); + #ifdef SIGTTOU /* Ignore this signal since it will happen when we try to set the pgrp. */ @@ -353,7 +356,7 @@ terminal_ours_1 (int output_only) inferior_ttystate = serial_get_tty_state (stdin_serial); #ifdef PROCESS_GROUP_TYPE - if (!attach_flag) + if (!inf->attach_flag) /* If setpgrp failed in terminal_inferior, this would give us our process group instead of the inferior's. See terminal_inferior for details. */ @@ -626,7 +629,8 @@ static void (*osig) (); void set_sigint_trap (void) { - if (attach_flag || inferior_thisrun_terminal) + struct inferior *inf = current_inferior (); + if (inf->attach_flag || inferior_thisrun_terminal) { osig = (void (*)()) signal (SIGINT, pass_signal); } @@ -635,7 +639,8 @@ set_sigint_trap (void) void clear_sigint_trap (void) { - if (attach_flag || inferior_thisrun_terminal) + struct inferior *inf = current_inferior (); + if (inf->attach_flag || inferior_thisrun_terminal) { signal (SIGINT, osig); } diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c index 130eb95..6714239 100644 --- a/gdb/nto-procfs.c +++ b/gdb/nto-procfs.c @@ -494,8 +494,10 @@ procfs_meminfo (char *args, int from_tty) static void procfs_files_info (struct target_ops *ignore) { + struct inferior *inf = current_inferior (); + printf_unfiltered ("\tUsing the running image of %s %s via %s.\n", - attach_flag ? "attached" : "child", + pi->attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid), nto_procfs_path); } @@ -512,6 +514,7 @@ procfs_attach (char *args, int from_tty) { char *exec_file; int pid; + struct inferior *inf; if (!args) error_no_arg (_("process-id to attach")); @@ -535,7 +538,8 @@ procfs_attach (char *args, int from_tty) gdb_flush (gdb_stdout); } inferior_ptid = do_attach (pid_to_ptid (pid)); - add_inferior (pid); + inf = add_inferior (pid); + inf->attach_flag = 1; push_target (&procfs_ops); @@ -575,7 +579,6 @@ do_attach (ptid_t ptid) if (devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0) == EOK && status.flags & _DEBUG_FLAG_STOPPED) SignalKill (nto_node (), PIDGET (ptid), 0, SIGCONT, 0, 0); - attach_flag = 1; nto_init_solib_absolute_prefix (); return ptid; } @@ -795,7 +798,6 @@ procfs_detach (char *args, int from_tty) pid = ptid_get_pid (inferior_ptid); inferior_ptid = null_ptid; - attach_flag = 0; detach_inferior (pid); init_thread_list (); unpush_target (&procfs_ops); /* Pop out of handling an inferior. */ @@ -915,7 +917,6 @@ procfs_mourn_inferior (void) init_thread_list (); unpush_target (&procfs_ops); generic_mourn_inferior (); - attach_flag = 0; } /* This function breaks up an argument string into an argument diff --git a/gdb/procfs.c b/gdb/procfs.c index 658ec10..7529146 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -3663,6 +3663,7 @@ static ptid_t do_attach (ptid_t ptid) { procinfo *pi; + struct inferior *inf; int fail; int lwpid; @@ -3712,9 +3713,9 @@ do_attach (ptid_t ptid) if ((fail = procfs_debug_inferior (pi)) != 0) dead_procinfo (pi, "do_attach: failed in procfs_debug_inferior", NOKILL); - add_inferior (pi->pid); + inf = add_inferior (pi->pid); /* Let GDB know that the inferior was attached. */ - attach_flag = 1; + inf->attach_flag = 1; /* Create a procinfo for the current lwp. */ lwpid = proc_get_current_thread (pi); @@ -3768,7 +3769,6 @@ do_detach (int signo) proc_warn (pi, "do_detach, set_rlc", __LINE__); } - attach_flag = 0; destroy_procinfo (pi); } @@ -4074,6 +4074,8 @@ wait_again: } else if (syscall_is_exit (pi, what)) { + struct inferior *inf; + /* Handle SYS_exit call only */ /* Stopped at entry to SYS_exit. Make it runnable, resume it, then use @@ -4087,7 +4089,9 @@ wait_again: TARGET_WAITKIND_SPURIOUS. */ if (!proc_run_process (pi, 0, 0)) proc_error (pi, "target_wait, run_process", __LINE__); - if (attach_flag) + + inf = find_inferior_pid (pi->pid); + if (inf->attach_flag) { /* Don't call wait: simulate waiting for exit, return a "success" exit code. Bogus: what if @@ -4686,8 +4690,9 @@ procfs_notice_signals (ptid_t ptid) static void procfs_files_info (struct target_ops *ignore) { + struct inferior *inf = current_inferior (); printf_filtered (_("\tUsing the running image of %s %s via /proc.\n"), - attach_flag? "attached": "child", + inf->attach_flag? "attached": "child", target_pid_to_str (inferior_ptid)); } diff --git a/gdb/remote.c b/gdb/remote.c index dfae2f6..9dacd17 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -3074,6 +3074,7 @@ extended_remote_attach_1 (struct target_ops *target, char *args, int from_tty) int pid; char *dummy; char *wait_status = NULL; + struct inferior *inf; if (!args) error_no_arg (_("process-id to attach")); @@ -3113,13 +3114,12 @@ extended_remote_attach_1 (struct target_ops *target, char *args, int from_tty) /* Now, if we have thread information, update inferior_ptid. */ inferior_ptid = remote_current_thread (inferior_ptid); - add_inferior (pid); + inf = add_inferior (pid); + inf->attach_flag = 1; /* Now, add the main thread to the thread list. */ add_thread_silent (inferior_ptid); - attach_flag = 1; - /* Next, if the target can specify a description, read it. We do this before anything involving memory or registers. */ target_find_description (); @@ -5624,7 +5624,6 @@ extended_remote_create_inferior_1 (char *exec_file, char *args, init_wait_for_inferior (); /* Now mark the inferior as running before we do anything else. */ - attach_flag = 0; inferior_ptid = magic_null_ptid; add_inferior (ptid_get_pid (inferior_ptid)); diff --git a/gdb/solib-osf.c b/gdb/solib-osf.c index 031d598..efb8cf8 100644 --- a/gdb/solib-osf.c +++ b/gdb/solib-osf.c @@ -310,9 +310,11 @@ osf_solib_create_inferior_hook (void) struct inferior *inf; struct thread_info *tp; + inf = current_inferior (); + /* If we are attaching to the inferior, the shared libraries have already been mapped, so nothing more to do. */ - if (attach_flag) + if (inf->attach_flag) return; /* Nothing to do for statically bound executables. */ @@ -334,7 +336,6 @@ osf_solib_create_inferior_hook (void) if (!target_can_run (¤t_target)) return; - inf = current_inferior (); tp = inferior_thread (); clear_proceed_status (); inf->stop_soon = STOP_QUIETLY; diff --git a/gdb/solib.c b/gdb/solib.c index 7ca3a42..d40e70e 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -508,14 +508,20 @@ update_solib_list (int from_tty, struct target_ops *target) struct so_list *inferior = ops->current_sos(); struct so_list *gdb, **gdb_link; - /* If we are attaching to a running process for which we - have not opened a symbol file, we may be able to get its - symbols now! */ - if (attach_flag && - symfile_objfile == NULL) - catch_errors (ops->open_symbol_file_object, &from_tty, - "Error reading attached process's symbol file.\n", - RETURN_MASK_ALL); + /* We can reach here due to changing solib-search-path or the + sysroot, before having any inferior. */ + if (target_has_execution) + { + struct inferior *inf = current_inferior (); + + /* If we are attaching to a running process for which we + have not opened a symbol file, we may be able to get its + symbols now! */ + if (inf->attach_flag && symfile_objfile == NULL) + catch_errors (ops->open_symbol_file_object, &from_tty, + "Error reading attached process's symbol file.\n", + RETURN_MASK_ALL); + } /* GDB and the inferior's dynamic linker each maintain their own list of currently loaded shared objects; we want to bring the diff --git a/gdb/target.c b/gdb/target.c index 2fefa84..a509c17 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -199,11 +199,6 @@ struct target_ops current_target; static struct cmd_list_element *targetlist = NULL; -/* Nonzero if we are debugging an attached outside process - rather than an inferior. */ - -int attach_flag; - /* Nonzero if we should trust readonly sections from the executable when reading memory. */ @@ -2349,7 +2344,6 @@ generic_mourn_inferior (void) delete_inferior (pid); } - attach_flag = 0; breakpoint_init_inferior (inf_exited); registers_changed (); @@ -1185,13 +1185,14 @@ quit_confirm (void) if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution) { char *s; + struct inferior *inf = current_inferior (); /* This is something of a hack. But there's no reliable way to see if a GUI is running. The `use_windows' variable doesn't cut it. */ if (deprecated_init_ui_hook) s = "A debugging session is active.\nDo you still want to close the debugger?"; - else if (attach_flag) + else if (inf->attach_flag) s = "The program is running. Quit anyway (and detach it)? "; else s = "The program is running. Quit anyway (and kill it)? "; @@ -1218,7 +1219,8 @@ quit_target (void *arg) if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution) { - if (attach_flag) + struct inferior *inf = current_inferior (); + if (inf->attach_flag) target_detach (qt->args, qt->from_tty); else target_kill (); diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c index 8365cba..03b2f52 100644 --- a/gdb/win32-nat.c +++ b/gdb/win32-nat.c @@ -1316,14 +1316,16 @@ get_win32_debug_event (int pid, struct target_waitstatus *ourstatus) "CREATE_THREAD_DEBUG_EVENT")); if (saw_create != 1) { - if (!saw_create && attach_flag) + struct inferior *inf; + inf = find_inferior_pid (current_event.dwProcessId); + if (!saw_create && inf->attach_flag) { /* Kludge around a Windows bug where first event is a create thread event. Caused when attached process does not have a main thread. */ retval = fake_create_process (); - if (retval) - saw_create++; + if (retval) + saw_create++; } break; } @@ -1519,7 +1521,7 @@ win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus) } static void -do_initial_win32_stuff (DWORD pid) +do_initial_win32_stuff (DWORD pid, int attaching) { extern int stop_after_trap; int i; @@ -1546,6 +1548,7 @@ do_initial_win32_stuff (DWORD pid) init_wait_for_inferior (); inf = add_inferior (pid); + inf->attach_flag = attaching; terminal_init_inferior_with_pgrp (pid); target_terminal_inferior (); @@ -1712,8 +1715,6 @@ win32_attach (char *args, int from_tty) if (has_detach_ability ()) DebugSetProcessKillOnExit (FALSE); - attach_flag = 1; - if (from_tty) { char *exec_file = (char *) get_exec_file (0); @@ -1728,7 +1729,7 @@ win32_attach (char *args, int from_tty) gdb_flush (gdb_stdout); } - do_initial_win32_stuff (pid); + do_initial_win32_stuff (pid, 1); target_terminal_ours (); } @@ -1797,8 +1798,11 @@ win32_pid_to_exec_file (int pid) static void win32_files_info (struct target_ops *ignore) { + struct inferior *inf = current_inferior (); + printf_unfiltered ("\tUsing the running image of %s %s.\n", - attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid)); + inf->attach_flag ? "attached" : "child", + target_pid_to_str (inferior_ptid)); } static void @@ -1867,8 +1871,6 @@ win32_create_inferior (char *exec_file, char *allargs, char **in_env, if (new_console) flags |= CREATE_NEW_CONSOLE; - attach_flag = 0; - args = alloca (strlen (toexec) + strlen (allargs) + 2); strcpy (args, toexec); strcat (args, " "); @@ -1937,7 +1939,7 @@ win32_create_inferior (char *exec_file, char *allargs, char **in_env, else saw_create = 0; - do_initial_win32_stuff (pi.dwProcessId); + do_initial_win32_stuff (pi.dwProcessId, 0); /* win32_continue (DBG_CONTINUE, -1); */ } diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 8365cba..03b2f52 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1316,14 +1316,16 @@ get_win32_debug_event (int pid, struct target_waitstatus *ourstatus) "CREATE_THREAD_DEBUG_EVENT")); if (saw_create != 1) { - if (!saw_create && attach_flag) + struct inferior *inf; + inf = find_inferior_pid (current_event.dwProcessId); + if (!saw_create && inf->attach_flag) { /* Kludge around a Windows bug where first event is a create thread event. Caused when attached process does not have a main thread. */ retval = fake_create_process (); - if (retval) - saw_create++; + if (retval) + saw_create++; } break; } @@ -1519,7 +1521,7 @@ win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus) } static void -do_initial_win32_stuff (DWORD pid) +do_initial_win32_stuff (DWORD pid, int attaching) { extern int stop_after_trap; int i; @@ -1546,6 +1548,7 @@ do_initial_win32_stuff (DWORD pid) init_wait_for_inferior (); inf = add_inferior (pid); + inf->attach_flag = attaching; terminal_init_inferior_with_pgrp (pid); target_terminal_inferior (); @@ -1712,8 +1715,6 @@ win32_attach (char *args, int from_tty) if (has_detach_ability ()) DebugSetProcessKillOnExit (FALSE); - attach_flag = 1; - if (from_tty) { char *exec_file = (char *) get_exec_file (0); @@ -1728,7 +1729,7 @@ win32_attach (char *args, int from_tty) gdb_flush (gdb_stdout); } - do_initial_win32_stuff (pid); + do_initial_win32_stuff (pid, 1); target_terminal_ours (); } @@ -1797,8 +1798,11 @@ win32_pid_to_exec_file (int pid) static void win32_files_info (struct target_ops *ignore) { + struct inferior *inf = current_inferior (); + printf_unfiltered ("\tUsing the running image of %s %s.\n", - attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid)); + inf->attach_flag ? "attached" : "child", + target_pid_to_str (inferior_ptid)); } static void @@ -1867,8 +1871,6 @@ win32_create_inferior (char *exec_file, char *allargs, char **in_env, if (new_console) flags |= CREATE_NEW_CONSOLE; - attach_flag = 0; - args = alloca (strlen (toexec) + strlen (allargs) + 2); strcpy (args, toexec); strcat (args, " "); @@ -1937,7 +1939,7 @@ win32_create_inferior (char *exec_file, char *allargs, char **in_env, else saw_create = 0; - do_initial_win32_stuff (pi.dwProcessId); + do_initial_win32_stuff (pi.dwProcessId, 0); /* win32_continue (DBG_CONTINUE, -1); */ } |