什么是coredump?
coredump是程序崩潰時的內(nèi)存快照。
操作系統(tǒng)在程序發(fā)生異常而異常在進(jìn)程內(nèi)部又沒有被捕獲的情況下,會把進(jìn)程此刻內(nèi)存、寄存器狀態(tài)、運行堆棧等信息轉(zhuǎn)儲保存在一個文件里。
什么場景/怎樣才能出coredump?
ulimit -c 可以設(shè)置core文件的大小,如果這個值為0.則不會產(chǎn)生core文件,這個值太小,則core文件也不會產(chǎn)生,因為core文件一般都比較大。
查看ulimit
ulimit -c
設(shè)置ulimit
ulimit -c unlimited
ulimit -c 1024
coredump存儲目錄在哪?
- linux操作系統(tǒng)
/proc/sys/kernel/core_pattern定義了下coredump路徑的pattern。
gdp調(diào)試coredump
gdb sbin/nginx cores/core.nginx.1562145687.176208
輸出為:
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `nginx: worker process '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 ngx_vslprintf (buf=0x7fffc9da3c68 "\320=\332\311\377\177",
buf@entry=0x7fffc9da3c5a "my_test_conf: \320=\332\311\377\177", last=last@entry=0x7fffc9da4c30 "",
fmt=0x742d76 "s", fmt@entry=0x742d67 "my_test_conf: %s", args=args@entry=0x7fffc9da3c18)
at src/core/ngx_string.c:272
272 while (*p && buf < last) {