I am trying to run gdb on Mac OSX Sierra. I have installed the package using brew and codesigned it as well. GDB starts normally and when I try to run the debugger it correctly prompts for permission to interact with a process. However, once it is running it immediately crashes, citing an unhandled dyld version. I found a similar issue here https://github.com/Homebrew/brew/issues/2636 but I cannot find any record of it being reported here. The response to the aforementioned post indicated that it should be reported here, so I figured I should try. My apologies if this was in error.
I was trying to run gdb through emacs (m-x gdb) and I got specifically this error message:
warning: unhandled dyld version (15)
The error is the same if I run gdb through shell.
The installation steps I used were
brew install gdb
killall taskgated
sudo codesign gdb-cert /usr/local/bin/gdb
sudo launchctl load /System/Library/LaunchDaemons/com.apple.taskgated.plist
Did you follow _all_ of the instructions in the Caveats, making sure to read and follow all of the directions on the _BuildingOnDarwin_ wiki page?
==> Caveats
gdb requires special privileges to access Mach ports.
You will need to codesign the binary. For instructions, see:
https://sourceware.org/gdb/wiki/BuildingOnDarwin
On 10.12 (Sierra) or later with SIP, you need to run this:
echo "set startup-with-shell off" >> ~/.gdbinit
I ran into this when I installed gdb this morning. I followed both of those directions (codesign the binary, add that line to my .gdbinit).
Did you follow the specific instructions regarding codesigning the gdb binary that are described on that page? Namely the location of the codesigning certificate and signing using the full path of the binary?
I did follow the both parts of the instructions, including code signing the certificate and adding the specified line to my .gdbinit. To double check that .gdbinit was loading, I installed an improved .gdbinit available for free and I have the same error, though it does show a more detailed output when I interrupt the process after it fails due to the dyld version.
Followed detailed and updated instructions for macOS 10.13 (High Sierra) here: https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d
The GDB Wiki has not been updated to reflect recent macOS changes in SIP: https://sourceware.org/gdb/wiki/BuildingOnDarwin
After running codesign, killing taskgated, restarting in Recovery mode (Cmd + R), and running csrutil enable --without debug in that mode, then restarting, I still see the same error in gdb and the breakpoints don't work.
(gdb) break a.out:5
No symbol table is loaded. Use the "file" command.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (a.out:5) pending.
(gdb) run
Starting program: /Users/olivierlacan/Development/sandbox/a.out
[New Thread 0x1703 of process 3501]
warning: unhandled dyld version (15)
Hello, World![Inferior 1 (process 3501) exited normally]
This is after using cc on the following C code to output a.out:
#include <stdio.h>
int main()
{
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}
And yes, ~/.gdbinit also contains set startup-with-shell off. And the only way I can get gdb to even run on a.out is by starting it with with sudo gdb a.out. Running gdb a.out directly results in the following:
Starting program: /Users/olivierlacan/Development/sandbox/a.out
Unable to find Mach task port for process-id 4906: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
And before you ask:
$ codesign -s gdb-cert /usr/local/bin/gdb
/usr/local/bin/gdb: is already signed
I have the same problem, and I have signed gdb according to the instructions.
Before signing gdb I received this error message:
Starting program: /Users/randall/git/pax-common-code/repos/apache-mynewt-core/bin/targets/slinky_sim/app/apps/slinky/slinky.elf
Unable to find Mach task port for process-id 32935: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
After successfully signing gdb, I receive this:
[New Thread 0x1303 of process 85600]
warning: unhandled dyld version (15)
To show that the signing worked:
codesign -v /usr/local/Cellar/gdb/8.0.1/bin/gdb
yields no error messages.
I have the very same problem:
warning: unhandled dyld version (15)and I did follow all instructions as well.
However, contrary to @olivierlacan , I am able to start gdb without sudo:
[build]$ gdb ../install/bin/example_pdebug
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 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.7.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 ../install/bin/example_pdebug...done.
(gdb) b 22
Breakpoint 1 at 0x1000071e0: file /Users/cbernet/Code/FCC/papas/examples/example_pdebug_python_comparer.cpp, line 22.
(gdb) run
Starting program: /Users/cbernet/Code/FCC/papas/install/bin/example_pdebug
[New Thread 0x1403 of process 23573]
warning: unhandled dyld version (15)
Usage: ./example_debug filename detector [logname]
[Inferior 1 (process 23573) exited with code 01]
If I start with sudo, I get another error:
[build]$ sudo gdb ../install/bin/example_pdebug
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 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.7.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 ../install/bin/example_pdebug...done.
(gdb) b 22
Breakpoint 1 at 0x1000071e0: file /Users/cbernet/Code/FCC/papas/examples/example_pdebug_python_comparer.cpp, line 22.
(gdb) run
Starting program: /Users/cbernet/Code/FCC/papas/install/bin/example_pdebug
[New Thread 0x1a03 of process 23587]
warning: unhandled dyld version (15)
dyld: Library not loaded: @rpath/libpapas.so
Referenced from: /Users/cbernet/Code/FCC/papas/install/bin/example_pdebug
Reason: image not found
Thread 2 received signal SIGABRT, Aborted.
0x00000001000bd9ee in ?? ()
You'll need to seek help from upstream troubleshooting this.
For those curious, warning: unhandled dyld version (15) is occurring because gdb 8.0.1 doesn't include commit 4bbd4ef, which updates the maximum version of dyld that gdb says it can handle.
Most helpful comment
For those curious,
warning: unhandled dyld version (15)is occurring because gdb 8.0.1 doesn't include commit 4bbd4ef, which updates the maximum version of dyld that gdb says it can handle.