我有一个 Go 程序,我正在使用 GDB(也是 Eclipse/Goclipse,但它使用 GDB,所以它们都是一样的)进行调试。有时,当我告诉 GDB next
时,它的行为就像我告诉它 continue
或 finish
一样。这就像可执行文件中缺少堆栈/框架/等信息。帮忙?
gdb -v
给出:
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.1.0". For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/.
go -v
给出:
go version go1.2.1 darwin/amd64
两者都在 OSX.9 下安装了 MacPorts
最佳答案
不仅仅是 OSX。 gdb 并不真正理解,也不能始终遵循 goroutine,因为它们可以跨操作系统线程进行调度。
稍后您始终可以尝试使用另一个断点再次捕获执行,但我认为您无能为力。
GDB 对于堆栈跟踪和断点仍然很有用,但在可预见的 future 单步执行代码不会可靠地工作。在 golang 开发邮件列表上已经讨论了关于不断改进 gdb 还是放弃它以支持新事物的问题;但尚未发布任何公告。
关于debugging - 使用 GDB 调试 Go 时的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24047959/