Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: gdb-patches@sources.redhat.com
Subject: [patch/gdbserver] Handle early interrupts
Date: Sat, 28 Feb 2004 18:14:00 -0000	[thread overview]
Message-ID: <20040228181359.GA16903@nevyn.them.org> (raw)

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);


             reply	other threads:[~2004-02-28 18:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-28 18:14 Daniel Jacobowitz [this message]
2004-02-29 16:47 ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040228181359.GA16903@nevyn.them.org \
    --to=drow@false.org \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox