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. 怎么点击div之外的区域就隐藏这个div啊 找了很久,都没有很好解决

    方法一. <!DOCTYPE html><html><head><meta http-equiv="Content-Type" conte ...

  2. Arrow-一个最好用的日期时间Python处理库

    https://www.jianshu.com/p/c878bb1c48c1 写过Python程序的人大都知道,Python日期和时间的处理非常繁琐和麻烦,主要有以下几个问题: 有众多的package ...

  3. Distribution(F题)---第八届河南省程序设计大赛

    Description One day , Wang and Dong in the Dubai desert expedition, discovered an ancient castle. Fo ...

  4. 聊一聊Linux中的工作队列

    2018-01-18 工作队列是Linux内核中把工作延迟执行的一种手段,其目的不同于软中断,软中断是提高CPU的响应,尽可能的缩短关中断的时间:而工作队列主要目的是节省资源,其比较适合很微小的任务, ...

  5. RSA加密常用的填充方式 以及 常见错误

    一.RSA加密常用的填充方式 1.RSA_PKCS1_PADDING 输入:比 RSA modulus 短至少11个字节.如果输入的明文过长,必须切割,然后填充 输出:和modulus一样长 根据这个 ...

  6. socke+epoll

    读: #define V5CLI_READ_MSG_LEN 1024 char readMsg[V5CLI_READ_MSG_LEN]; ; ; )) > ){ n += nread; }//读 ...

  7. Prometheus+Grafana+Altermanager搭建监控系统

    基本概念 Prometheus 时间序列化数据库,我的理解就是将数据打上标签,以时间维度存储.后面有机会在深入研究. Prometheus架构如下: Grafana Prometheus中存储的数据, ...

  8. python3中替换python2中cmp函数

    python 3.4.3 的版本中已经没有cmp函数,被operator模块代替,在交互模式下使用时,需要导入模块. 在没有导入模块情况下,会出现 提示找不到cmp函数了,那么在python3中该如何 ...

  9. cocos代码研究(7)即时动作子类学习笔记

    理论部分 即时动作是会立即被执行的动作.他们没有持续时间动作(ActionInterval)的持续时间属性.继承自 FiniteTimeAction.被 CallFunc, FlipX, FlipY, ...

  10. discuz模板引擎

    discuz是采用“编译型的模板”,就是指采用普通网页文件保存,在文件中插入需要动态显示数据的仿php的代码,最后进行编译成真正的php的文件保存为模板缓存文件,这个转换的过程就称为编译.在用户浏览页 ...