This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Handle initial SIGSTOP for gdbserver --attach
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org
- Date: Wed, 8 Feb 2006 15:28:36 -0500
- Subject: [commit] Handle initial SIGSTOP for gdbserver --attach
A customer noticed that if you use gdbserver's --attach option, it reports a
SIGSTOP; and this causes GDB (by default) to send a SIGSTOP to the program
when it is resumed. Normally harmless, but it turns out that sending a
SIGSTOP to an NPTL thread while resuming it causes the SIGSTOP to be
delivered to some other thread, instead of discarded. Oops!
The correct fix, since GDB doesn't know to ignore the SIGSTOP, is to hide
it. Tested on x86_64-pc-linux-gnu and checked in.
--
Daniel Jacobowitz
CodeSourcery
2006-02-08 Daniel Jacobowitz <dan@codesourcery.com>
* server.c (attach_inferior): Return SIGTRAP for a successful
attach.
Index: server.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
retrieving revision 1.31
diff -u -p -r1.31 server.c
--- server.c 1 Feb 2006 21:37:21 -0000 1.31
+++ server.c 8 Feb 2006 20:26:29 -0000
@@ -80,6 +80,12 @@ attach_inferior (int pid, char *statuspt
*sigptr = mywait (statusptr, 0);
+ /* GDB knows to ignore the first SIGSTOP after attaching to a running
+ process using the "attach" command, but this is different; it's
+ just using "target remote". Pretend it's just starting up. */
+ if (*statusptr == 'T' && *sigptr == SIGSTOP)
+ *sigptr = SIGTRAP;
+
return 0;
}