Introduce target_announce_attach
This introduces target_announce_attach, by analog with target_announce_detach. Then it converts existing targets to use this, rather than emitting their own output by hand.
This commit is contained in:
parent
10a85f29c7
commit
bc521517b7
9 changed files with 30 additions and 77 deletions
|
@ -2002,17 +2002,7 @@ darwin_nat_target::attach (const char *args, int from_tty)
|
||||||
if (pid == getpid ()) /* Trying to masturbate? */
|
if (pid == getpid ()) /* Trying to masturbate? */
|
||||||
error (_("I refuse to debug myself!"));
|
error (_("I refuse to debug myself!"));
|
||||||
|
|
||||||
if (from_tty)
|
target_announce_attach (from_tty, pid);
|
||||||
{
|
|
||||||
const char *exec_file = get_exec_file (0);
|
|
||||||
|
|
||||||
if (exec_file)
|
|
||||||
printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
|
|
||||||
target_pid_to_str (ptid_t (pid)).c_str ());
|
|
||||||
else
|
|
||||||
printf_unfiltered (_("Attaching to %s\n"),
|
|
||||||
target_pid_to_str (ptid_t (pid)).c_str ());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pid == 0 || ::kill (pid, 0) < 0)
|
if (pid == 0 || ::kill (pid, 0) < 0)
|
||||||
error (_("Can't attach to process %d: %s (%d)"),
|
error (_("Can't attach to process %d: %s (%d)"),
|
||||||
|
|
|
@ -2170,16 +2170,7 @@ gnu_nat_target::attach (const char *args, int from_tty)
|
||||||
if (pid == getpid ()) /* Trying to masturbate? */
|
if (pid == getpid ()) /* Trying to masturbate? */
|
||||||
error (_("I refuse to debug myself!"));
|
error (_("I refuse to debug myself!"));
|
||||||
|
|
||||||
if (from_tty)
|
target_announce_attach (from_tty, pid);
|
||||||
{
|
|
||||||
const char *exec_file = get_exec_file (0);
|
|
||||||
|
|
||||||
if (exec_file)
|
|
||||||
printf_unfiltered ("Attaching to program `%s', pid %d\n",
|
|
||||||
exec_file, pid);
|
|
||||||
else
|
|
||||||
printf_unfiltered ("Attaching to pid %d\n", pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
inf_debug (inf, "attaching to pid: %d", pid);
|
inf_debug (inf, "attaching to pid: %d", pid);
|
||||||
|
|
||||||
|
|
|
@ -148,17 +148,7 @@ inf_ptrace_target::attach (const char *args, int from_tty)
|
||||||
unpusher.reset (this);
|
unpusher.reset (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from_tty)
|
target_announce_attach (from_tty, pid);
|
||||||
{
|
|
||||||
const char *exec_file = get_exec_file (0);
|
|
||||||
|
|
||||||
if (exec_file)
|
|
||||||
printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
|
|
||||||
target_pid_to_str (ptid_t (pid)).c_str ());
|
|
||||||
else
|
|
||||||
printf_unfiltered (_("Attaching to %s\n"),
|
|
||||||
target_pid_to_str (ptid_t (pid)).c_str ());
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef PT_ATTACH
|
#ifdef PT_ATTACH
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
|
@ -701,17 +701,8 @@ nto_procfs_target::attach (const char *args, int from_tty)
|
||||||
if (pid == getpid ())
|
if (pid == getpid ())
|
||||||
error (_("Attaching GDB to itself is not a good idea..."));
|
error (_("Attaching GDB to itself is not a good idea..."));
|
||||||
|
|
||||||
if (from_tty)
|
target_announce_attach (from_tty, pid);
|
||||||
{
|
|
||||||
const char *exec_file = get_exec_file (0);
|
|
||||||
|
|
||||||
if (exec_file)
|
|
||||||
printf_unfiltered ("Attaching to program `%s', %s\n", exec_file,
|
|
||||||
target_pid_to_str (ptid_t (pid)).c_str ());
|
|
||||||
else
|
|
||||||
printf_unfiltered ("Attaching to %s\n",
|
|
||||||
target_pid_to_str (ptid_t (pid)).c_str ());
|
|
||||||
}
|
|
||||||
ptid_t ptid = do_attach (ptid_t (pid));
|
ptid_t ptid = do_attach (ptid_t (pid));
|
||||||
inf = current_inferior ();
|
inf = current_inferior ();
|
||||||
inferior_appeared (inf, pid);
|
inferior_appeared (inf, pid);
|
||||||
|
|
14
gdb/procfs.c
14
gdb/procfs.c
|
@ -1775,19 +1775,7 @@ procfs_target::attach (const char *args, int from_tty)
|
||||||
unpusher.reset (this);
|
unpusher.reset (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from_tty)
|
target_announce_attach (from_tty, pid);
|
||||||
{
|
|
||||||
const char *exec_file = get_exec_file (0);
|
|
||||||
|
|
||||||
if (exec_file)
|
|
||||||
printf_filtered (_("Attaching to program `%s', %s\n"),
|
|
||||||
exec_file, target_pid_to_str (ptid_t (pid)).c_str ());
|
|
||||||
else
|
|
||||||
printf_filtered (_("Attaching to %s\n"),
|
|
||||||
target_pid_to_str (ptid_t (pid)).c_str ());
|
|
||||||
|
|
||||||
fflush (stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
do_attach (ptid_t (pid));
|
do_attach (ptid_t (pid));
|
||||||
|
|
||||||
|
|
12
gdb/remote.c
12
gdb/remote.c
|
@ -6115,17 +6115,7 @@ extended_remote_target::attach (const char *args, int from_tty)
|
||||||
if (packet_support (PACKET_vAttach) == PACKET_DISABLE)
|
if (packet_support (PACKET_vAttach) == PACKET_DISABLE)
|
||||||
error (_("This target does not support attaching to a process"));
|
error (_("This target does not support attaching to a process"));
|
||||||
|
|
||||||
if (from_tty)
|
target_announce_attach (from_tty, pid);
|
||||||
{
|
|
||||||
const char *exec_file = get_exec_file (0);
|
|
||||||
|
|
||||||
if (exec_file)
|
|
||||||
printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
|
|
||||||
target_pid_to_str (ptid_t (pid)).c_str ());
|
|
||||||
else
|
|
||||||
printf_unfiltered (_("Attaching to %s\n"),
|
|
||||||
target_pid_to_str (ptid_t (pid)).c_str ());
|
|
||||||
}
|
|
||||||
|
|
||||||
xsnprintf (rs->buf.data (), get_remote_packet_size (), "vAttach;%x", pid);
|
xsnprintf (rs->buf.data (), get_remote_packet_size (), "vAttach;%x", pid);
|
||||||
putpkt (rs->buf);
|
putpkt (rs->buf);
|
||||||
|
|
18
gdb/target.c
18
gdb/target.c
|
@ -3637,6 +3637,24 @@ target_announce_detach (int from_tty)
|
||||||
target_pid_to_str (ptid_t (pid)).c_str ());
|
target_pid_to_str (ptid_t (pid)).c_str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See target.h */
|
||||||
|
|
||||||
|
void
|
||||||
|
target_announce_attach (int from_tty, int pid)
|
||||||
|
{
|
||||||
|
if (!from_tty)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const char *exec_file = get_exec_file (0);
|
||||||
|
|
||||||
|
if (exec_file)
|
||||||
|
printf_unfiltered ("Attaching to program: %s, %s\n", exec_file,
|
||||||
|
target_pid_to_str (ptid_t (pid)).c_str ());
|
||||||
|
else
|
||||||
|
printf_unfiltered ("Attaching to %s\n",
|
||||||
|
target_pid_to_str (ptid_t (pid)).c_str ());
|
||||||
|
}
|
||||||
|
|
||||||
/* The inferior process has died. Long live the inferior! */
|
/* The inferior process has died. Long live the inferior! */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -1448,6 +1448,11 @@ extern bool target_attach_no_wait ();
|
||||||
|
|
||||||
extern void target_post_attach (int pid);
|
extern void target_post_attach (int pid);
|
||||||
|
|
||||||
|
/* Display a message indicating we're about to attach to a given
|
||||||
|
process. */
|
||||||
|
|
||||||
|
extern void target_announce_attach (int from_tty, int pid);
|
||||||
|
|
||||||
/* Display a message indicating we're about to detach from the current
|
/* Display a message indicating we're about to detach from the current
|
||||||
inferior process. */
|
inferior process. */
|
||||||
|
|
||||||
|
|
|
@ -1929,17 +1929,7 @@ windows_nat_target::attach (const char *args, int from_tty)
|
||||||
|
|
||||||
DebugSetProcessKillOnExit (FALSE);
|
DebugSetProcessKillOnExit (FALSE);
|
||||||
|
|
||||||
if (from_tty)
|
target_announce_attach (from_tty, pid);
|
||||||
{
|
|
||||||
const char *exec_file = get_exec_file (0);
|
|
||||||
|
|
||||||
if (exec_file)
|
|
||||||
printf_unfiltered ("Attaching to program `%s', %s\n", exec_file,
|
|
||||||
target_pid_to_str (ptid_t (pid)).c_str ());
|
|
||||||
else
|
|
||||||
printf_unfiltered ("Attaching to %s\n",
|
|
||||||
target_pid_to_str (ptid_t (pid)).c_str ());
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
HANDLE h = OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, pid);
|
HANDLE h = OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, pid);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue