Golang language, learning for a long time, has been that it has more than one-step debugging problems, only recently know that they know too little about it.
The original go language to GDB version is at least gdb7, in order to better print any variable, if below this version, there will be some problems.
The web says GDB version is 7.1, I use GDB7.8 version test, indeed very good. Here are a few of the print variables used to record one-step debugging.
Info frame, which prints the current stack parameters.
Info Locals print local variables
Info args print parameters.
BT displays the current stack
X/3xw &r View Memory
Remove debug Symbols: Go build-ldflags "-s-w" Filename.go
-S: Removes symbolic information.
-W: Removes dwarf debug information.
Close inline optimization: Go build-gcflags "-n-l" Filename.go
—————–
When using native GDB debugging in centos6.6, the following features are found.
1. Using the list command directly, you will enter a state as follows.
(gdb) l
/usr/local/go/src/runtime/rt0_linux_amd64.s: No such file or directory.
in /usr/local/go/src/runtime/rt0_linux_amd64.s
2. You can use the L Main.main command to navigate to the main function.
(gdb) l main.main
warning: Source file is more recent than executable.
4
5type point struct {
6x, y int
7}
8
9func main() {
10i:=32
11p := point{1, 2}
12f := 3.3434
13txt := "sdfsdfdsfsfds"
http://www.kxtry.com/archives/737
GDB Debugging for Go