10 May 2015
Some of the fancy features Go adds to GDB require GDB >= 7.1. You can check which version you have with `gdb -v`. If it's high enough, skip to the next section. If not, do the following:
1) Follow these instructions: http://www.opensource.apple.com/source/lldb/lldb-69/docs/code-signing.txt. The name doesn't matter really, but gdb_codesign is as good a choice as any.
2) `brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gdb.rb`.
3) `codesign -s gdb_codesign $(which gdb)`
You don't really have to do anything special, but if you compile with `-gcflags "-N -l"`, the compiler will omit some optimizations that can make debugging more difficult. Eg:
$ go build -gcflags "-N -l" main.go
There's a bug on OS X that prevents the custom gdb extensions from loading automatically, so you have to source them manually when you start up the debugger. You can put the source wherever you want, but I'll assume you're putting it at ~/src/go:
mkdir ~/src ; cd ~/src ; hg clone -u tip https://code.google.com/p/go
1) Start the debugger. `gdb ./my_app`
2) Load the extra runtime support: `source ~/src/go/src/pkg/runtime/runtime-gdb.py`
3) Debug. See http://golang.org/doc/gdb