gdb 8.3;

my problem is the same as the guy above, solved by

codesign --entitlements gdb.xml -fs gdb-cert /usr/local/bin/gdb


i can recommend to follow this gist:

with trick to overcome: unknown error = -2,147,414,007 during certificate creation described here:


path for gdb installed as homebrew package should be something like: /usr/local/cellar/gdb/9.2/bin/gdb

and csrutil enable --without debug will cause a message about requesting unsupported configuration, like here:


○ → sw_vers -productversion

○ → gdb ./a.out
gnu gdb (gdb) 9.2
thread 3 hit breakpoint 1, main () at main.c:14
14          data_t d = {0};


i wonder if the global change in the highest voted answer here has some unintended consequences.

rather than enabling the old tiger convention, taskgated does allow signed code to run. so it might be better to just get a signed cert for gdb, similar to the answer here.

after this i was able to sudo use gdb. if you need to use gdb w/o sudo then perhaps this link will help though, disclaimer, i haven't tried it yet because using sudo is an ok solution for now`.


this is what worked for me on big sur: the crucial missing step from other guides was the --entitlements gdb-entitlement.xml option for codesigning:

i am copying here the file gdb-entitlement.xml for reference in case the linked site disappears: codesign --entitlements gdb-entitlement.xml -fs

where <gdb-cert> is the name of the certificate and is the path to the gdb executable

<!doctype plist public "-//apple//dtd plist 1.0//en" ""><plist version="1.0"><dict><key></key><true/><key></key><true/><key></key><true/><key></key><true/><key></key><true/><key></key><true/><key></key><true/></dict></plist>


this may not be related. you can use lldb on macos instead of gdb. you don't need this hassle to install gdb.

lldb( is already installed by default in high sierra


for anyone who using sierra 10.12.6 (and above) and homebrew, /usr/local/bin/gdb is a symbolic link to /usr/local/cellar/gdb/8.0/bin/gdb (or whatever version, e.g. 8.0.1).

you need to codesign both link and target:

codesign -fs gdb-cert /usr/local/bin/gdb
codesign -fs gdb-cert "/usr/local/cellar/gdb/8.0/bin/gdb"

or, if you have greadlink (installed via brew install coreutils):

codesign -fs gdb-cert $(which gdb)
codesign -fs gdb-cert $(greadlink -f $(which gdb))


none of this worked for me and i had to go with a long run. here is a full list of steps i've done to get it working.

  1. create a certificate to sign the gdb.

unfortunately, system certificate gave me unknown error = -2,147,414,007 which is very helpful, so i had to go with a workaround. keychain access -> create certificate ->

pick login, gdb-cert, code signing

copy/move certificate to the system keychain (enter password)

  1. select certificate (gdb-cert) click get info -> trust always
  2. disable startup-with-shell

enter in console: set startup-with-shell off

remember configuration: echo "set startup-with-shell off" >>~/.gdbinit

  1. enable root user

go to system preferences -> users & groups -> unlock it -> login options -> network account server -> join -> unlock it -> edit (menu) -> enable root user

  1. sudo killall taskgated
  2. finally sign gdb

codesign -fs gdb-cert "$(which gdb)"

  1. disable root user (step 4)
  2. reboot if still does not work. (if nothing else works, most likely it works already)

ps. i ended up using lldb because it just works (tutorial)


i experienced the same issue with gdb. i am running under mac os x 10.8.5 aka mountain lion. i am using gdb version 7.7.1.

i compiled my test program with following command:

g++ -o gdb-sample.out -g gdb-sample.cpp    

if i entered the command gdb sample.out, i get the same cryptic error message:

"unable to find mach task port for process-id 46234: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))"

this error message however is a red herring.

the solution i found that worked for me was to simply invoke gdb using the superuser acct:

sudo gdb sample.out. 

that works fine for me.

and that from that point i could run gdb example.out without using sudo.

hope this helps and works for others. rsvp if it doesn't.


i made gdb work on osx 10.9 without codesigning this way (described here):

  1. install gdb with macports. (may be you can skip it)

  2. sudo nano /system/library/launchdaemons/

    change option string from -s to -sp at line 22, col 27.

  3. reboot the computer.

  4. use gdb. if you installed it with mac ports then you must use ggdb command. or made an alias in your config file:

alias gdb='ggdb'

and use 'gdb' command then.


i upgraded to gdb 8.3 and was not able to make things working. this helped me:

codesign --entitlements gdb.xml -fs gdb-cert /usr/local/bin/gdb

where content of gdb.xml is:

<?xml version="1.0" encoding="utf-8"?>
<!doctype plist public "-//apple//dtd plist 1.0//en"
<plist version="1.0">

i found this solution here:

note: without the entitlement i was able to run gdb only with sudo.


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 "$(which gdb)"


on macos 10.12 (sierra) and later, you must also

use gdb 7.12.1 or later additionally prevent gdb from using a shell to start the program to be debugged. you can use the following command for this inside gdb:

set startup-with-shell off

you can also put this last command in a file called .gdbinit in your home directory, in which case it will be applied automatically every time you start gdb

echo "set startup-with-shell off" >> ~/.gdbinit


Related Query

More Query from same tag