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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?