我們可以生成core dump檔案,並用gdb重現崩潰時的場景。
ulimit設定core dump開關和大小
1
ulimit
-c unlimited
測試**:
01
#include
02
03
04
int
main(
int
argc,
char
* argv)
05
編譯:1
gcc -g
2
./main.c -o ./main.bin
執行,提示出錯:
1
./main.bin
2
段錯誤 (core dumped)
用gdb除錯復原:
1
gdb ./main.bin --core=./core
gbd資訊:
view source
print?
01
gnu gdb (gdb) 7.1-ubuntu
02
03
license gplv3+: gnu gpl version 3 or later <>
04
this is
free
software: you are
free
to change and redistribute it.
05
there is no warranty, to the extent permitted by law. type
"show copying"
06
and
"show warranty"
for
details.
07
this gdb was configured as
"i486-linux-gnu"
.
08
for bug reporting instructions, please see:
09
<>...
10
reading symbols from /tmp/main.bin...
done
.
11
[new thread 18055]
12
13
warning: can't
read
pathname
for
load map: 輸入/輸出錯誤.
14
reading symbols from /lib/tls/i686/cmov/libc.so.6...(no debugging symbols found)...
done
.
15
loaded symbols
for
/lib/tls/i686/cmov/libc.so.6
16
reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...
done
.
17
loaded symbols
for
/lib/ld-linux.so.2
18
core was generated by `./main.bin'.
19
program terminated with signal 11, segmentation fault.
20
#0 0x080483c4 in main (argc=1, argv=0xbfbbafa4) at ./main.c:8
21
8 *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 這裡將程式設定成自啟動,在...