Skip to content

Instantly share code, notes, and snippets.

@gravitylow
Created September 5, 2017 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gravitylow/e2112c543058b82be802a78202ac5e42 to your computer and use it in GitHub Desktop.
Save gravitylow/e2112c543058b82be802a78202ac5e42 to your computer and use it in GitHub Desktop.
Using gdb for Eclipse CDT debugging

macOS no longer includes gdb (the GNU debugger) by default, so you must install it yourself.

If you don't already have it, install homebrew, the package manager for macOS, using Terminal: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Use homebrew to install gdb: brew install gdb

You now need to codesign gdb to allow it the extra permissions it needs to run.

  1. Open Keychain Access
  2. In menu, open Keychain Access > Certificate Assistant > Create a certificate
  3. Give it a name (e.g. gdbc)
  • 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
  3. Create certificate and close Certificate Assistant.
  4. Find 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. Codesign gdb using your certificate: codesign -fs gdbc /usr/local/bin/gdb

You now need to disable macOS's extra integrity protections against adding new debuggers.

  1. Shut down your mac and restart in recovery mode (hold down command-R until apple logo appears)
  2. Open terminal window
  3. Modify System Integrity Protection to allow debugging: csrutil enable --without debug
  4. Reboot your Mac. Debugging with gdb should now work as expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment