Install GDB on OSX Yosemite

First things first – you need to install brew. It’s a homebrew package installer that can be found here. Then in your terminal, run

brew install gdb

This will install the latest gdb.

but, if you are show error like this “Error: No available formula for gdb”c

Homebrew does not provide gcc and the associated development tool formulas over concerns that custom/non-system compilers could break builds. Two possibilities for easiness:

This is probably the command for you:

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gdb.rb

Now, gdb is installed!

 

Or so it seems! The thing is that now you need to codesign your gdb installation. So go to Applications -> Utilities -> Keychain Access. In the menu up top go to Keychain Access -> Certificate Assistant -> Create a Certificate…. In the name just put gdb-cert, identity as self-signed root, and certificate type as Code Signing. Also tick the “override defaults” button.

Now you can choose how many days before the certificate expires. For simplicity’s sake, I just put 6666 days since I don’t ever want to do this again.

Now just keep clicking continue (like 6-7 clicks) until you get to “Specify a Location for the Certificate.” Make sure it’s on the System keychain!

Now when that wraps up, go to your Keychain Assistant once more. On the left menu go to your System keychain, right click on your gdb-cert and click Get Info. In the window that pops up there should be a menu called Trust. Just set it to always trust.

Finally we can sign GDB!

codesign -s gdb-cert [your-gdb-location]

I symlinked my gdb into my bin directory (/usr/local/bin/gdb) so I can access it from the terminal easily.

Now if you run gdb, you should get no more problems with gdb not being codesigned or what not.