發生core dump之後, 用gdb進行查看core文件的內容, 以定位文件中引發core dump的行. gdb [exec file] [ core file]
gdb之所以能夠知道對應的源代碼,是因爲調試版的可執行程序中記錄了源代碼的位置;
因爲源代碼的位置在編譯之後可能會移動到其它地方
所以gdb還會在當前目錄中查找源代碼
另外gdb也允許明確指定源代碼的搜索位置
- 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)
- //