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

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 https://raw.githubusercontent.com/Homebrew/homebrew-core/c3128a5c335bd2fa75ffba9d721e9910134e4644/Formula/gdb.rb
    
  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 https://github.com/marcoparente and https://github.com/lokoum for their gist comments!

Tags:

Macos

Gdb