Just tried out Apple's new beta of the next version of OS X, namely macOS 10.12 Sierra. A freshly compiled gdb 7.11.1 is not capable of debugging anything I've tried yet, it always fails with: During startup program terminated with signal SIGTRAP, Trace/breakpoint trap. This is an issue specific to macOS 10.12 beta, the same gdb works fine under Mac OS X 10.11. I'm not sure if this is an Apple issue or one with gdb, just thought I should let you guys know. Also, lldb is working fine on macOS 10.12, so there's that. (gdb) run Starting program: /Users/k/Desktop/gdb-test/test_program During startup program terminated with signal SIGTRAP, Trace/breakpoint trap. (gdb)
So, the official, final release of Sierra is here and I'm here (alongside another user) to confirm this problem exists and should be treated *ASAP! Link to my recently-created thread on Reddit: https://www.reddit.com/r/learnprogramming/comments/53zmls/gdb_itself_is_crashing_and_i_cant_seem_to_find_a/d7xs95g?context=3
Unfortunately, I don't think that any active maintainer uses macOS routinely. So this likely will only get fixed when someone contributes a fix or investigates what the problem is.
Note that "During startup program terminated..." indicates that it's the shell that died. GDB starts the program like "sh -c '$program $arg1 $arg2'". Usually, on Unix systems, gdb will see one SIGTRAP that indicates that the shell execed the final program, and so gdb is now actually debugging the program. Maybe the problems is that now on macOS gdb needs to expect two traps. See the START_INFERIOR_TRAPS_EXPECTED define in gdb's sources. Try bumping it. But first try the "set startup-with-shell off" command.
(In reply to Pedro Alves from comment #3) > Note that "During startup program terminated..." indicates that it's the > shell that died. GDB starts the program like "sh -c '$program $arg1 $arg2'". > > Usually, on Unix systems, gdb will see one SIGTRAP that indicates that the > shell execed the final program, and so gdb is now actually debugging the > program. > > Maybe the problems is that now on macOS gdb needs to expect two traps. > > See the START_INFERIOR_TRAPS_EXPECTED define in gdb's sources. Try bumping > it. > > But first try the "set startup-with-shell off" command. Thanks for your input, Pedro. I've tried both of your suggestions, but the problem still persists. What's strange is that the problem was fixed when I tried using gdb in Apple's later betas of Sierra, but then the issue reappeared in the official public release. Now, though, the error message has changed to the following: During startup program terminated with signal SIG113, Real-time event 113. I've also verified that the problem exists on macOS 10.12.1 Beta 3 (Build 16B2338c). The issue appears to be affecting everybody using gdb on Sierra, and threads on the topic have started appearing on Stack Overflow and other forums, but nobody seems to have solution yet.
Seems like someone found a workaround: https://sourceware.org/ml/gdb/2016-10/msg00009.html
This seems to hold the answer: https://sourceware.org/ml/gdb/2016-10/msg00062.html
A partial fix went in: https://sourceware.org/ml/gdb/2016-11/msg00011.html But apparently it still needs "set startup-with-shell off"
This fix doesn't work for me on 10.13.3, I get exact same error message with gdb 8.1..
Created attachment 10799 [details] my terminal session leading up to an error See more details in the attachment
art29577 for high sierra this error actually only occurs for 8.1. If you downgrade to 8.0.1 using brew, this issue goes away. Assuming codesigning is done correctly (which is a whole nother unrelated can of worms, the only hiccup in 8.0.1 would be a warning about dyld version, but gdb 8.0.1 works correctly). whatever re-introduced the sig/breakpoint trap that occurred in your terminal output happened between 8.0.1 and 8.1, and should be filed as a new bug, not a continuation of this one from 2016.
by the way, to downgrade from 8.1 to 8.0.1, see the answer to this question: https://stackoverflow.com/questions/49001329/gdb-doesnt-work-on-macos-high-sierra-10-13-3#comment85498442_49001329 The fact that the problem seen in art29577 's terminal session goes away after downgrading to 8.0.1 suggests to me that this is a newer problem, introduced sometime between 8.0.1 and 8.1, *not* the one originally in this thread, which goes back to 6/2016. I have filed a new bug report at bug # 22960.
Unable to find Mach task port for process-id 37095: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))
Neither 8.0.1 nor git master work for me on macOS 10.13.5.
(In reply to Tom Tromey from comment #13) > Neither 8.0.1 nor git master work for me on macOS 10.13.5. Strange, 8.0.1 is working for me on macOS 10.13.6. But not master. This was using "set startup-with-shell off" and signing with codesign.
I don't remember the current state of this bug (for me - since experiences seem to differ unfortunately); but you may be interested in this series: https://sourceware.org/ml/gdb-patches/2018-08/msg00518.html Not in yet but it seemed promising.
I think this is fixed now, so I am going to close it as a dup of bug 23364. startup-with-shell is automatically disabled on master, and that bug will be used to make the shell situation a bit better. Feel free to open if the problem persists with git master. *** This bug has been marked as a duplicate of bug 23364 ***