From e8914930a3f86bb13f6073a04dfb40d8117ef926 Mon Sep 17 00:00:00 2001 From: "chen.yang" Date: Tue, 2 Nov 2021 23:58:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20GDB=20=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E8=B0=83=E8=AF=95=20Golang.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chen.yang --- Software/Applications/GDB/GDB_的使用.md | 13 +++++-- .../Language/Go/Debug/GDB_远程调试_Golang.md | 34 +++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 Software/Development/Language/Go/Debug/GDB_远程调试_Golang.md diff --git a/Software/Applications/GDB/GDB_的使用.md b/Software/Applications/GDB/GDB_的使用.md index b9f9194..41e9338 100644 --- a/Software/Applications/GDB/GDB_的使用.md +++ b/Software/Applications/GDB/GDB_的使用.md @@ -3,11 +3,17 @@ ## 1.基本指令 ```bash +# 设置调试目标文件(解决找不到符号或找不到文件问题) +(gdb) file # 开启/关闭伪图形窗口 (gdb) tui enable/disable +# 设置参数 +(gdb) r ... # 查看各级函数调用及参数 (gdb) backtrace (gdb) bt +# 切换调用栈 +(gdb) f # 退出 gdb 调试环境 (gdb) quit (gdb) q @@ -22,14 +28,17 @@ # 删除断点 (gdb) delete [breakpoints num] [range...] (gdb) d [breakpoints num] [range...] +# 查看断点信息(breakpoints num) +(gdb) info breakpoints +(gdb) info b +# 禁用断点 +(gdb) dis # 清除全部断点 (gdb) clear # 删除所选定的环境中所有的断点 (gdb) clear ``` -可通过 info breakpoints 获取 breakpoints num 等断点信息。 - ## 3.执行控制 ```bash diff --git a/Software/Development/Language/Go/Debug/GDB_远程调试_Golang.md b/Software/Development/Language/Go/Debug/GDB_远程调试_Golang.md new file mode 100644 index 0000000..877b32f --- /dev/null +++ b/Software/Development/Language/Go/Debug/GDB_远程调试_Golang.md @@ -0,0 +1,34 @@ +# GDB 远程调试 Golang + +## Target + +```bash +gdbserver : +# 如 gdbserver :889 demo-go +``` + +## Host + +```bash +arm-linux-gnueabihf-gdb +# 如: target remote 192.168.1.100:8899 +(gdb) target remote : +(gdb) set language go +# 如: file /host/path/to/demo-go +(gdb) file +(gdb) b : +(gdb) b . +# 查看调用栈 +(gdb) bt +# 切换调用栈 +(gdb) f +# 查看 goroutine +(gdb) info goroutines +(gdb) goroutines bt +``` + +GDB 调试 Golang 无法查看 string、slice 等类型。 + +## 外部参考资料 + +1. [Golang 程序调试工具介绍(gdb vs dlv)](https://blog.csdn.net/dianfu2892/article/details/101466591)