close

coredump是用來debug看程式哪個環節error了,程式掛了後,會產生core檔案

可用gdb來看此檔

用法:

step 1:

echo "/var/log/coredump/core-%e-%p-%t" >  /proc/sys/kernel/core_pattern
修改core生成的目錄路徑為/var/log/coredump/底下
               ,寫入設定檔/proc/sys/kernel/core_pattern,其中%部份是命名參數,參考note

more /proc/sys/kernel/core_pattern   檢查是否有修改路徑

:用來看core產生的路徑

 

step 2:

ulimit -c:用來看core dump寫入的容量限制,

預設為0,為不寫入

通常為unlimit設定的方法是

ulimit -c unlimited

step 3:
將要debug的執行檔重啟,並保留視窗到當掉為止,不然開新視窗ulimit -c會為0

step 4:

 

 

當程式當掉後,用gdb看core檔

./gdb a core    :a 執行檔

 

以下是参数列表:
%p – insert pid into filename 添加pid
%u – insert current uid into filename 添加当前uid
%g – insert current gid into filename 添加当前gid
%s – insert signal that caused the coredump into the filename 添加导致产生core的信号
%t – insert UNIX time that the coredump occurred into filename 添加core文件生成时的unix时间
%h – insert hostname where the coredump happened into filename 添加主机名
%e – insert coredumping executable name into filename 添加命令名

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 = = 的頭像
    = =

    逗點大的雨滴

    = = 發表在 痞客邦 留言(0) 人氣()