GDB源码移动后如何调试以及几种解决方法

发生core dump之后, 用gdb进行查看core文件的内容, 以定位文件中引发core dump的行.   gdb [exec file] [ core file]

gdb之所以能够知道对应的源代码,是因为调试版的可执行程序中记录了源代码的位置;

 

因为源代码的位置在编译之后可能会移动到其它地方

 

所以gdb还会在当前目录中查找源代码

 

另外gdb也允许明确指定源代码的搜索位置

  1. gdb允许明确指定源代码位置,以应付源代码位置迁移的情况
  • directory path-list(dir /home/fdj/src/Sources/fsc/tools/test_lni):将一个或者多个源代码搜索目录加入到当前源码搜索目录列表的前面,目录之间使用空格间隔。
  • directory(dir):不带参数的directory将源码搜索目录恢复为默认值。
  • /////测试unuse///set directories path-list:将源码目录设置为path-list,但是会补上默认目录(同 directory path-list)。
  • show directories( show dir):显示源码搜索目录列表。
    • gdb在编译时目录中搜索 ($cdir : compilation directory)
    • 当前目录中搜索 ($cwd : current working directory)
    • 源代码搜索目录列表 (substitute-path)
  • //
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章