duanlangwen9597 2013-11-02 18:51
浏览 75
已采纳

Golang:使用C库无法使gdb用于Go程序

Platform is Mac OSX Mavericks, I installed gdb from ports and signed it. For simple programs it works perfectly fine, but as soon as I try a program which uses a C library it fails to load symbols. For example if I try the FSAA example from the Go GLFW bindings I get the following output:

~/g/s/g/g/e/g/fsaa > ggdb main
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin13.0.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /Users/nils/gocode/src/github.com/go-gl/examples/glfw/fsaa/main...
warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/attriblocation.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/buffer.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/color.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/framebuffer.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/gl.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/matrix.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/object.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/program.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/renderbuffer.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/shader.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/texture.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/transformfeedback.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/uniformlocation.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/vertex.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/vertexarray.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/glu/_obj/_cgo_export.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/glu/_obj/callback.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/glu/_obj/callback.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/glu/_obj/glu.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/glu/_obj/tesselator.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build432883021/runtime/cgo/_obj/gcc_amd64.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build432883021/runtime/cgo/_obj/gcc_darwin_amd64.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build432883021/runtime/cgo/_obj/gcc_setenv.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build432883021/runtime/cgo/_obj/gcc_util.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build883630526/github.com/go-gl/glfw/_obj/_cgo_export.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build883630526/github.com/go-gl/glfw/_obj/callback.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build883630526/github.com/go-gl/glfw/_obj/callback.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build883630526/github.com/go-gl/glfw/_obj/glfw.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build883630526/github.com/go-gl/glfw/_obj/image.cgo2.o': can't open to read symbols: No such file or directory.
(no debugging symbols found)...done.
(gdb) list
No symbol table is loaded.  Use the "file" command.
(gdb) 

I got my go version from the trunk, go version says:

go version devel +f9af8b83c78c Fri Oct 25 23:00:22 2013 +0300 darwin/amd64

GDB version is 7.6. I don't want to step in the C libraries, I just want to debug my Go code. Any ideas?

  • 写回答

1条回答 默认 最新

  • dqt83336 2013-11-03 03:39
    关注

    You're experiencing issue 5221. A related question is this one.

    This problem has been partially fixed for ELF files but remains open for the Mach format which you are using. So I guess you have to wait for go 1.3 or the appropriate fix from tip to have this resolved.

    Basically the problem is that the linker you use for the compiled .c files does not extract the debug info from the object (.o) files but refers to them. As they're deleted after the build process, gdb can't read them.

    As a workaround, you might try to run go build -work for go-glfw so that the build directory is not removed and the object files remain accessible.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题