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