Linux下生成core dump文件的配置及对core文件的分析

1.环境配置(core 文件生成条件)

1.文件路径配置

kernel.core_pattern = /var/crash/core-%e-%s-%u-%g-%p-%t // 添加到/etc/sysctl.conf
//参数说明
%e is the filename
%g is the gid the process was running under
%p is the pid of the process
%s is the signal that caused the dump
%t is the time the dump occurred
%u is the uid the process was running under

sysctl -p //使配置生效

2.core文件大小配置

ulimit -c unlimited //unlimited 可替换为固定值

1.永久生效方法

可以在~/.bashrc(只对当前用户生效)文件末尾添加ulimit -c unlimited,这样每次打开shell都会生效,可以使用编辑器或者输入命令$ echo 'ulimit -c unlimited' >> ~/.bashrc进行添加。

3.可选配置

程序编译选项添加 -g 选项会生成调试信息

4.参考

环境配置
-g选项作用

2. 使用 gdb 对 coredump 文件进行分析

常用指令参考
gdb使用手册

posted @   浮生多少记  阅读(577)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
点击右上角即可分享
微信分享提示