简体   繁体   中英

Golang: Cannot get gdb working for Go programs using C libraries

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM