我知道 Go 团队不会很好地支持 GDB。但是,它似乎有时会起作用,所以在我放弃之前,我想看看它是否适用于这个程序。
我试图用它在 mac os x mavericks 中调试我的程序,不幸的是我无法在运行时检查我的程序。我正在使用 mac os x mavericks 10.9.4,我的 go 版本是 go version 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)