讓程式崩潰後生成Core Dump

2021-06-16 21:41:58 字數 2644 閱讀 7876

我們可以生成core dump檔案,並用gdb重現崩潰時的場景。

ulimit設定core dump開關和大小

1ulimit-c unlimited

測試**:

01#include

02

03

04intmain(intargc,char* argv)

05

編譯:1gcc -g

2./main.c -o ./main.bin

執行,提示出錯:

1./main.bin

2段錯誤 (core dumped)

用gdb除錯復原:

1gdb ./main.bin --core=./core

gbd資訊:

view source

print?

01gnu gdb (gdb) 7.1-ubuntu

02

03license gplv3+: gnu gpl version 3 or later <>

04this isfreesoftware: you arefreeto change and redistribute it.

05there is no warranty, to the extent permitted by law.  type"show copying"

06and"show warranty"fordetails.

07this gdb was configured as"i486-linux-gnu".

08for bug reporting instructions, please see:

09<>...

10reading symbols from /tmp/main.bin...done.

11[new thread 18055]

12

13warning: can'treadpathnameforload map: 輸入/輸出錯誤.

14reading symbols from /lib/tls/i686/cmov/libc.so.6...(no debugging symbols found)...done.

15loaded symbolsfor/lib/tls/i686/cmov/libc.so.6

16reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.

17loaded symbolsfor/lib/ld-linux.so.2

18core was generated by `./main.bin'.

19program terminated with signal 11, segmentation fault.

20#0  0x080483c4 in main (argc=1, argv=0xbfbbafa4) at ./main.c:8

218       *p = 123;

讓程式崩潰後生成Core Dump

在linux下,程式崩潰是很頭疼的事情 其實windows更是如此 我們可以生成core dump檔案,並用gdb重現崩潰時的場景。ulimit設定core dump開關和大小 1 ulimit c unlimited 測試 12 3 4 5 6 7 8 9 10 11 include intmai...

Linux C 讓程式崩潰後生成Core Dump

在linux下,程式崩潰是很頭疼的事情 其實windows更是如此 我們可以生成core dump檔案,並用gdb重現崩潰時的場景。ulimit設定core dump開關和大小 四號程式設計師,1ulimit c unlimited 測試 四號程式設計師,12 3 4 5 6 7 8 9 10 in...

qt程式崩潰生成core dump

二 qt程式 1 qt程式的除錯過程與命令列大同小異,首先編寫崩潰程式如下 void mainwindow on checkbox toggled bool 當勾選checkbox的時候,程式崩潰 2 修改qt程式的makefile,在圖中位置增添 g引數,再進行編譯 2 這裡將程式設定成自啟動,在...