Bug 20035

Summary: gdb doesn't handle SIGINT on OS X when attaching to a process
Product: gdb Reporter: edmunoz
Component: gdbAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: Anton.Makeev, pedro
Priority: P2    
Version: 7.11   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description edmunoz 2016-05-02 20:30:09 UTC
On OS X, when attaching to a simple program (e.g., infinite loop), gdb doesn't handle SIGINT signals sent to the debuggee, and hence the process can't be interrupted. This does not repro when the debuggee is started by gdb (using 'run').

1. Attach gdb
$ gdb a.out
(gdb) attach <PID>
(gdb) continue

2. Send a SIGINT to the debuggee
$ kill -2 <PID>

3. The debuggee exits
[Inferior 1 (process <PID>) exited normally]

Expected
gdb should handle the SIGINT sent to the debuggee, as shown when executing "info handle".

I tried this with executables built with clang and gcc (gcc-5 (Homebrew gcc 5.3.0) 5.3.0).

The configuration of gdb is

--host=x86_64-apple-darwin14.5.0 --target=x86_64-apple-darwin14.5.0
--with-auto-load-dir=:${prefix}/share/auto-load
--with-auto-load-safe-path=:${prefix}/share/auto-load
--with-expat
--with-gdb-datadir=/usr/local/Cellar/gdb/7.11/share/gdb (relocatable)
--with-jit-reader-dir=/usr/local/Cellar/gdb/7.11/lib/gdb (relocatable)
--without-libunwind-ia64
--without-lzma
--with-python=/System/Library/Frameworks/Python.framework/Versions/2.7
--without-guile
--with-separate-debug-dir=/usr/local/Cellar/gdb/7.11/lib/debug (relocatable)
--without-babeltrace


The version of my OS is OS X Yosemite 10.10.5

$ uname -a
Darwin 14.5.0 Darwin Kernel Version 14.5.0: Mon Jan 11 18:48:35 PST 2016; root:xnu-2782.50.2~1/RELEASE_X86_64 x86_64
Comment 1 Pedro Alves 2016-05-02 21:55:19 UTC
I'm clueless on the darwin/osx debug API, but it sounds like gdb is never notified of the SIGINT.  "set debug darwin 1" and "set debug infrun 1" may reveal something.  The darwin target code is in darwin-nat.c, if you want to take a look yourself.