linux下的dump调试
来源:互联网 发布:包包设计软件 编辑:程序博客网 时间:2024/06/03 15:27
Linux下的dump文件一般称为core文件 ,可以用来记录程序崩溃前的线程callstack信息,内存信息等,可以作为排错的一种辅助手段。生存的core大小可以限制,保存的内容也可以灵活的选择,因此在MID上也可以使用。
一 core文件的生成
1 查看core信息
输入 ulimit -a,显示如下:
core file size (blocks, -c) 1024
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 20
file size (blocks, -f) unlimited
pending signals (-i) 16382
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) unlimited
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
如果core file size为0的话,则输入ulimit -c 1024, 表示设置成1024个block,如果超过这个值就不再写core文件
2 测试程序如下
#include <stdio.h>
int test()
{
int * p = NULL;
printf("%d /n",*p);
}
int main()
{
test();
}
在ubuntu上编译程序:
gcc –Wall -g test.c
加上可执行权限
chmod +x a.out
执行 ,在同级目录下生成了一个core文件
gdb --core=core
显示如下:
GNU gdb 6.8-debian
Copyright (C) 2008 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-linux-gnu".
(no debugging symbols found)
Core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
[New process 18079]
#0 0x0000000000400520 in ?? ()
(gdb)
接下来指定可执行文件(含调试信息)
(gdb) file ./a.out
显示如下:Reading symbols from /home/share/test/a.out...done.
执行(gdb) bt,显示如下:
#0 0x0000000000400520 in just_a_test () at hello.c:8
#1 0x0000000000400546 in main () at hello.c:15
即定位到相应的错误行
- linux下的dump调试
- Linux下调试core dump 文件的方法
- Linux下调试core dump文件的方法
- linux下的代码错误调试技能-core dump
- Linux下core dump调试--gdb
- Linux下利用core dump文件调试
- linux 下dump的使用
- linux下的dump时机
- Linux 下的Core Dump
- window下dump文件的调试
- Linux core dump的调试技术
- Linux core dump的调试技术
- Linux core dump的调试技术
- Linux core dump的调试技
- Linux core dump的调试技术
- Linux下的段错误产生的原因及调试方法&&Core Dump
- linux 调试(dump)
- Linux core dump调试
- having
- 多线程编程之三——线程间通讯
- C++处理异常 try,catch,throw
- 弗洛伊德算法求最短路径
- 使得EditText失去焦点
- linux下的dump调试
- maven 手动加载第三方jar、zip包
- Unity调用安卓的两种方法
- Linux下ls命令的简单实现
- zigbee--电源管理OSAL机制的z-statk低功耗管理(CC2530)
- GCC介绍
- 图片等比例缩放
- Linux服务器不关机新增硬盘的方法
- Python日志输出——logging模块