使用 dmesg 和 addr2line 分析程序 core 原因
2016-04-13 17:49
369 查看
今天遇到这样一种情况:发现进程 tagent 在发送响应时退出了,退出原因未知,因为没有 core 文件,无从分析。core 文件生成目录和 ulimit 都没有任何问题,就是不生成 core 文件:
写了个小程序也能生成 core, 没有 core 文件,只能另觅他径了。
由日志可以看出程序 core 在 13:27:17 左右,但是 dmesg 中并没与时间戳。
将时间戳进一步转换:
发现时间吻合,程序的确是 core 掉了。
注:/proc/uptime 第一列表示的是系统开机时间,根据这个值和当前时间可以获取到 dmesg 日志中事件发生的时间。
发现代码 core 在了 xxx.cpp 38 行,函数为 plugin_conn_send.
$ cat /proc/sys/kernel/core_pattern core.%p_%e $ ulimit -c unlimited
写了个小程序也能生成 core, 没有 core 文件,只能另觅他径了。
dmesg
dmesg 发现如下两行:[3612464.102140] tagent[29001]: segfault at 7f499fee11d8 ip 00000000004267aa sp 00007f499fee11e0 error 6 in tagent[400000+13d000] [3619693.083152] test[8223]: segfault at 7fff7319a000 ip 000000000040056d sp 00007fff731991b0 error 6 in test[400000+1000]
由日志可以看出程序 core 在 13:27:17 左右,但是 dmesg 中并没与时间戳。
获取 dmesg 日志中的时间戳
dmesg 日志中的“时间”(3612464.102140) 表示的是系统启动到事件发生的时间差,这个值可以转换成时间戳:$ echo "$(date +%s) - $(cat /proc/uptime | cut -f 1 -d' ') + 3612464.102140" | bc 1460525237.192140
将时间戳进一步转换:
$ date -d '@1460525237' '+%Y-%m-%d %H:%M:%S' 2016-04-13 13:27:17
发现时间吻合,程序的确是 core 掉了。
注:/proc/uptime 第一列表示的是系统开机时间,根据这个值和当前时间可以获取到 dmesg 日志中事件发生的时间。
addr2line 找到代码 core 的地方
$ addr2line -e tagent 00000000004267aa -f plugin_conn_send /xxx/xxx.cpp:38
发现代码 core 在了 xxx.cpp 38 行,函数为 plugin_conn_send.
相关文章推荐
- libharu pdf 中文字体生成,及字体旋转。
- shell 中的特殊符号的含义
- Excel/SPSS相关性及显著性水平分析
- BZOJ4402: Claris的剑
- Redis - pipelining(管道)
- 【bzoj3245】【最快路线】【spfa】
- PHP简单的操作mysql
- Python3.5入门学习记录-函数
- win10 eclipse打开图片出现乱码解决办法
- Matlab 中的 isnan 函数
- sizeof详解 -- C++
- 高并发服务端分布式系统设计概要(上)
- swift url 解码(不是最新,swift变得太快了)
- Android weight属性
- session
- Unity3d在runtime中改变material渲染模式
- 【Unity Shaders】法线贴图
- mybatis防止sql注入
- 使用 Git Hook 实现网站的自动部署
- 第七周周记