GDB Debugging Go program Some problems memo

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

1. Earlier wrote the GDB debugging simple Go program article, did not have the command line parameter, recently looked an open source project to need to use with the command line parameter debugging.
As follows:
View Help gets as follows:

GDB [Options]--args executable-file [inferior-arguments ...]

For example:

GDB--args Revel Run Github.com/yourihua/console

2. Load into Go Runtime:

source/home/yourihua/go/src/pkg/runtime/runtime-gdb.py

Or, in the Add File ~/.gdbinit, the contents are as follows:

Add-auto-load-safe-path ~/go/src/pkg/runtime/

The reasons are as follows: http://grokbase.com/t/gg/golang-nuts/12atrp2jwf/ go-nuts-debugging-warning-when-loading-a-binary-runtime-gdb-py-auto-loading-has-been-declined

3. If you need to hit a breakpoint on a non-main package, the following prompt will appear when using B Package.func:
Make breakpoint pending on the future shared library load? (Y or [n])
Only b filename:line is used at this time, and the full path is required, for example:

(GDB) B/home/yourihua/workplace/rhino/src/github.com/robfig/revel/revel.go:81breakpoint 1 at 0x44eeaf:file/home/ Yourihua/workplace/rhino/src/github.com/robfig/revel/revel.go, line 81.

To avoid entering the full path each time, you can add a search path using Dir, as follows:

(gdb) dir/home/yourihua/workplace/rhino/src/github.com/robfig/revel/source directories searched:/home/yourihua/ Workplace/rhino/src/github.com/robfig/revel: $cdir: $CWD (gdb) b revel.go:86breakpoint 2 at 0x44ef60:file/home/ Yourihua/workplace/rhino/src/github.com/robfig/revel/revel.go, line 86.

4. Good article: Introduction to Go Debugging with GDB, address: http://lincolnloop.com/blog/2012/oct/3/introduction-go-debugging-gdb/

5. When you close gdb, you find that the application is not exited:

A. Finding the occupied port
Netstat-tln
Netstat-tln | grep 8060
NETSTAT-TLN View port usage, while Netstat-tln | grep 8060 is a view of the usage of port 8060 only
B. See which program the port belongs to? Which process is consuming the port
lsof-i:8060

yourihua@ubuntu:~$ lsof-i:9000command PID USER FD TYPE DEVICE size/off NODE namerevel 24739 yourihua 8u IPv6 576421 0t0 T CP *:9000 (LISTEN) yourihua@ubuntu:~$

C. Kill the port-taking process according to the PID
Kill-9 Process ID
Kill-9 24739

Finally, thank Yuhen for his enthusiastic help.

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.