Install GDB in macOS Sierra

I found that there was no GDB pre-installed inside the macOS (was called OSX) since very long time ago. So this article is talking about how to install GDB in macOS Sierra.

macOS Sierra


First, you need to install homebrew

Then, install gdb by typing

brew install gdb


sudo brew install gdb

But if you are using gdb right now to debug your code, you will find that the terminal will tell you:

Error message from debugger back end: Unable to find Mach task port for processid 46234: (os/kern) failure (0x5). (please check gdb is codesigned see taskgated(8)

That is because you haven’t code-sign your own installed gdb yet, so here are two ways to do it.


  1. Code-sign your own gdb.
  2. Let superuser do the job, so it will jump through this certification.

For the solution two, just type:

sudo gdb

and it will solve your problem.


Also, you can edit your bash profile or zsh profile to add the alias

alias gdb=”sudo gdb”

then there is no need to type sudo every time, but if you want it to be safe, you can do type sudo every time.


  1. I was pretty pleased to uncover this web site. I wanted to thank
    you for your time for this particularly wonderful read!!
    I definitely loved every bit of it and i also have you book-marked
    to check out new stuff in your website.

  2. Jie Chen

    When I run the program in GDB, I have the following output :

    During startup program terminated with signal ?, Unknown signal.

    What does it mean? Thanks.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.