From 04b08da9af0c450d645ab7389d1467308cfc2db8 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg
When you compile and link your Go programs with the gc
toolchain
-on Linux, Mac OS X or FreeBSD, the resulting binaries contain DWARFv3
+on Linux, Mac OS X, FreeBSD or NetBSD, the resulting binaries contain DWARFv3
debugging information that recent versions (>7.1) of the GDB debugger can
use to inspect a live process or a core dump.
'-s'
flag to the linker to omit the debug information
(for example, go build -ldflags "-s" prog.go
).
+The code generated by the gc
compiler includes inlining of
+function invocations and registerization of variables. These optimizations
+can sometimes make debugging with gdb
harder. To disable them
+when debugging, pass the flags -gcflags "-N -l"
to the
+go
command used to build the code being
+debugged.
+
(gdb) list (gdb) list line (gdb) list file.go:line @@ -172,7 +179,7 @@ $ gdb regexp.test -d $GOROOT If for some reason GDB still can't find that directory or that script, you can load it by hand by telling gdb (assuming you have the go sources in~/go/
): -+
(gdb) source ~/go/src/pkg/runtime/runtime-gdb.py -- cgit v1.2.3