猿问

Golang:无法让 gdb 为使用 C 库的 Go 程序工作

平台是 Mac OSX Mavericks,我从端口安装了 gdb 并对其进行了签名。对于简单的程序,它工作得很好,但是一旦我尝试使用 C 库的程序,它就无法加载符号。例如,如果我尝试 Go GLFW 绑定中的 FSAA 示例,我会得到以下输出:


~/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.


我从后备箱得到了我的 go 版本,go version说:


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

GDB 版本是 7.6。我不想涉足 C 库,我只想调试我的 Go 代码。有任何想法吗?


慕妹3146593
浏览 269回答 1
1回答

扬帆大鱼

您遇到了问题 5221。一个相关的问题是这个。对于 ELF 文件,此问题已部分修复,但对于您正在使用的 Mach 格式仍保持打开状态。所以我想你必须等待 go 1.3 或来自提示的适当修复才能解决这个问题。基本上问题在于您用于编译.c文件的链接器不会从对象 (&nbsp;.o) 文件中提取调试信息,而是引用它们。由于它们在构建过程后被删除,gdb 无法读取它们。作为一种解决方法,您可以尝试运行go build -workforgo-glfw以便不删除构建目录并且目标文件仍可访问。
随时随地看视频慕课网APP

相关分类

Go
我要回答