This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Fix gdbserver handling of "detach" packet.
- From: dje at google dot com (Doug Evans)
- To: gdb-patches at sourceware dot org
- Date: Tue, 26 Apr 2011 10:41:52 -0700 (PDT)
- Subject: [patch] Fix gdbserver handling of "detach" packet.
Hi.
ref: http://sourceware.org/ml/gdb/2011-04/msg00147.html
I will check this in in a few days if there are no objections.
I verified cvs head gdbserver exits leaving the inferior running
without this patch and waits for the inferior with it (amd64-linux).
2011-04-26 Doug Evans <dje@google.com>
* linux-low.c (linux_join): Skip process lookup.
* server.c (join_inferiors_callback): Delete.
(process_serial_event): For 'D' packet (detach) call join_inferior
directly.
Index: linux-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v
retrieving revision 1.170
diff -u -p -r1.170 linux-low.c
--- linux-low.c 27 Feb 2011 21:41:26 -0000 1.170
+++ linux-low.c 26 Apr 2011 17:24:36 -0000
@@ -915,11 +915,6 @@ static void
linux_join (int pid)
{
int status, ret;
- struct process_info *process;
-
- process = find_process_pid (pid);
- if (process == NULL)
- return;
do {
ret = my_waitpid (pid, &status, 0);
Index: server.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
retrieving revision 1.143
diff -u -p -r1.143 server.c
--- server.c 24 Apr 2011 08:02:20 -0000 1.143
+++ server.c 26 Apr 2011 17:24:36 -0000
@@ -2442,17 +2442,6 @@ detach_or_kill_for_exit (void)
for_each_inferior (&all_processes, detach_or_kill_inferior_callback);
}
-static void
-join_inferiors_callback (struct inferior_list_entry *entry)
-{
- struct process_info *process = (struct process_info *) entry;
-
- /* If we are attached, then we can exit. Otherwise, we need to hang
- around doing nothing, until the child is gone. */
- if (!process->attached)
- join_inferior (ptid_get_pid (process->head.id));
-}
-
int
main (int argc, char *argv[])
{
@@ -2851,8 +2840,7 @@ process_serial_event (void)
/* If we are attached, then we can exit. Otherwise, we
need to hang around doing nothing, until the child is
gone. */
- for_each_inferior (&all_processes,
- join_inferiors_callback);
+ join_inferior (pid);
exit (0);
}
}