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. linux:正则表达式grep命令

    基本语法一个正则表达式通常被称为一个模式(pattern),为用来描述或者匹配一系列符合某个句法规则的字符串. 一.选择:| |   竖直分隔符表示选择,例如"boy|girl"可 ...

  2. TensorFlow基础1:reduce_sum()函数和reduce_mean()函数

    https://blog.csdn.net/chengshuhao1991/article/details/78545723 在计算损失时,通常会用到reduce_sum()函数来进行求和,但是在使用 ...

  3. [python-opencv]超大图像二值化方法

    *分块 *全局阈值 VS 局部阈值 import cv2 as cv import numpy as np def big_image_binary(image): print(image.shape ...

  4. Web Responsive Table, 只需CSS使table在手机和平板中完美显示

    在做responsive或者手机版页面的时候,经常碰到<Table>在手机和平板中会因为长度问题把页面撑大.最近看到一个比较好,比较方便的方法,而且仅仅用CSS 2就可以实现! 实例URL ...

  5. python 基础 字典

    字典操作 字典一种key - value 的数据类型 特性: 无顺序 去重 查询速度快,比列表快多了 比list占用内存多 语法: info = { 'abc001': "Ben" ...

  6. [LeetCode] 690. Employee Importance_Easy tag: BFS

    You are given a data structure of employee information, which includes the employee's unique id, his ...

  7. unity3d-小案例之角色简单漫游

    准备资源 我这里从网上下载一个角色模型,里面有一组动画.有站立.奔跑.杀怪等 我们来实现角色的前后左后移动,即键盘上的WSDA键,这里因为没有行走的动画.索性就用奔跑代替了!! 暂时先不计较代码冗余的 ...

  8. mysql主从延迟(摘自http://www.linuxidc.com/Linux/2012-02/53995.htm)

    http://www.linuxidc.com/Linux/2012-02/53995.htm

  9. Filter—过滤器和拦截器的区别

    1.首先要明确什么是拦截器.什么是过滤器 1.1 什么是拦截器: 拦截器,在AOP(Aspect-Oriented Programming)中用于在某个方法或字段被访问之前,进行拦截然后在之前或之后加 ...

  10. UVM环境(一)

    1)如何避免绝对路径的出现:绝对路径一般都是用在信号的连接关系上,这样可以用virtual interface,来通过句柄的赋值来动态的建立连接关系.那么顶层模块怎么 样将interface的句柄赋值 ...