Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb terminated with signal ?, unknown signal

Tags:

c

macos

gdb

I'm just trying to debug code with gdb on Mac OSX Version 10.12 but always getting this unknown error when launching my program in gdb.

I codesigned the gdb after installation and compiled my code with the -g flag.

This is what is happening:

computer:hello user$ gdb a.out
GNU gdb (GDB) 7.12
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin16.0.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...Reading symbols from /Users/user/Documents/Programming/hello/a.out.dSYM/Contents/Resources/DWARF/a.out...done.
done.
(gdb) r
Starting program: /Users/user/Documents/Programming/hello/a.out 
During startup program terminated with signal ?, Unknown signal.

Temporary I got the SIGTRAP signal, but I could not figure out why it's now throwing the Unknown signal again.

like image 910
Mario P. Waxenegger Avatar asked Oct 14 '16 21:10

Mario P. Waxenegger


3 Answers

Solution for Mac OS X 10.12.5 and newer

Create a .gdbinit file in your home-direcetory and write "set startup-with-shell off" in it.

File can be created using vi ~/.gdbinit.

Open a new terminal and gdb will work.

like image 181
lakeslove Avatar answered Oct 25 '22 03:10

lakeslove


This worked for me, if you are still looking for a solution:

  • Restart youre machine in the recovery mode, open a terminal and enter the following

    $ csrutil enable --without debug

    Reboot the machine and gdb should work as usual (full thread in here: http://sourceware-org.1504.n7.nabble.com/gdb-on-macOS-10-12-quot-Sierra-quot-td415708.html#a415940)

like image 25
s.yadegari Avatar answered Oct 25 '22 01:10

s.yadegari


It's because you're using the latest version of OSX 10.12 or 10.12.1. Downgrading or waiting for an OSX/GDB fix seems like the best options. I've faffed around all day figuring this out. Don't waste your time trying to work around it with Sierra!

like image 40
user4992332 Avatar answered Oct 25 '22 02:10

user4992332