This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: propagate gdb host keyboard interrupts through gdbserver


Ctrl-C on the gdb host had no effect on the inferior running on
gdbserver (at least for TCP/IP transport, though I expect serial
fails identically).

Tested on ppc netbsd & Linux.

2000-11-22  Greg McGary  <greg@mcgary.org>

	* remote-utils.c (remote_open): Set gdbserver as "owner" of SIGIO.
	(input_interrupt): Don't block on read, in case we got redundant SIGIO.
	Don't gripe about redundant SIGIO.
	* low-linux.c (mywait): Use waitpid.  Enable SIGIO handler while waiting.
	* low-hppabsd.c (mywait): Likewise.
	* low-nbsd.c (mywait): Likewise.
	* low-sparc.c (mywait): Likewise.

Index: gdbserver/remote-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/remote-utils.c,v
retrieving revision 1.3
diff -u -p -r1.3 remote-utils.c
--- remote-utils.c	2000/07/30 01:48:28	1.3
+++ remote-utils.c	2000/11/23 02:22:18
@@ -1,5 +1,5 @@
 /* Remote utility routines for the remote server for GDB.
-   Copyright (C) 1986, 1989, 1993 Free Software Foundation, Inc.
+   Copyright (C) 1986, 1989, 1993, 2000 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -31,6 +31,8 @@
 #include <sys/ioctl.h>
 #include <signal.h>
 #include <fcntl.h>
+#include <sys/time.h>
+#include <unistd.h>
 
 int remote_debug = 0;
 struct ui_file *gdb_stdlog;
@@ -155,8 +157,11 @@ remote_open (char *name)
 #if defined(F_SETFL) && defined (FASYNC)
   save_fcntl_flags = fcntl (remote_desc, F_GETFL, 0);
   fcntl (remote_desc, F_SETFL, save_fcntl_flags | FASYNC);
+#endif
+#if defined (F_SETOWN)
+  fcntl (remote_desc, F_SETOWN, getpid ());
+#endif
   disable_async_io ();
-#endif /* FASYNC */
   fprintf (stderr, "Remote debugging using %s\n", name);
 }
 
@@ -260,18 +265,20 @@ putpkt (char *buf)
 static void
 input_interrupt (void)
 {
-  int cc;
-  char c;
+  fd_set readset;
+  struct timeval immediate = { 0, 0 };
 
-  cc = read (remote_desc, &c, 1);
-
-  if (cc != 1 || c != '\003')
+  FD_ZERO (&readset);
+  FD_SET (remote_desc, &readset);
+  if (select (remote_desc + 1, &readset, 0, 0, &immediate) > 0)
     {
-      fprintf (stderr, "input_interrupt, cc = %d c = %d\n", cc, c);
-      return;
+      char c;
+      int cc = read (remote_desc, &c, 1);
+      if (cc == 1 && c == '\003')
+	kill (inferior_pid, SIGINT);
+      else
+	fprintf (stderr, "input_interrupt, cc = %d c = %d\n", cc, c);
     }
-
-  kill (inferior_pid, SIGINT);
 }
 
 void
Index: gdbserver/low-hppabsd.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/low-hppabsd.c,v
retrieving revision 1.2
diff -u -p -r1.2 low-hppabsd.c
--- low-hppabsd.c	2000/07/30 01:48:28	1.2
+++ low-hppabsd.c	2000/11/23 02:22:18
@@ -1,5 +1,5 @@
 /* Low level interface to ptrace, for the remote server for GDB.
-   Copyright (C) 1995 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2000 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -108,7 +108,9 @@ mywait (char *status)
   int pid;
   union wait w;
 
-  pid = wait (&w);
+  enable_async_io ();
+  pid = waitpid (inferior_pid, &w, 0);
+  disable_async_io ();
   if (pid != inferior_pid)
     perror_with_name ("wait");
 
Index: gdbserver/low-linux.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/low-linux.c,v
retrieving revision 1.4
diff -u -p -r1.4 low-linux.c
--- low-linux.c	2000/07/30 01:48:28	1.4
+++ low-linux.c	2000/11/23 02:22:18
@@ -1,5 +1,5 @@
 /* Low level interface to ptrace, for the remote server for GDB.
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2000 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -116,7 +116,9 @@ mywait (char *status)
   int pid;
   union wait w;
 
-  pid = wait (&w);
+  enable_async_io ();
+  pid = waitpid (inferior_pid, &w, 0);
+  disable_async_io ();
   if (pid != inferior_pid)
     perror_with_name ("wait");
 
Index: gdbserver/low-nbsd.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/low-nbsd.c,v
retrieving revision 1.5
diff -u -p -r1.5 low-nbsd.c
--- low-nbsd.c	2000/11/21 00:25:58	1.5
+++ low-nbsd.c	2000/11/23 02:22:18
@@ -171,7 +171,9 @@ mywait (char *status)
   int pid;
   int w;
 
-  pid = wait (&w);
+  enable_async_io ();
+  pid = waitpid (inferior_pid, &w, 0);
+  disable_async_io ();
   if (pid != inferior_pid)
     perror_with_name ("wait");
 
Index: gdbserver/low-sparc.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/low-sparc.c,v
retrieving revision 1.2
diff -u -p -r1.2 low-sparc.c
--- low-sparc.c	2000/07/30 01:48:28	1.2
+++ low-sparc.c	2000/11/23 02:22:18
@@ -1,5 +1,5 @@
 /* Low level interface to ptrace, for the remote server for GDB.
-   Copyright (C) 1986, 1987, 1993 Free Software Foundation, Inc.
+   Copyright (C) 1986, 1987, 1993, 2000 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -113,7 +113,9 @@ mywait (char *status)
   int pid;
   union wait w;
 
-  pid = wait (&w);
+  enable_async_io ();
+  pid = waitpid (inferior_pid, &w, 0);
+  disable_async_io ();
   if (pid != inferior_pid)
     perror_with_name ("wait");
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]