Question or issue on macOS:

I have installed gdb 8.1 with brew.

I have codesign gdb also and .gdbinit as below:

$ cd gdb-7.11 gdb-7.11$./configure gdb-7.11$ make This step will take a bit of time. So you can sit back and have cup of coffee for a while. Once it is completed, you can locate gdb binary located at gdb-7.11/gdb/gdb. Step-4: Install GDB. $ make install By default this will install gdb binaries in /usr/local/bin and libs in /usr/local/lib. Once you have Homebrew, you can install gdb. If you're using High Sierra (macOS 10.13) or later, be aware that gdb 8.1 and 8.2 are not compatible. You can either use gdb 8.0.1 or one of the latest versions, starting from 8.3. In this tutorial, I'm going to use gdb 8.3. Cd gdb-7.12.1 in terminal to open the gdb folder then follow the instructions in the README file in the gdb folder, or simply follow the following steps./configure, wait for the terminal make and wait again (which can take some time). Install Disk Creator is a straightforward way to create a boot disk. I was able to make a macOS Sierra external USB boot disk in a few minutes, and the installation worked without a hitch.

set startup-with-shell off.

I have disabled SIP feature:

But gdb still doesn’t work:

Mac

Compile command:

gdb output:

What correct steps to make gdb work on macos sierra?

How to solve this problem?

Solution no. 1:

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

Install Gdb Mac High Sierra

Mac

Solution no. 2:

Install Gdb For Mac Sierra Download

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+)

  1. Open Keychain Access
  2. In menu, open Keychain Access > Certificate Assistant > Create a certificate
  3. Give it a name (e.g. gdb-cert)
    • Identity type: Self Signed Root
    • Certificate type: Code Signing
    • Check: let me override defaults
  4. Continue until 'specify a location for...'
  5. Set Keychain location to System
  6. Create certificate and close Certificate Assistant.
  7. Find certificate in System keychain.
  8. Double click the certificate
  9. Expand Trust, set Code signing to always trust
  10. Restart taskgated in terminal: killall taskgated
  11. Codesign gdb using your certificate: codesign -fs gdb-cert /usr/local/bin/gdb
  12. --- CHECK IF IT WORKS ---
  13. Shut down your mac and restart in recovery mode (hold down command-Runtil apple logo appears)
  14. Open terminal window
  15. Modify System Integrity Protection to allow debugging: csrutil enable --without debug
  16. Reboot your Mac
  17. 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

Solution no. 3:

I'm using macOS 10.13.6 and I was having the same issue that ' (please check gdb is codesigned - see taskgated(8))' ...

When I downgraded the GDB from 8.2.1 to 8.0.1 and then created and signed the gdb-cert again and it simply worked..

Don't forget to change the path of gdb from 8.2.1 to 8.0.1 in debugger of eclipse, restart and it will work.

Hope this helps!

Here are the steps to installing and setting up GDB on Mac OS Sierra/High Sierra.Run brew install gdb.On starting gdb, you will get the following error:

To fix this error, follow the following steps:

  1. Open Keychain Access
  2. In menu, open Keychain Access > Certificate Assistant > Create a Certificate
  3. Give it a name (e.g. gdbcert)
  • Identity type: Self Signed Root
  • Certificate type: Code Signing
  • Check: Let Me Override Defaults
  1. Continue until 'Specify a Location For'
  2. Set Keychain location to System. If this yields the following error:Certificate Error: Unknown Error =-2,147,414,007Set Location to Login, Unlock System by click on the lock at the top left corner and drag and drop the certificate gdbcert to the System Keychain.
  3. Create certificate and close Certificate Assistant.
  4. Find the certificate in System keychain.
  5. Double click certificate.
  6. Expand Trust, set Code signing to Always Trust
  7. Restart taskgated in terminal: killall taskgated
  8. Enable root account by following the steps given below:Open System Preferences.Go to User & Groups > Unlock.Login Options > 'Join' (next to Network Account Server).Click 'Open Directory Utility'.Go up to Edit > Enable Root User.
  9. Codesign gdb using your certificate: codesign -fs gdbc /usr/local/bin/gdb
  10. Shut down your mac and restart in recovery mode (hold down command-R until apple logo appears)
  11. Open terminal window
  12. Modify System Integrity Protection to allow debugging: csrutil enable --without debug
  13. Reboot your Mac. Debugging with gdb should now work as expected.