我知道go团队不会很好地支持GDB。然而,在我放弃之前它似乎有时会起作用我想看看它是否适用于这个程序。
我试图用它在mac os x mavericks中调试我的程序,但我不能在运行时检查我的程序。我使用的是mac os x mavericks 10.9.4,我的go版本是go版本的go1.2.2 darwin / amd64。
如果我在我的二进制文件上gdb my_binary
然后尝试运行它,会发生什么:
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from hydra...
warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build728316890/crypto/x509/_obj/root_darwin.cgo2.o': can't open to read symbols: No such file or directory.
warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build728316890/net/_obj/cgo_unix.cgo2.o': can't open to read symbols: No such file or directory.
warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build728316890/runtime/cgo/_obj/gcc_amd64.o': can't open to read symbols: No such file or directory.
warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build728316890/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-build728316890/runtime/cgo/_obj/gcc_setenv.o': can't open to read symbols: No such file or directory.
warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build728316890/runtime/cgo/_obj/gcc_util.o': can't open to read symbols: No such file or directory.
warning: `/var/folders/m9/3tx5tfkx02z9jkwdz0lkg85cj4gbmq/T/go-build297950324/github.com/alecthomas/gozmq/_obj/zmq.cgo2.o': can't open to read symbols: No such file or directory.
warning: `/var/folders/m9/3tx5tfkx02z9jkwdz0lkg85cj4gbmq/T/go-build297950324/github.com/alecthomas/gozmq/_obj/zmq_3_x.cgo2.o': can't open to read symbols: No such file or directory.
(no debugging symbols found)...done.
我想关注的是最后一行:
(no debugging symbols found)...done.
我是否错误地编译了我的go程序?是否有任何标志可以使这项工作?
我只做了go build my_program
,但似乎某些旗帜或其他东西可能会起作用?
我已经能够使gdb在非常简单的程序上工作,但是在这个更大的程序上它会失败并抛出上述错误。有人知道为什么会这样吗?有人能够使它适用于包含大量库和包等的大型程序吗?
我知道它可能不起作用,但我想通过询问社区来试一试。
(如果有的话,我也愿意使用不同的调试器。)
(我也遇到了与cgdb相同的问题)。
(我也开放使用任何其他调试器,它允许我查看变量,断点和基本功能的值,也许还可以探索go-routines将是非常棒的。当然,对于mac来说)
答案 0 :(得分:0)
GDB告诉你它认为可能找到调试符号的文件和目录不在那里。从名称来看,这些是Go的临时工作目录。
命令行选项-work
到go build
的描述如下:
打印临时工作目录的名称和 退出时不要删除它。
所以这可能会有效,但需要定期手动清理。