When compiling the Go Language program, pass the-gcflags "-n-l" parameter, which can ignore some optimizations made inside the go language, such as aggregation variables and functions.
Go build-gcflags "-n-l"
Common commands
- List
Displays the source code, the default display 10 lines, for example list 15, displays 10 lines of code, where the 15th line in the display of 10 lines inside the middle
- Break
Set breakpoints, followed by code line numbers or function names
- Delete
Delete breakpoint, followed by the sequence number of the breakpoint, this sequence number can be obtained through the info breakpoints the corresponding set breakpoint number
- BackTrace
Shorthand command BT, used to print the executed code procedure
Info
Used to display information
Info locals used to display the values of variables in the currently executing program
Info breakpoints Displays a list of currently set breakpoints
Info Goroutines Displays the list of currently executed Goroutine
Print
Print variables or other information, followed by the name of the variable you want to print,
Whatis
Used to display the type of the current variable followed by the variable name
Next
Skip to Next step
Continue
Used to jump out of the current breakpoint, continue execution, followed by parameter n, skipping the last breakpoint
- Set Variable
Used to change the value of variables during operation
Go Language-gdb Debug