使用gdb进行Golang调试无法打开以读取符号?

I debug my code referencing Debugging Go Code

But when I run gdb xxx.test, I get a list Warning:

Reading symbols from markdown.test...
warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build765783040/runtime/cgo/_obj/gcc_amd64.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build765783040/runtime/cgo/_obj/gcc_darwin_amd64.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build765783040/runtime/cgo/_obj/gcc_setenv.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build765783040/runtime/cgo/_obj/gcc_util.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rn/ff65_68n0kg4_ml_v420yg5m0000gn/T/go-build619623895/github.com/glenn-brown/golang-pkg-pcre/src/pkg/pcre/_obj/pcre.cgo2.o': can't open to read symbols: No such file or directory.
(no debugging symbols found)...done.

Using go test -c -work instead of go test -c

warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build765783040/runtime/cgo/_obj/gcc_amd64.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build765783040/runtime/cgo/_obj/gcc_darwin_amd64.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build765783040/runtime/cgo/_obj/gcc_setenv.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build765783040/runtime/cgo/_obj/gcc_util.o': can't open to read symbols: No such file or directory.

source /usr/local/go/src/runtime/runtime-gdb.py within gdb

Loading Go Runtime support.
Traceback (most recent call last):
  File "/usr/local/go/src/runtime/runtime-gdb.py", line 205, in <module>
    _rctp_type = gdb.lookup_type("struct runtime.rtype").pointer()
gdb.error: No struct type named runtime.rtype.

After editing runtime-gdb.py

line 205: `#_rctp_type = gdb.lookup_type("struct runtime._type").pointer()`
line 216: `return go_type_ptr.cast(gdb.lookup_type("struct reflect.rtype").pointer()).dereference()`

source runtime-gdb.py within gdb

(gdb) source /usr/local/go/src/runtime/runtime-gdb.py
Loading Go Runtime support.

And then I cannot do next step.Is anyone know how to fix it?

  • go version go1.4.2 darwin/amd64
  • GDB:7.9 (using homebrew to install)
  • OS:Mac OS X 10.10.3
douzhenqun1271
douzhenqun1271 ,谢谢!在Ubuntu中引用官方文档效果很好。但仍然不能在OSX中使用。
5 年多之前 回复
dtlh12053
dtlh12053 抱歉,我没有真正阅读您提供的链接,并认为这与调试测试有关(我很糟糕!)。但是他们将测试可执行文件作为示例,而无需使用-work。您是否做了gdbxxx.test-d$GOROOT(设置了GOROOT,或用$(goenvGOROOT)代替了)?如果前一个失败,您是否尝试从gdb中采购runtime-gdb.py?我不使用OSX,所以除了这些无用的建议,我无所不能。抱歉。:(
5 年多之前 回复
dopii22884
dopii22884 ,当我运行gotest-c-work时,命令行输出WORK=/var/folders/rn/ff65_68n0kg4_ml_v420yg5m0000gn/T/go-build702663380。而且/var/folders中没有00。它仍然失败
5 年多之前 回复
dongzhi2332
dongzhi2332 gotest-c生成dirname.test,但丢弃它标记并用于构建测试可执行文件的临时源。也许像gotest-c-work之类的东西可能会做您想要的,但是,这取决于您在完成后删除该临时工作目录。
5 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问