Coredump及调试
1、查看是否打开了coredump
lybxin@Inspiron:~/MyRes/miscellany/test/01_coredump$ulimit -c #这里可以看到ulimit限制coredump的产生0lybxin@Inspiron:~/MyRes/miscellany/test/01_coredump$ulimit -c unlimited #取消限制lybxin@Inspiron:~/MyRes/miscellany/test/01_coredump$ulimit -cunlimited
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文件加载进去
lybxin@Inspiron:~/MyRes/miscellany/test/04_gdbtest$gdb -core=coreGNU gdb (Ubuntu7.11.1-0ubuntu1~16.04)7.11.1Copyright(C)2016FreeSoftwareFoundation,Inc.LicenseGPLv3+: 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-linux-gnu".Type"show configuration"for configuration details.For bug reporting instructions, please see:<http://www.gnu.org/software/gdb/bugs/>.Find the GDB manual and other documentation resources online at:<http://www.gnu.org/software/gdb/documentation/>.For help, type "help".Type"apropos word" to search for commands related to "word".[New LWP 6093]Core was generated by `./testgdb.out'.Program terminated with signal SIGSEGV, Segmentation fault.#0 0x00000000004005f4 in ?? ()(gdb) bt#0 0x00000000004005f4 in ?? ()#1 0x000000000000000a in ?? ()#2 0x0000000000000140 in ?? ()#3 0x00007fff5297f7d0 in ?? ()#4 0x0000000000000145 in ?? ()#5 0x00007fff5297f6d0 in ?? ()#6 0x000000000040065e in ?? ()#7 0x00000000004007ac in ?? ()#8 0x000000647ce2a7fa in ?? ()#9 0x0000000000000000 in ?? ()(gdb) file all.outwarning: core file may not match specified executable file.Reading symbols from all.out...done.(gdb) bt#0 0x00000000004005f4 in test1 (p=320)at /home/lybxin/MyRes/miscellany/test/04_gdbtest/testgdb.c:18#1 0x000000000040065e in test2 (offset=100)at /home/lybxin/MyRes/miscellany/test/04_gdbtest/testgdb.c:30#2 0x00000000004006c3 in main (argc=1, argv=0x7fff5297f7d8)at /home/lybxin/MyRes/miscellany/test/04_gdbtest/testgdb.c:46(gdb)
Coredump及调试的更多相关文章
- 【Coredump】调试之旅
测试反馈,core了. 拿到环境,发现6和11,一个是重复释放,一个是非法指针. 用GDB一挂 ,发现 1 GNU gdb (GDB) 7.5 2 Copyright (C) 2012 Free So ...
- gdb 调试coredump文件过程
gdb 调试coredump文件过程: 第一步:首先需要一个进程的coredump文件,怎么搞出coredump文件呢? 1. ps -fax|grep 进程名称 找到 ...
- gdb调试coredump文件
linux上程序崩溃起来挺烦人,不过linux 比较好的是有gdb. 1.生成coredump文件 echo "ulimit -c unlimited" >> /etc ...
- gdb 调试coredump文件过程:
第一步:首先需要一个进程的coredump文件,怎么搞出coredump文件呢? 1. ps -fax|grep 进程名称 找到进程的pid 2.gdb -p pid ...
- 40.Linux应用调试-使用gdb和gdbserver
1.gdb和gdbserver调试原理 通过linux虚拟机里的gdb,来向开发板里的gdbserver发送命令,比如设置断点,运行setp等,然后开发板上的gdbserver收到命令后,便会执行应用 ...
- 基于solarflare的openonload技术以TCPDirect方法加速epoll
[前言]基于solarflare的onload模式加速,官方文档给出TCPDirect模式可以实现从300ns到30ns的延迟缩减.我们需要测试在我们的交易模型框架中他的延时,有人给出了tcpdire ...
- 转:linux coredump调试
1 )如何生成 coredump 文件 ? 登陆 LINUX 服务器,任意位置键入 echo "ulimit -c 1024" >> /etc/profile 退出 L ...
- 快速学习C语言二: 编译自动化, 静态分析, 单元测试,coredump调试,性能剖析
上次的Hello world算是入门了,现在学习一些相关工具的使用 编译自动化 写好程序,首先要编译,就用gcc就好了,基本用法如下 gcc helloworld.c -o helloworld.o ...
- coredump调试的使用
一,什么是coredump 跑程序的时候经常碰到SIGNAL 或者 call trace的问题,需要定位解决,这里说的大部分是指对应程序由于各种异常或者bug导致在运行过程中异常退出或者中止,并且在满 ...
随机推荐
- MVC Controller 基类 BaseController 中的 Request
今天修复mvc中的一个bug,需求是每个页面要获取当前URL链接中 host首是否正确,我把获取url的方法写到了Controller的基类BaseController(BaseController继 ...
- Java三种代理模式
本文转自:https://mp.weixin.qq.com/s/nBmbNP2mR7ei-lDsuOxjWg 代理模式 代理(Proxy)是一种设计模式,提供了对目标对象另外的访问方式;即通过代理对象 ...
- php 遍历一个文件夹下的所有文件和子文件
php 遍历一个文件夹下的所有文件和子文件 <?php /** * 将读取到的目录以数组的形式展现出来 * @return array * opendir() 函数打开一个目录句柄,可由 clo ...
- 7z 压缩解压简单示例
7z命令行压缩示例: 7z -tZip a test.zip ./test/* -mx0 把test文件夹中所有文件以存储压缩的模式压缩成zip格式的文件,压缩文件为test.zip a为添加选项 ...
- B/S与C/S架构简介
概念: C/S结构,即Client/Server(客户机/服务器)结构,是大家熟知的软件系统体系结构,通过将任务合理分配到Client端和Server端,降低了系统的通讯开销,可以充分利用两端硬件环境 ...
- Python学习:12.Python字符串格式化
字符串格式化 讲解Python这么久,也没有讲解Python的字符串的格式化,那我们今天就来了解一下python字符串格式化的强大之处. 首先我们先理解一下为什么要有字符串的格式化,就是为了方便字符串 ...
- BZOJ1011 莫比乌斯反演(基础题
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1101 [题目大意] 求[1,n][1,m]内gcd=k的情况 [题解] 考虑求[1,n ...
- 20145207《网络对抗》MAL后门原理与实践
20145207<网络对抗>MAL后门原理与实践 基础问题回答 (1)例举一个后门进入到你系统中的可能方式? 下载软件,淘宝虚假链接,买卖账号时侵入的黑客 (2)例举一个后门启动起来(wi ...
- Spring Cloud 分布式事务管理
Spring Cloud 分布式事务管理 在微服务如火如荼的情况下,越来越多的项目开始尝试改造成微服务架构,微服务即带来了项目开发的方便性,又提高了运维难度以及网络不可靠的概率. Spring Clo ...
- 北京Uber优步司机奖励政策(4月7日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...