aboutsummaryrefslogtreecommitdiff
path: root/gdb/win32-nat.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2008-09-22 15:21:30 +0000
committerPedro Alves <palves@redhat.com>2008-09-22 15:21:30 +0000
commit181e7f9393edb01de72d25e208a6ef4f069fb36f (patch)
tree1e6c460894d9f33dbfafd225515cabefc66f8523 /gdb/win32-nat.c
parentd6b48e9c8beee5d3ab78ac1979f6af0d6de9ae30 (diff)
downloadgdb-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.
Diffstat (limited to 'gdb/win32-nat.c')
-rw-r--r--gdb/win32-nat.c24
1 files changed, 13 insertions, 11 deletions
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); */
}