使用 GDB 进行调试
1. 核心转储文件查看
核心转储后,可能会看到类似如下内容:
# ls /corefiles
core.sort-debug.1431425613
更多信息可参考手册页 core(5) 。
2. 使用 GDB 查看核心文件
以下是一个使用 GDB 查看核心文件的示例会话:
$ arm-poky-linux-gnueabi-gdb sort-debug
/home/chris/rootfs/corefiles/core.sort-debug.1431425613
[...]
Core was generated by `./sort-debug'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000085c8 in addtree (p=0x0, w=0xbeac4c60 "the") at sort-debug.c:41
41 p->word = strdup (w);
这表明程序在第 41 行停止。使用 list 命令可查看附近代码:
(gdb) list
37 static struct tnode *addtree (struct tnode *p, char *w)
38 {
39 int
GDB调试:应用与内核代码调试全解析
超级会员免费看
订阅专栏 解锁全文
1298

被折叠的 条评论
为什么被折叠?



