GDB Debugging for Go

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.