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.
This commit is contained in:
Pedro Alves
2008-09-22 15:21:30 +00:00
parent d6b48e9c8b
commit 181e7f9393
15 changed files with 133 additions and 75 deletions

View File

@ -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