1、查看是否打开了coredump

  1. lybxin@Inspiron:~/MyRes/miscellany/test/01_coredump$ulimit -c  #这里可以看到ulimit限制coredump的产生
  2. 0
  3. lybxin@Inspiron:~/MyRes/miscellany/test/01_coredump$ulimit -c unlimited  #取消限制
  4. lybxin@Inspiron:~/MyRes/miscellany/test/01_coredump$ulimit -c
  5. unlimited

2、coredump默认存储在与程序相同的目录里

3、core文件的命名规则
/proc/sys/kernel/core_uses_pid  1 表示使用procid命名,0表示不使用
/proc/sys/kernel/core_pattern 可以设置格式化的 core 文件保存位置或文件名
echo “/opt/corefile/core-%e-%p-%t” > /proc/sys/kernel/core_pattern
将会控制所产生的 core 文件会存放到 /corefile 目录下,产生的文件名为 core- 命令名 -pid- 时间戳
以下是参数列表 :
   %p - insert pid into filename 添加 pid
   %u - insert current uid into filename 添加当前 uid
   %g - insert current gid into filename 添加当前 gid
   %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 添加命令名

4、core_pattern内核解析函数

format_corename

5、Coredump调试

除了下面方法外,也可以在打开gdb后使用core-file core-xxx命令来吧core-xxx文件加载进去

  1. lybxin@Inspiron:~/MyRes/miscellany/test/04_gdbtest$gdb -core=core
  2. GNU gdb (Ubuntu7.11.1-0ubuntu1~16.04)7.11.1
  3. Copyright(C)2016FreeSoftwareFoundation,Inc.
  4. LicenseGPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  5. This is free software: you are free to change and redistribute it.
  6. There is NO WARRANTY, to the extent permitted by law.  Type"show copying"
  7. and "show warranty"for details.
  8. This GDB was configured as "x86_64-linux-gnu".
  9. Type"show configuration"for configuration details.
  10. For bug reporting instructions, please see:
  11. <http://www.gnu.org/software/gdb/bugs/>.
  12. Find the GDB manual and other documentation resources online at:
  13. <http://www.gnu.org/software/gdb/documentation/>.
  14. For help, type "help".
  15. Type"apropos word" to search for commands related to "word".
  16. [New LWP 6093]
  17. Core was generated by `./testgdb.out'.
  18. Program terminated with signal SIGSEGV, Segmentation fault.
  19. #0  0x00000000004005f4 in ?? ()
  20. (gdb) bt
  21. #0  0x00000000004005f4 in ?? ()
  22. #1  0x000000000000000a in ?? ()
  23. #2  0x0000000000000140 in ?? ()
  24. #3  0x00007fff5297f7d0 in ?? ()
  25. #4  0x0000000000000145 in ?? ()
  26. #5  0x00007fff5297f6d0 in ?? ()
  27. #6  0x000000000040065e in ?? ()
  28. #7  0x00000000004007ac in ?? ()
  29. #8  0x000000647ce2a7fa in ?? ()
  30. #9  0x0000000000000000 in ?? ()
  31. (gdb) file all.out
  32. warning: core file may not match specified executable file.
  33. Reading symbols from all.out...done.
  34. (gdb) bt
  35. #0  0x00000000004005f4 in test1 (p=320)
  36.    at /home/lybxin/MyRes/miscellany/test/04_gdbtest/testgdb.c:18
  37. #1  0x000000000040065e in test2 (offset=100)
  38.    at /home/lybxin/MyRes/miscellany/test/04_gdbtest/testgdb.c:30
  39. #2  0x00000000004006c3 in main (argc=1, argv=0x7fff5297f7d8)
  40.    at /home/lybxin/MyRes/miscellany/test/04_gdbtest/testgdb.c:46
  41. (gdb)

Coredump及调试的更多相关文章

  1. 【Coredump】调试之旅

    测试反馈,core了. 拿到环境,发现6和11,一个是重复释放,一个是非法指针. 用GDB一挂 ,发现 1 GNU gdb (GDB) 7.5 2 Copyright (C) 2012 Free So ...

  2. gdb 调试coredump文件过程

    gdb 调试coredump文件过程: 第一步:首先需要一个进程的coredump文件,怎么搞出coredump文件呢? 1. ps -fax|grep                 进程名称 找到 ...

  3. gdb调试coredump文件

    linux上程序崩溃起来挺烦人,不过linux 比较好的是有gdb. 1.生成coredump文件 echo "ulimit -c unlimited" >> /etc ...

  4. gdb 调试coredump文件过程:

    第一步:首先需要一个进程的coredump文件,怎么搞出coredump文件呢? 1. ps -fax|grep                 进程名称 找到进程的pid 2.gdb -p pid ...

  5. 40.Linux应用调试-使用gdb和gdbserver

    1.gdb和gdbserver调试原理 通过linux虚拟机里的gdb,来向开发板里的gdbserver发送命令,比如设置断点,运行setp等,然后开发板上的gdbserver收到命令后,便会执行应用 ...

  6. 基于solarflare的openonload技术以TCPDirect方法加速epoll

    [前言]基于solarflare的onload模式加速,官方文档给出TCPDirect模式可以实现从300ns到30ns的延迟缩减.我们需要测试在我们的交易模型框架中他的延时,有人给出了tcpdire ...

  7. 转:linux coredump调试

    1 )如何生成 coredump 文件 ? 登陆 LINUX 服务器,任意位置键入 echo "ulimit -c 1024" >> /etc/profile 退出 L ...

  8. 快速学习C语言二: 编译自动化, 静态分析, 单元测试,coredump调试,性能剖析

    上次的Hello world算是入门了,现在学习一些相关工具的使用 编译自动化 写好程序,首先要编译,就用gcc就好了,基本用法如下 gcc helloworld.c -o helloworld.o ...

  9. coredump调试的使用

    一,什么是coredump 跑程序的时候经常碰到SIGNAL 或者 call trace的问题,需要定位解决,这里说的大部分是指对应程序由于各种异常或者bug导致在运行过程中异常退出或者中止,并且在满 ...

随机推荐

  1. Asp.Net Core链接Mysql数据库

    一.新建一个Asp.Net Core WebMVC程序 添加nuget包  Mysql.Data 二.新建一个UserContext类 下面代码中的UserInfo是我自己建的一个实体,里面有俩字段: ...

  2. Java : Spring基础 AOP

    简单的JDK动态代理例子(JDK动态代理是用了接口实现的方式)(ICar是接口, GoogleCar是被代理对象, MyCC是处理方法的类): public class TestCar { publi ...

  3. php 将富文本编辑后的内容取出

    背景:项目中用了富文本编辑器,讲写完的内容存入了数据库,但是取出的时候因为有些展示地方并不需要样式,只想获取到内容,所以需要将带了html编码的信息解析出来. 原始信息如下 [task_desc] = ...

  4. php源码建博客1--搭建站点-实现登录页面

    主要: 站点搭建 实现登录页面 分析及改进 站点搭建 1)  在apache安装目录下: [conf\extra\httpd-vhosts.conf]加入站点配置 <VirtualHost *: ...

  5. 关于NPOI导出excel文件(xls和xlsx两种格式)提示格式不符的问题

    这两天在做导出excel文件的时候遇到这个问题 本来我导出的格式是xlsx格式的,但是下载得到的文件格式变成了xls, 一开始以为是返回的contenttype设置错了 return File(ms, ...

  6. C程序设计语言笔记-第一章

     The C Programming language notes 一 基础变量类型.运算符和判断循环         char                 字符型  character      ...

  7. R语言爬虫:爬取百度百科词条

    抓取目标:抓取花儿与少年的百度百科中成员信息 url <- "http://baike.baidu.com/item/%E8%8A%B1%E5%84%BF%E4%B8%8E%E5%B0 ...

  8. spring作用

    在SSH框假中spring充当了管理容器的角色.我们都知道hibernate用来做持久层,因为它将JDBC做了一个良好的封装,程序员在与数据库进行交互时可以不用书写大量的SQL语句.Struts是用来 ...

  9. .net core mvc 模型绑定 之 json and urlencoded

    .net core mvc 模型绑定, FromQuery,对应 url 中的 urlencoded string ("?key1=value1&key2=value2") ...

  10. spring源码-开篇

    一.写博客也有一段时间了,感觉东西越来越多了,但是自己掌握的东西越来越少了,很多时候自己也在想.学那么多东西,到头来知道的东西越来越少了.是不是很奇怪,其实一点都不奇怪. 我最近发现了一个很大的问题, ...