35 lines
700 B
Markdown
35 lines
700 B
Markdown
|
# GDB 远程调试 Golang
|
||
|
|
||
|
## Target
|
||
|
|
||
|
```bash
|
||
|
gdbserver :<port> <program name>
|
||
|
# 如 gdbserver :889 demo-go
|
||
|
```
|
||
|
|
||
|
## Host
|
||
|
|
||
|
```bash
|
||
|
arm-linux-gnueabihf-gdb
|
||
|
# 如: target remote 192.168.1.100:8899
|
||
|
(gdb) target remote <remote ip>:<remote port>
|
||
|
(gdb) set language go
|
||
|
# 如: file /host/path/to/demo-go
|
||
|
(gdb) file <debug targe file>
|
||
|
(gdb) b <file>:<line>
|
||
|
(gdb) b <package>.<function>
|
||
|
# 查看调用栈
|
||
|
(gdb) bt
|
||
|
# 切换调用栈
|
||
|
(gdb) f <n>
|
||
|
# 查看 goroutine
|
||
|
(gdb) info goroutines
|
||
|
(gdb) goroutines <n> bt
|
||
|
```
|
||
|
|
||
|
GDB 调试 Golang 无法查看 string、slice 等类型。
|
||
|
|
||
|
## 外部参考资料
|
||
|
|
||
|
1. [Golang 程序调试工具介绍(gdb vs dlv)](https://blog.csdn.net/dianfu2892/article/details/101466591)
|