Linux 下 Coredump 的解析

请添加图片描述

Coredump 的解析

1. 什么是coredump

程序出现段错误,内核错误的时候出现的错误文件。
可以通过该文件复现出现错误的位置,查看错误时的各项值,来解决Bug。

2. coredump取得

默认情况下 home/coredump 中可以看到相关文件,文件名:core.xxxxxx
1)使用ulimit -c unlimited命令,开启core dump功能
2)可以通过修改/proc/sys/kernel/core_pattern,控制core文件保存位置。

3. 运行coredump

使用命令格式 gdb [执行程序] [coredump文件名]
例如
[root@localhost coredump]# gdb cplane core.1234
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-94.el7
Copyright © 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type “show copying”
and “show warranty” for details.
This GDB was configured as “x86_64-redhat-linux-gnu”.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>…
Reading symbols from /home/uea/coredump/ue_cplane…done.
[New LWP 12949]
[New LWP 12950]
[New LWP 12952]
[New LWP 12951]
[New LWP 12953]
[New LWP 12945]
[New LWP 12893]
[New LWP 12947]
[New LWP 12946]
[New LWP 12948]

warning: .dynamic section for “/lib64/libglib-2.0.so.0” is not at the expected address (wrong library or version mismatch?)
[Thread debugging using libthread_db enabled]
Using host libthread_db library “/lib64/libthread_db.so.1”.
Core was generated by `/opt/duosim/uea/module/c-plane/ue_cplane --session 6876819638719825’.
Program terminated with signal 11, Segmentation fault.
#0 0x000000000042b249 in testCoredump (pTskIf=0x7f93eb07f120) at testCoredump.c:443
Missing separate debuginfos, use: debuginfo-install glib2-2.56.1-5.el7.x86_64 glibc-2.17-157.el7.x86_64

以上信息中 #0 0x000000000042b249 in testCoredump (pTskIf=0x7f93eb07f120) at testCoredump.c:443 可以知道程序是在哪里NG的

4.查看基本信息
(gdb) bt
#0 0x000000000042b249 in testCoredump (pTskIf=0x7f93eb07f120) at testCoredump.c:443
#1 0x000000000042b192 in testCoredump(input_p=0x8ae7f60) at testCoredump.c:403
#2 0x00007f93fa8a6dc5 in start_thread () from /lib64/libpthread.so.0
#3 0x00007f93fa3ce73d in clone () from /lib64/libc.so.6

使用bt命令可以查看程序NG时的基本信息

5.查看单个变量值
(gdb) p y->callId
$1 = 4294967295

Edit
6.看结构体变量值
(gdb) p y
$2 = {srcPrtclTyp = 4096, dstPrtclTyp = 33, callId = 4294967295}

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值