Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Codesign gdb on OSX


Note: these instructions are for pre-Sierra MacOS. Sierra (10.12) and newer users see https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d by @gravitylow



If you are getting this in gdb on OSX while trying to run a program:

Unable to find Mach task port for process-id 57573: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
  1. Open Keychain Access
  2. In the 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
  4. Continue until it prompts you for: "specify a location for..."
  5. Set Keychain location to System
  6. Create a certificate and close assistant.
  7. Find the certificate in System keychains, right click it > get info (or just double click it)
  8. Expand Trust, set Code signing to always trust
  9. Restart taskgated in terminal: killall taskgated
  10. Enable root account:
    1. Open System Preferences
    2. Go to User & Groups > Unlock
    3. Login Options > "Join" (next to Network Account Server)
    4. Click "Open Directory Utility"
    5. Go up to Edit > Enable Root User
  11. Run codesign -fs gdbc /usr/local/bin/gdb in terminal: this asks for the root password
  12. Disable root account (see #10)

Done!

@johnothwolo
Copy link

johnothwolo commented Jan 7, 2020

I won't be surprised if Apple completely disables the root account next.

@HappyTigger
Copy link

HappyTigger commented Jul 26, 2020

No error occurs during the signing. But it does not work. Gdb still requires to be code signed when debugging.

@HCastanha
Copy link

HCastanha commented Oct 24, 2020

Executed thoroughly in 10.15.5. Didn't work properly, unfortunately. Error message persists.

@hlissner
Copy link
Author

hlissner commented Oct 25, 2020

In case anyone misses the giant text at the top of the gist:

Note: these instructions are for pre-Sierra MacOS. Sierra (10.12) and newer users see https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d by @gravitylow

Though, admittedly, I don't even know if the linked guide works. I haven't been on macOS in nearly 8 years. Good luck!

@guipborges
Copy link

guipborges commented Apr 23, 2021

@hao-lh
Copy link

hao-lh commented Sep 8, 2022

I needed to run sudo killall taskgated rather than just killall taskgated, which reported No matching processes belonging to you were found.

Thanks for clarification. Using sudo helped for my machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment