- 打开core文件开关
ulimit -c unlimited
- 设置core文件名称及保存路径
echo "/corefile/core-%e-%p-%t" > /proc/sys/kernel/core_pattern
参数列表:
%p - insert pid into filename 添加pid(进程id)
%u - insert current uid into filename 添加当前uid(用户id)
%g - insert current gid into filename 添加当前gid(用户组id)
%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 添加导致产生core的命令
如果遇到 Permition denu
sudo bash -c 'echo core.%e.%p > /proc/sys/kernel/core_pattern'
3.调用coredump文件
gdb ./可执行文件 coredump文件
报错:value of type `cfg’ requires 123244 bytes, which is more than max-value-size
set max-value-size unlimited