core dump調(diào)查方法

core dump概念

A core dump is the recorded state of the working memory of a computer program at a specific time, generally when the program has terminated abnormally (crashed). In practice, other key pieces of program state are usually dumped at the same time, including the processor registers, which may include the program counter and stack pointer, memory management information, and other processor and operating system flags and information. The name comes from the once-standard memory technology core memory. Core dumps are often used to diagnose or debug errors in computer programs.

On many operating systems, a fatal error in a program automatically triggers a core dump, and by extension the phrase "to dump core" has come to mean, in many cases, any fatal error, regardless of whether a record of the program memory is created.

如果程序在運(yùn)行期間發(fā)生崩潰,操作系統(tǒng)會(huì)生成一個(gè)core dump文件,之后通過對(duì)core dump文件進(jìn)行分析可以獲取程序崩潰的原因

默認(rèn)情況下,Linux 不允許生成core dump文件

# 設(shè)置core大小為無限
ulimit -c unlimited
# 查看當(dāng)前允許core文件大小
ulimit -c

修改/proc/sys/kernel/core_uses_pid,可以把進(jìn)程的pid作為core文件的擴(kuò)展名
修改/proc/sys/kernel/core_pattern,可以控制core文件保存位置和文件格式

echo 1 > /proc/sys/kernel/core_uses_pid                             # core.pid
echo "/corefile/core-%e-%p-%t" > /proc/sys/kernel/core_pattern      # core-cmd-pid-timestamp

通過gdb調(diào)試對(duì)core文件進(jìn)行分析

gdb program core文件
bt
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Troubleshooting 整理 kill -3 pid發(fā)送一個(gè)SIGQUIT信號(hào)給Java應(yīng)用, 通常會(huì)有當(dāng)...
    andersonoy閱讀 774評(píng)論 0 0
  • 什么是core? 在linux中,程序運(yùn)行時(shí)出現(xiàn)異常崩潰,操作系統(tǒng)會(huì)將程序當(dāng)時(shí)的內(nèi)存狀態(tài)、調(diào)用堆棧等信息保存在co...
    拉普拉斯妖kk閱讀 1,979評(píng)論 0 0
  • 一、core 文件的生成 C程序因?yàn)閟egment fault(段錯(cuò)誤)崩潰時(shí),如果系統(tǒng)core dump功能是打...
    zhuweipu閱讀 2,527評(píng)論 0 2
  • ???? 性能分析工具匯總 收藏 一、分析工具 1、CPU性能分析工具: vmstat ps sar time s...
    翟云云閱讀 1,158評(píng)論 0 0
  • 這個(gè)平臺(tái)第一次寫技術(shù)博客,希望自己能夠堅(jiān)持下去。 既然是嵌入式,那么就從common的分析, 當(dāng)然選擇一個(gè)ARM的...
    ybzhao閱讀 3,958評(píng)論 0 2

友情鏈接更多精彩內(nèi)容