This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Handle a race condition in C-c'ing a remote target
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org
- Date: Wed, 23 Jan 2008 15:43:36 -0500
- Subject: [commit] Handle a race condition in C-c'ing a remote target
We have some patches (still under development) which add more valid
responses during remote_wait; e.g. a 'new thread' message. This
causes us to restore the old SIGINT handler (gdb's handle_sigint), do
some work which might include I/O to the terminal, and then reinstall
the remote_interrupt handler. If the user hits C-c while
handle_sigint is installed, remote_interrupt won't be called; we'll
hang around waiting for a QUIT.
Here's the obvious fix. Tested on x86_64-linux and powerpc-linux;
it fixes manythreads.exp with the new thread notification patch
and otherwise has no effect, but the failure is in theory possible
without additional patches.
Checked in.
--
Daniel Jacobowitz
CodeSourcery
2008-01-23 Daniel Jacobowitz <dan@codesourcery.com>
* remote.c (remote_wait): Handle SIGINT between packets.
(remote_async_wait): Likewise.
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.276
diff -u -p -r1.276 remote.c
--- remote.c 23 Jan 2008 11:26:28 -0000 1.276
+++ remote.c 23 Jan 2008 20:40:37 -0000
@@ -3204,6 +3204,13 @@ remote_wait (ptid_t ptid, struct target_
char *buf, *p;
ofunc = signal (SIGINT, remote_interrupt);
+ /* If the user hit C-c before this packet, or between packets,
+ pretend that it was hit right here. */
+ if (quit_flag)
+ {
+ quit_flag = 0;
+ remote_interrupt (SIGINT);
+ }
getpkt (&rs->buf, &rs->buf_size, 1);
signal (SIGINT, ofunc);
@@ -3413,7 +3420,16 @@ remote_async_wait (ptid_t ptid, struct t
char *buf, *p;
if (!target_is_async_p ())
- ofunc = signal (SIGINT, remote_interrupt);
+ {
+ ofunc = signal (SIGINT, remote_interrupt);
+ /* If the user hit C-c before this packet, or between packets,
+ pretend that it was hit right here. */
+ if (quit_flag)
+ {
+ quit_flag = 0;
+ remote_interrupt (SIGINT);
+ }
+ }
/* FIXME: cagney/1999-09-27: If we're in async mode we should
_never_ wait for ever -> test on target_is_async_p().
However, before we do that we need to ensure that the caller