1. debug by gdb:

office doc

download the runtime-gdb file.

$ wget -q -O - https://golang.org/src/runtime/runtime-gdb.py  |grep '<span id="L' >  runtime-gdb.py

处理脱字符

$ sed -i -e "s/<span.*span>//g" -e "s/<pre>//g" -e "s/^\t//g" -e 's/"/"/g' -e "s/'/'/g" -e "s/&gt;/>/g" -e "s/&lt;/</g" -e "s/amp;//g" runtime-gdb.py

linux 下应该有脱字符处理工具(iconv)。 或者wget 本身应该能处理掉脱字符。

run gdb by:

$GOROOT=`go env  |grep GOROOT |cut -d "=" -f2`

$ gdb your_bin -d $GOROOT

$ gdb cpuinfo_main -d `go env  |grep GOROOT |cut -d "=" -f2`

source ~/go/src/runtime/runtime-gdb.py

中文参考

发现最新的golang1.6已经自带了runtime-gdb.py

进入gdb

(gdb) add-auto-load-safe-path /usr/local/go/src/runtime/runtime-gdb.py

echo "set auto-load safe-path /" > line to your configuration file "/home/shaohef//.gdbinit".

直接运行

$ gdb your_bin

2. godebug

http://studygolang.com/articles/2899

Download:

$ go get -u github.com/mailgun/godebug

将 _ = "breakpoint" 插入代码。

 package main

 import (
"fmt"
) func main() {
_ = "breakpoint"
fmt.Print("**********************\n")
}

build godbug

$ go build

mv  godbug to goroot bin

$ sudo cp godebug /usr/local/go/bin/

$ debug

godbug run your go_file.

3.  Go语言debug调试

http://studygolang.com/articles/2057

4. 采用idea IDE环境。

http://www.cnblogs.com/lingdhox/p/4189517.html

5. 使用Delve进行Golang代码的调试

http://www.qingpingshan.com/jb/go/111271.html

$ dlv  exec  ./sample-controller -- -kubeconfig=$HOME/.kube/config

使用Delve调试test case

dlv test --build-flags='github.com/dlsniper/u/tmp/mypack' -- -test.run ^TestHello$

https://github.com/derekparker/delve/issues/422

6. 代码中打印栈信息

 package main

 import (
"fmt"
"runtime/debug"
) func test1() {
test2()
} func test2() {
test3()
} func test3() {
fmt.Printf("%s", debug.Stack())
debug.PrintStack()
} func main() {
test1()
}

golang debug调试的更多相关文章

  1. golang debug with LiteIDE

    golang 的调试比较麻烦,debug stop into 无法跳转到自己写的代码,但是能够跳转到系统提供的代码. 以下是简单的测试代码: package main import ( "f ...

  2. 远程debug调试java代码

    远程debug调试java代码 日常环境和预发环境遇到问题时,可以用远程调试的方法本地打断点,在本地调试.生产环境由于网络隔离和系统稳定性考虑,不能进行远程代码调试. 整体过程是通过修改远程服务JAV ...

  3. u-boot 2011.09 开启debug 调试

    以前做过,现在刚才又想不起来了,这个错误非常的严重. 在这里记一下. debug 调试信息的开启在 include/common.h 有如下宏定义: #ifdef DEBUG #define debu ...

  4. 使用Eclipse开发Java Web过程中Debug调试的使用方法

    里介绍的是在Eclipse中的Debug调试. 首先右击项目选择Debug As -- Debug on Server 或者点击Server面板的小昆虫图标,启动Debug模式. 运行web项目,进行 ...

  5. eclipse debug (调试) 学习心得

    eclipse debug (调试) 学习心得   进入debug模式:   1.设置断点   2.启动servers端的debug模式   3.运行程序,在后台遇到断点时,进入debug调试状态   ...

  6. Eclipse debug调试

    Eclipse debug调试: F5:跳入方法F6:向下逐行调试F7:跳出方法F8:直接跳转到下一个断点

  7. (转) eclipse debug (调试) 学习心得

    1.Step Into (also F5) 跳入2.Step Over (also F6) 跳过3.Step Return (also F7) 执行完当前method,然后return跳出此metho ...

  8. Android Studio的使用(二)--Debug调试

    使用Android Studio进行Debug调试,这里有一篇比较详细的介绍 http://www.2cto.com/kf/201506/408358.html 故不再重复介绍.

  9. Eclipse中debug调试java代码一直报Source not found的解决办法

    今天使用eclipse的debug调试代码,一直没法正常调试,一按F6就提示Source not found 根据提示发现可能是另一个项目影响了,所以把另一个项目Close Project,这次直接t ...

随机推荐

  1. 微软、谷歌、亚马逊、Facebook等硅谷大厂91个开源软件盘点(附下载地址)

    开源软件中有大量专家构建的代码,大大节省了开发人员的时间和成本,热衷于开源的大厂们总是能够带给我们新的惊喜.2016年9月GitHub报告显示,GitHub已经有超过 520 万的用户和超 30 万的 ...

  2. 反正切函数atan与atan2的区别

    atan 和 atan2 都是求反正切函数,如:有两个点 point(x1,y1), 和 point(x2,y2); 那么这两个点形成的斜率的角度计算方法分别是: float angle = atan ...

  3. POJ 2653 - Pick-up sticks - [枚举+判断线段相交]

    题目链接:http://poj.org/problem?id=2653 Time Limit: 3000MS Memory Limit: 65536K Description Stan has n s ...

  4. php iconv() : Detected an illegal character in input string

    php iconv() : Detected an illegal character in input string_php技巧_脚本之家 https://www.jb51.net/article/ ...

  5. Assign the task---hdu3974(线段树优化+dfs)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3974 题意就是:公司有n个员工,关系有n-1个,T x y 代表把工作y交给员工x: 员工可以把工作交 ...

  6. MySQL事务隔离级别详解(转)

    原文: http://xm-king.iteye.com/blog/770721 SQL标准对事务定义了4种隔离级别,包括了一些具体规则,用来限定事务内外的哪些改变是可见的,哪些是不可见的.低级别的隔 ...

  7. html中载入自执行getElementById("xx")得到null

    <!DOCTYPE HTML> <html> <head> <title>Scope Chain & Closure Example </ ...

  8. centos7 设置 静态IP

    centos7 图形设置 yum install NetworkManager-tui #centos7 nmtui edit eth0 #图形设置ip systemctl restart netwo ...

  9. kmeans聚类源代码

    代码是在weka上二次开发的,但没有使用原来的kmeans代码,只是用了它的数据类Intances,先说下与它相关的几点东西. 一.KMeans算法简介 输入:聚类个数k,以及包含 n个数据对象的数据 ...

  10. 第三章基本的SQl查询语言

    ---恢复内容开始--- ---恢复内容结束---