Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: jtc@redback.com (J.T. Conklin)
To: gdb-patches@sourceware.cygnus.com
Subject: PATCH: propagate gdb host keyboard interrupts through gdbserver
Date: Wed, 11 Jul 2001 10:40:00 -0000	[thread overview]
Message-ID: <5mzoabbbzd.fsf@jtc.redback.com> (raw)

I just committed the enclosed patch.  It's a patch Greg McGary
submitted all too long ago.

I took the liberty of adding a comment explaining why code to ignore
spurious interrupts was added.  I also tweaked the change to input_-
interrupt() to more closely resemble the original code.

        --jtc

2001-07-11  Greg McGary  <greg@mcgary.org>
 
	* gdbserver/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.
	* gdbserver/low-hppabsd.c (mywait): Use waitpid().  Enable SIGIO
	handler while waiting.
	* gdbserver/low-linux.c (mywait): Likewise.
	* gdbserver/low-nbsd.c (mywait): Likewise.
	* gdbserver/low-sparc.c (mywait): Likewise.

Index: gdbserver/low-hppabsd.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/low-hppabsd.c,v
retrieving revision 1.7
diff -c -r1.7 low-hppabsd.c
*** low-hppabsd.c	2001/04/06 22:25:09	1.7
--- low-hppabsd.c	2001/07/11 17:29:58
***************
*** 96,102 ****
    int pid;
    union wait w;
  
!   pid = wait (&w);
    if (pid != inferior_pid)
      perror_with_name ("wait");
  
--- 96,104 ----
    int pid;
    union 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.9
diff -c -r1.9 low-linux.c
*** low-linux.c	2001/03/28 09:15:22	1.9
--- low-linux.c	2001/07/11 17:29:58
***************
*** 105,111 ****
    int pid;
    union wait w;
  
!   pid = wait (&w);
    if (pid != inferior_pid)
      perror_with_name ("wait");
  
--- 105,113 ----
    int pid;
    union 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.9
diff -c -r1.9 low-nbsd.c
*** low-nbsd.c	2001/04/06 22:25:09	1.9
--- low-nbsd.c	2001/07/11 17:29:59
***************
*** 172,178 ****
    int pid;
    int w;
  
!   pid = wait (&w);
    if (pid != inferior_pid)
      perror_with_name ("wait");
  
--- 172,180 ----
    int pid;
    int 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.6
diff -c -r1.6 low-sparc.c
*** low-sparc.c	2001/04/06 22:25:09	1.6
--- low-sparc.c	2001/07/11 17:29:59
***************
*** 102,108 ****
    int pid;
    union wait w;
  
!   pid = wait (&w);
    if (pid != inferior_pid)
      perror_with_name ("wait");
  
--- 102,110 ----
    int pid;
    union wait w;
  
!   enable_async_io ();
!   pid = waitpid (inferior_pid, &w, 0);
!   disable_async_io ();
    if (pid != inferior_pid)
      perror_with_name ("wait");
  
Index: gdbserver/remote-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/remote-utils.c,v
retrieving revision 1.4
diff -c -r1.4 remote-utils.c
*** remote-utils.c	2001/03/06 08:21:44	1.4
--- remote-utils.c	2001/07/11 17:30:00
***************
*** 1,5 ****
  /* Remote utility routines for the remote server for GDB.
!    Copyright 1986, 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
     Free Software Foundation, Inc.
  
     This file is part of GDB.
--- 1,5 ----
  /* Remote utility routines for the remote server for GDB.
!    Copyright 1986, 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
     Free Software Foundation, Inc.
  
     This file is part of GDB.
***************
*** 32,37 ****
--- 32,39 ----
  #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;
***************
*** 156,163 ****
  #if defined(F_SETFL) && defined (FASYNC)
    save_fcntl_flags = fcntl (remote_desc, F_GETFL, 0);
    fcntl (remote_desc, F_SETFL, save_fcntl_flags | FASYNC);
    disable_async_io ();
- #endif /* FASYNC */
    fprintf (stderr, "Remote debugging using %s\n", name);
  }
  
--- 158,168 ----
  #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 ();
    fprintf (stderr, "Remote debugging using %s\n", name);
  }
  
***************
*** 261,278 ****
  static void
  input_interrupt (void)
  {
!   int cc;
!   char c;
  
!   cc = read (remote_desc, &c, 1);
  
!   if (cc != 1 || c != '\003')
      {
!       fprintf (stderr, "input_interrupt, cc = %d c = %d\n", cc, c);
!       return;
!     }
  
!   kill (inferior_pid, SIGINT);
  }
  
  void
--- 266,294 ----
  static void
  input_interrupt (void)
  {
!   fd_set readset;
!   struct timeval immediate = { 0, 0 };
  
!   /* Protect against spurious interrupts.  This has been observed to
!      be a problem under NetBSD 1.4 and 1.5.  */
  
!   FD_ZERO (&readset);
!   FD_SET (remote_desc, &readset);
!   if (select (remote_desc + 1, &readset, 0, 0, &immediate) > 0)
      {
!       int cc;
!       char c;
!       
!       cc = read (remote_desc, &c, 1);
  
!       if (cc != 1 || c != '\003')
! 	{
! 	  fprintf (stderr, "input_interrupt, cc = %d c = %d\n", cc, c);
! 	  return;
! 	}
!       
!       kill (inferior_pid, SIGINT);
!     }
  }
  
  void


-- 
J.T. Conklin
RedBack Networks


             reply	other threads:[~2001-07-11 10:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-11 10:40 J.T. Conklin [this message]
2001-07-11 11:27 ` 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=5mzoabbbzd.fsf@jtc.redback.com \
    --to=jtc@redback.com \
    --cc=gdb-patches@sourceware.cygnus.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