This is the mail archive of the gdb-prs@sourceware.org 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]
Other format: [Raw text]

[Bug gdb/10123] New: gdb fails to interrupt program being debugged


TEST PLATFORM:

Linux ubuntu 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 i686 GNU/Linux
GNU gdb 6.8-debian
This GDB was configured as "i486-linux-gnu".


SUMMARY:

gdb fails to interrupt the program being debugged if the program is blocking SIGINT.

When using the sigwait function to retrieve signals, the program is expected to block them.  SIGINT is a commonly handled signal.  Any 
program using sigwait to retrieve signals and handling SIGINT this way will not be interruptible by gdb.


STEPS TO REPRODUCE:

1. Save this file as noint.c:

  #include <stddef.h>
  #include <unistd.h>
  #include <signal.h>
  
  int main(int argc, char *argv[])
  {
    sigset_t sigs;
    sigfillset(&sigs);
    sigprocmask(SIG_SETMASK, &sigs, NULL);
    for (;;) {
      pause();
      write(STDERR_FILENO, "Nope\n", 5);
    }
    return 0;
  }

2. Compile it like this:

  gcc -o noint -O0 -g noint.c

3. Load it under gdb like so:

  gdb -tty /dev/null noint

4. Then run it with the "run" gdb command

5. Now attempt to interrupt it by pressing Ctrl-C

6. Notice it's not interruptible and gdb does not regain control


EXPECTED RESULTS:

The expectation is that gdb will regain control when Ctrl-C is pressed.  Commenting out the call to sigprocmask and repeating the steps will 
result in gdb gaining control when Ctrl-C is pressed.


NOTES

Running gdb using the mi interpreter (as opposed to the console interpreter) has the same problem when using -exec-interrupt instead of 
Ctrl-C.

The Apple-specific version of gdb available from:

  http://opensource.apple.com/darwinsource/tarballs/other/gdb-768.tar.gz

suffers from the same problem.

The following patch, which makes minor changes to the macosx_child_stop and mi_cmd_exec_interrupt functions, is enough to eliminate the 
problem in the Apple-specific version of gdb (both for the Ctrl-C case and the -exec-interrupt case).  These changes may be a helpful guide 
to fixing other versions.

Here are the contents of patch for the Apple-specific version of gdb:

  --- gdb/macosx/macosx-nat-inferior.c	2007-09-19 19:03:27.000000000 -0700
  +++ gdb/macosx/macosx-nat-inferior.c	2009-05-01 10:25:02.000000000 -0700
  @@ -1085,7 +1085,7 @@
     extern pid_t inferior_process_group;
     int ret;
   
  -  ret = kill (inferior_process_group, SIGINT);
  +  ret = kill (inferior_process_group, SIGSTOP);
   }
   
   static void
  --- gdb/mi/mi-main.c	2007-06-21 18:28:02.000000000 -0700
  +++ gdb/mi/mi-main.c	2009-05-01 21:38:47.000000000 -0700
  @@ -296,7 +296,7 @@
     else
       {
         int pid = PIDGET (inferior_ptid);
  -      kill (pid, SIGINT);
  +      kill (pid, SIGSTOP);
       }
   
     if (current_command_token) {

-- 
           Summary: gdb fails to interrupt program being debugged
           Product: gdb
           Version: 6.8
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: mackyle at gmail dot com
                CC: gdb-prs at sourceware dot org
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=10123

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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