GDB 调试技巧

GDB 调试参考文章:

https://www.wenjiangs.com/docs/100-gdb-tips

 

通过 core dump 文件定位:

解压:gunzip core_sig11_pid338_TSB_TEST.gz
启动:gdb TSB_TEST
gdb) 输入  core /data/core_sig11_pid338_TSB_TEST
gdb) 输入  bt
gdb) 输入  disassemble

 

用 bt/where 出现 ??? 情况

用GDB bt/where 调试出现 0x00007fa348d5c4e6 in ?? () 情况

1. 原因有可能是没找到符号表。

可以用 info share 查看信息:

1 (gdb) info share
2 From        To              Syms Read  Shared Object Library
3 0xb6f61270 0xb6f6fbac         No       /lib/libpthread.so.0
4 0xb6f47800 0xb6f4b074         No       /lib/librt.so.1
5 0xb6f3394c 0xb6f347f8         No       /lib/libdl.so.2
6 0xb6e5c3a0 0xb6f088ac         No       /lib/libstdc++.so.6

解决方法,cd到可执行文件目录下, 执行  “gdb -c core文件绝对路径” 按照上面步骤加载进入到 gdb 下。

进入gdb命令行, 执行 sharedlibrary 加载符号表,会看到很多done 之类的信息,再输入bt即能正确定位到错误点。

再用 info share 查看:

1 (gdb) info share
2 From       To             Syms Read  Shared Object Library
3 0xb6f61270 0xb6f6fbac      Yes (*)   /lib/libpthread.so.0
4 0xb6f47800 0xb6f4b074      Yes (*)   /lib/librt.so.1
5 0xb6f3394c 0xb6f347f8      Yes (*)   /lib/libdl.so.2
6 0xb6e5c3a0 0xb6f088ac      Yes (*)   /lib/libstdc++.so.6

 

2. 有可能是没有加 -g 打开带 symbol

 

posted @ 2022-01-18 15:21  西门吹雪~~~  阅读(146)  评论(0编辑  收藏  举报