How do I install GDB on MacOS 10.13.3 (High Sierra)


Question or issue on macOS:

There are tons and tons of post and blogs discussing this topic, but nothing seems to work…

From across the internet, here is the common consensus regarding the procedure required to install and run gdb.

After completing all the steps, when I attempt to debug a simple “hello world” program, I get the following startup error resulting from SIGTRAP being throw.

(gdb) start
Temporary breakpoint 1 at 0x100000e66: file test.cpp, line 5.
Starting program: /Users/zfields/Documents/Development/test/a.out
[New Thread 0x1703 of process 67971]
[New Thread 0x1903 of process 67971]
During startup program terminated with signal SIGTRAP, Trace/breakpoint trap.

What am I missing?

How to solve this problem?

Solution no. 1:

After hours and hours of searching, I finally found an obscure gist identifying the issue and detailing the solution.

TL;DR The GNU Debugger requires a patch before it can work with MacOS. gdb v8.0.1 is the last known good version of GDB for MacOS.

  1. Uninstall the latest version of gdb (i.e. v8.1)

    brew uninstall --force gdb 
  2. Force Homebrew to install a version of gdb with the patch for MacOS.

    brew install 
  3. Use the existing certificate to codesign the new install of gdb

    codesign -f -s "<GNU GDB Certificate>" $(which gdb) 

Now, gdb works as expected!

Special thanks to and for their gist comments!

Solution no. 2:

I got gdb working on Mojave yesterday by:

a) getting the latest gdb source archive (at time of writing,

b) build gdb. I got errors for variable shadowing in darwin-nat.c so I edited the file and rebuilt.

c) follow steps in


(source: GDB on Mac/Mojave: During startup program terminated with signal ?, Unknown signal)

Solution no. 3:

Maybe a bit of unrelated:

Mac OS Sierra 10.13.6
gdb 8.0.1

had the same error as topic-starter.

I discovered that I already had gdbcert1 in my System.
Followed everything from 7.

Hope this helps!