我一直在尝试使用gdb
或cgdb
在主机操作系统(ubuntu 14.04 操作系统)上运行的 Ubuntu 14.04 容器上调试并进入 docker 守护程序代码。我-O0 -g
在容器中构建调试二进制文件时使用了标志。
容器中使用的 go 版本:
# go version
go version go1.4.3 linux/amd64
我无法使用以下代码单步执行代码cgdb
:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"... Reading symbols from bundles/1.9.0-dev/dynbinary/docker...done. (
gdb) b main.handleGlobalDaemonFlag
Breakpoint 1 at 0x497b30
(gdb) r daemon -D
Starting program: /go/src/github.com/docker/docker/bundles/1.9.0-dev/dynbinary/docker daemon -D
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff5a00700 (LWP 2775)]
[New Thread 0x7ffff51ff700 (LWP 2776)]
[New Thread 0x7ffff49fe700 (LWP 2777)]
Breakpoint 1, 0x0000000000497b30 in main.handleGlobalDaemonFlag ()
(gdb) n Single stepping until exit from function main.handleGlobalDaemonFlag, which has no line number information.
Breakpoint 1, 0x0000000000497b30 in main.handleGlobalDaemonFlag ()
(gdb) l 1 in /tmp/go-build212795923/github.com/docker/docker/pkg/term/_obj/_cgo_export.c
(gdb)
如何确认构建的二进制文件是调试的?我可以使用工具readelf
阅读标题以确认这一点吗?
我应该将 GOPATH 或 GOROOT 设置为特定目录吗?
root@6511af5b06c1:/go/src/github.com/docker/docker# echo $GOROOT
root@6511af5b06c1:/go/src/github.com/docker/docker# echo $GOPATH
/go:/go/src/github.com/docker/docker/vendor
我的环境中是否还有其他依赖项可能缺少?