Codesign gdb on Mac OS X Yosemite (10.10.2)

Table of Content

Mac OS X 10.10.2 does not come with gdb pre installed. It is available on homebrew:

$ brew tap homebrew/dupes
$ brew install gdb

The binary is installed on /usr/local/bin

When initializing gdb on a program (a.out) it will produce the following error:

    Starting program: a.out
    Unable to find Mach task port for process-id XXXXX: (os/kern) failure (0x5).
     (please check gdb is codesigned - see taskgated(8))
Start Keychain Access application (/Applications/Utilities/Keychain

This error occurs because OSX implements a pid access policy which requires a digital signature for binaries to access other processes pids. To enable gdb access to other processes, we must first code sign the binary. This signature depends on a particular certificate, which the user must create and register with the system.

To create a code signing certificate, open the Keychain Access application. Choose menu Keychain Access -> Certificate Assistant -> Create a Certificate...

Choose a name for the certificate (e.g., gdb-cert), set Identity Type to Self Signed Root, set Certificate Type to Code Signing and select the Let me override defaults. Click several times on Continue until you get to the Specify a Location For The Certificate screen, then set Keychain to System.

Double click on the certificate, open Trust section, and set Code Signing to Always Trust. Exit Keychain Access application.

Restart the taskgated service, and sign the binary.

$ sudo killall taskgated
$ codesign -fs gdb-cert /usr/local/bin/gdb


  • It worked like a charm – thanks man!

  • thank you! works great!

  • Did not work for the macOS Sienna 10.12.3 version unfortunately. :/

  • Did not work for the macOS Sienna 10.12.3 version unfortunately. :/

  • it works for MacOS Serra 10.12.4

  • Thank you! Worked for Sierra too!

  • Thank you!

  • Downgraded back to Yosemite 10.10 & this worked like a charm!

  • Did not work for macOS High Sierra, 10.13.1

    I get: “Unknown Error = -2,147,414,007”

  • Did not work with macOS High Sierra unles I run gdb with root..

  • Does not work for 10.13.2, obtain “Unknown Error = -2,147,414,007”, too.

  • I also get “Unknown Error = -2,147,414,007”

  • Hi everyone! I’ve since moved away from MacOS. I can’t really help on this one.

  • I get this error:
    codesign -fs gdb-certif /usr/local/bin/gdb
    error: The specified item could not be found in the keychain.

  • Unknown Error = -2,147,414,007 can be avoided by creating the certificate in the login keychain and then dragging into the system keychain

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>