**:
在linux下,程式崩潰是很頭疼的事情(其實windows更是如此)。
我們可以生成core dump檔案,並用gdb重現崩潰時的場景。
ulimit設定core dump開關和大小
#四號程式設計師,
1ulimit
-c unlimited
測試**:
#四號程式設計師,
12
3
4
5
6
7
8
9
10
#include
int
main(
int
argc,
char
* argv)
編譯:#四號程式設計師,
12
gcc -g
./main
.c -o .
/main.bin
執行,提示出錯:
#四號程式設計師,
12
./main.bin
段錯誤 (core dumped)
用gdb除錯復原:
#四號程式設計師,
1gdb .
/main
.bin --core=.
/core
gbd資訊:
#四號程式設計師,
12
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
gnu gdb (gdb) 7.1-ubuntu
license gplv3+: gnu gpl version 3 or later
this is
free
software: you are
free
to change and redistribute it.
there is no warranty, to the extent permitted by law. type
"show copying"
and
"show warranty"
for
details.
this gdb was configured as
"i486-linux-gnu"
.
for bug reporting instructions, please see:
...
reading symbols from
/tmp/main
.bin...
done
.
[new thread 18055]
warning: can't
read
pathname
for
load map: 輸入/輸出錯誤.
reading symbols from
/lib/tls/i686/cmov/libc
.so.6...(no debugging symbols found)...
done
.
loaded symbols
for
/lib/tls/i686/cmov/libc
.so.6
reading symbols from
/lib/ld-linux
.so.2...(no debugging symbols found)...
done
.
loaded symbols
for
/lib/ld-linux
.so.2
core was generated by `.
/main
.bin'.
program terminated with signal 11, segmentation fault.
#0 0x080483c4 in main (argc=1, argv=0xbfbbafa4) at ./main.c:8
8 *p = 123;
讓程式崩潰後生成Core Dump
我們可以生成core dump檔案,並用gdb重現崩潰時的場景。ulimit設定core dump開關和大小 1ulimit c unlimited 測試 01 include 02 03 04intmain intargc,char argv 05 編譯 1gcc g 2.main.c o mai...
讓程式崩潰後生成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...
qt程式崩潰生成core dump
二 qt程式 1 qt程式的除錯過程與命令列大同小異,首先編寫崩潰程式如下 void mainwindow on checkbox toggled bool 當勾選checkbox的時候,程式崩潰 2 修改qt程式的makefile,在圖中位置增添 g引數,再進行編譯 2 這裡將程式設定成自啟動,在...