Skip to content

Instantly share code, notes, and snippets.

@icholy
Created June 3, 2013 20:29
Show Gist options
  • Save icholy/5701120 to your computer and use it in GitHub Desktop.
Save icholy/5701120 to your computer and use it in GitHub Desktop.
gdbb () {
# build with debug flags
go build -gcflags "-N -l" -o out
# make sure the build didn't fail
if [ $? != 0 ]; then return; fi
# extract debugger comments
gdbb-extract "*.go" > .breakpoints
# break on main if no breakpoints were found
if [ ! -s .breakpoints ]; then echo "break main.main" > .breakpoints; fi
# launch gdb
gdb -x .breakpoints -ex run --args out "$@"
# clean up
rm .breakpoints out
}
# test
gdbbtest () {
# build with debug flags
go test -c -gcflags "-N -l" "$@"
# make sure the build didn't fail
if [ $? != 0 ]; then return; fi
# extract debugger comments
gdbb-extract "*.go" > .breakpoints
# if breakpoints were found, run on start
if [ -s .breakpoints ]; then
gdb -x .breakpoints -ex run *.test
else
gdb *.test
fi
# clean up
rm .breakpoints *.test
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment