Skip to content

Instantly share code, notes, and snippets.

@tcz001
Forked from subh007/.bash_profile
Last active August 29, 2015 14:23
Show Gist options
  • Save tcz001/17a1b80c5d3a9c79325f to your computer and use it in GitHub Desktop.
Save tcz001/17a1b80c5d3a9c79325f to your computer and use it in GitHub Desktop.
setup golang debug
alias gdbnew='/usr/local/Cellar/gdb/7.9.1/bin/gdb'
define g
python
import subprocess as p
cmd = ["go", "env", "GOROOT"]
gdb_cmd = "source %s/src/pkg/runtime/runtime-gdb.py" % p.check_output(cmd)[:-1]
gdb.execute(gdb_cmd)
#### Install a new version of gdb (the one that comes with mac os x is too old)
1. Install and get brew
2. brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gdb.rb
3. Add an alias so it's easier to run, I named it gdbnew (check the .bash_profile file attached for an example)
#### Deal with signing gdb (you can skip this if you feel like running the debug process like root)
1. Start keychain access
2. Keychain access -> Certificate assistance -> Create a certificate
3. Name it whatever you like (I choose gdb)
4. Certificate type should be code signing
5. Check "let me override defaults"
6. Just click continue until you reach the point to select Keychain, select the System keychain
7. Trust your self signed Certificate on "get info".
8. type `codesign -s name-of-certificate /path/to/new/gdb` in your console (e.g. /usr/local/bin/gdb)
9. type `sudo chgrp procmod /path/to/new/gdb` in your console
10. type `sudo chmod g+s /usr/local/bin/gdb` in your console
11. Confirm that it works by trying to run the new gdb with a compiled golang binary. (newgdb path-to-binary) if an error similar to `codesign -s gdb-cert /usr/local/bin/gdb /usr/local/bin/gdb: is already signed but it still gives me the error message Unable to find Mach task port for process-id 838: (os/kern) failure (0x5)` pops up, it didnt work.
12. If it doesn't work then quit the keychain, it is important. Kill the taskgated process and restart it. It will reload the newly created certificate. (Ref : http://wiki.lazarus.freepascal.org/GDB_on_OS_X_Mavericks_and_Xcode_5 http://apple.stackexchange.com/questions/116707/how-do-i-start-taskgated-again).
#### Make sure gdb loads the golang scripts
1. Put the the attacked .gdbinit in your homedirectory
2. Launch the new gdb you can now enable the golang specific commands by typing "g" (without the quotes) in gdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment