Skip to content

Instantly share code, notes, and snippets.

@adam-singer
Forked from Pallinder/.bash_profile
Created May 25, 2014 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adam-singer/8a18b8f1b5ac9ff64072 to your computer and use it in GitHub Desktop.
Save adam-singer/8a18b8f1b5ac9ff64072 to your computer and use it in GitHub Desktop.
alias gdbnew='/usr/local/Cellar/gdb/7.6/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. type `codesign -s name-of-certificate /path/to/new/gdb` in your console
8. type `sudo chgrp procmod /path/to/new/gbb` in your console
9. type `sudo chmod g+s /usr/local/bin/gdb` in your console
10. Pray to whatever god(s) you may or may not have.
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. Some people say a restart of the computer might help.
#### 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