From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19189 invoked by alias); 28 Feb 2004 18:14:00 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 19179 invoked from network); 28 Feb 2004 18:13:59 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sources.redhat.com with SMTP; 28 Feb 2004 18:13:59 -0000 Received: from drow by nevyn.them.org with local (Exim 4.30 #1 (Debian)) id 1Ax8yN-0004Pd-BN for ; Sat, 28 Feb 2004 13:13:59 -0500 Date: Sat, 28 Feb 2004 18:14:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sources.redhat.com Subject: [patch/gdbserver] Handle early interrupts Message-ID: <20040228181359.GA16903@nevyn.them.org> Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.1i X-SW-Source: 2004-02/txt/msg00846.txt.bz2 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 * 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);