gdb doesn't work on macos High Sierra 10.13.3
This is caused by latest gdb 8.1, downgrade gdb to 8.0.1 could solve this problem.
How to downgrade to gdb 8.0.1
- Unlink current gdb:
brew unlink gdb
- Install gdb 8.0.1:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/9ec9fb27a33698fc7636afce5c1c16787e9ce3f3/Formula/gdb.rb
- Optional: avoid upgrade gdb with
brew pin gdb
in my case downgrading to 8.0.1 didn't help.
but the following steps helped.
(i inserted step 12, "check if it works" because, instead of restarting i've tested gdb and it worked just fine. i didn't follow the steps 12+)
- Open Keychain Access
- In menu, open Keychain Access > Certificate Assistant > Create a certificate
- Give it a name (e.g.
gdb-cert
)- Identity type: Self Signed Root
- Certificate type: Code Signing
- Check: let me override defaults
- Continue until "specify a location for..."
- Set Keychain location to System
- Create certificate and close Certificate Assistant.
- Find certificate in System keychain.
- Double click the certificate
- Expand Trust, set Code signing to always trust
- Restart taskgated in terminal:
killall taskgated
- Codesign gdb using your certificate:
codesign -fs gdb-cert /usr/local/bin/gdb
- --- CHECK IF IT WORKS ---
- Shut down your mac and restart in recovery mode (hold down
command-R
until apple logo appears) - Open terminal window
- Modify System Integrity Protection to allow debugging:
csrutil enable --without debug
- Reboot your Mac
- Debugging with gdb should now work as expected.
information source:
pre Sierra: https://gist.github.com/hlissner/898b7dfc0a3b63824a70e15cd0180154
Sierra: https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d