This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch/gdbserver] Handle early interrupts
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Sat, 28 Feb 2004 13:13:59 -0500
- Subject: [patch/gdbserver] Handle early interrupts
This patch lets gdbserver start expecting control-C as soon as we begin
resuming threads, instead of as soon as we begin waiting. On slow targets,
especially if one of the threads is scheduled right after the PTRACE_CONT
and before gdbserver has finished waking its siblings, there can be a long
delay. Until this arbitrary, sometimes very long, delay has passed, any
control-C sent by the client will be ignored. The easy solution is to
enable, but block, SIGIO; then unblock it when we're ready and the OS
will automatically deliver it then.
Will commit in a little while. Tested on arm-linux using gdbserver
(I've forgotten to mention that for the last few patches, but it's true of
all of them).
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2004-02-28 Daniel Jacobowitz <drow@mvista.com>
* linux-low.c (linux_wait): Unblock async I/O.
(linux_resume): Block and enable async I/O.
* remote-utils.c (block_async_io, unblock_async_io): New functions.
* server.h (block_async_io, unblock_async_io): Add prototypes.
Index: gdb/gdbserver/linux-low.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/gdbserver/linux-low.c,v
retrieving revision 1.27
diff -u -p -r1.27 linux-low.c
--- gdb/gdbserver/linux-low.c 31 Jan 2004 22:19:31 -0000 1.27
+++ gdb/gdbserver/linux-low.c 27 Feb 2004 21:34:28 -0000
@@ -662,6 +662,7 @@ retry:
}
enable_async_io ();
+ unblock_async_io ();
w = linux_wait_for_event (child);
stop_all_processes ();
disable_async_io ();
@@ -1017,7 +1018,11 @@ linux_resume (struct thread_resume *resu
if (pending_flag)
for_each_inferior (&all_threads, linux_queue_one_thread);
else
- for_each_inferior (&all_threads, linux_continue_one_thread);
+ {
+ block_async_io ();
+ enable_async_io ();
+ for_each_inferior (&all_threads, linux_continue_one_thread);
+ }
}
#ifdef HAVE_LINUX_USRREGS
Index: gdb/gdbserver/remote-utils.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/gdbserver/remote-utils.c,v
retrieving revision 1.17
diff -u -p -r1.17 remote-utils.c
--- gdb/gdbserver/remote-utils.c 5 Jun 2003 14:26:58 -0000 1.17
+++ gdb/gdbserver/remote-utils.c 27 Feb 2004 20:54:11 -0000
@@ -366,6 +368,24 @@ input_interrupt (int unused)
}
void
+block_async_io (void)
+{
+ sigset_t sigio_set;
+ sigemptyset (&sigio_set);
+ sigaddset (&sigio_set, SIGIO);
+ sigprocmask (SIG_BLOCK, &sigio_set, NULL);
+}
+
+void
+unblock_async_io (void)
+{
+ sigset_t sigio_set;
+ sigemptyset (&sigio_set);
+ sigaddset (&sigio_set, SIGIO);
+ sigprocmask (SIG_UNBLOCK, &sigio_set, NULL);
+}
+
+void
enable_async_io (void)
{
signal (SIGIO, input_interrupt);
Index: gdb/gdbserver/server.h
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/gdbserver/server.h,v
retrieving revision 1.13
diff -u -p -r1.13 server.h
--- gdb/gdbserver/server.h 29 Jun 2003 04:01:39 -0000 1.13
+++ gdb/gdbserver/server.h 27 Feb 2004 16:15:53 -0000
@@ -134,6 +134,8 @@ void write_ok (char *buf);
void write_enn (char *buf);
void enable_async_io (void);
void disable_async_io (void);
+void unblock_async_io (void);
+void block_async_io (void);
void convert_ascii_to_int (char *from, char *to, int n);
void convert_int_to_ascii (char *from, char *to, int n);
void new_thread_notify (int id);