在linux調試程式,最痛苦的就是程式異常宕掉,但是找不到core檔案,很難定位問題。但是有了core檔案就容易定位多了。
一般是可以通過在環境變量中設定ulimit -c unlimited。但是現場實施人員有時會忘記設定這條指令。那麼怎麼辦呢,可以通過設定linux的abrt服務來實作。
修改abrt-action-save-package-data.conf檔案
将其修改為:vi /etc/abrt/abrt-action-save-package-data.conf
# With this option set to "yes",
# only crashes in signed packages will be analyzed.
# the list of public keys used to check the signature is
# in the file gpg_keys
#
OpenGPGCheck = no
# Blacklisted packages
#
BlackList = nspluginwrapper, valgrind, strace, mono-core
# Process crashes in executables which do not belong to any package?
#
ProcessUnpackaged = yes
# Blacklisted executable paths (shell patterns)
#
BlackListedPaths = /usr/share/doc/, /example*, /usr/bin/nspluginviewer, /usr/lib/xulrunner-*/plugin-container
還可以調整core檔案的大小:[[email protected] abrt]# cat abrt.conf
# Enable this if you want abrtd to auto-unpack crashdump tarballs which appear
# in this directory (for example, uploaded via ftp, scp etc).
# Note: you must ensure that whatever directory you specify here exists
# and is writable for abrtd. abrtd will not create it automatically.
#
#WatchCrashdumpArchiveDir = /var/spool/abrt-upload
# Max size for crash storage [MiB] or 0 for unlimited
#
MaxCrashReportsSize = 1000
# Specify where you want to store coredumps and all files which are needed for
# reporting. (default:/var/spool/abrt)
#
# Changing dump location could cause problems with SELinux. See man abrt_selinux(8).
#
#DumpLocation = /var/spool/abrt
# If you want to automatically clean the upload directory you have to tweak the
# selinux policy.
#
DeleteUploaded = no
重新開機 abrtd 服務: service abrtd restart
有了core檔案也需要及時删除,通過abrt-cli list檢視檔案的包,然後用abrt-cli rm 【檔案包】就可以了。
abrt-cli rm