网站首页网站地图google地图百度地图学习库RSS在线PSPS联盟素材下载  PS视频教程专题 PS爱好者教程网www.psahz.com PS教程自学网QQ群

linux dump命令用法详解。dump命令学习心得。dump命令使用教程。

时间:2016-07-31 16:57 来源:linux dump命令使用教程 作者: dump 阅读:
linux dump命令用法详解。dump命令学习心得。dump命令使用教程。
 Linux下的dump文件一般称为core文件 ,可以用来记录程序崩溃前的线程callstack信息,内存信息等,可以作为排错的一种辅助手段。生存的core大小可以限制,保存的内容也可以灵活的选择,因此在MID上也可以使用。
由于linux的开发性,类似的调试技术比windows上的更为强大,灵活。
 1  Core文件的生成
输入 ulimit  –a
Mid上的输出信息
time(seconds)        unlimited
file(blocks)         unlimited
data(kbytes)         unlimited
stack(kbytes)        8192
coredump(blocks)     0
memory(kbytes)       unlimited
locked memory(kbytes) 32
process              1024
nofiles              1024
vmemory(kbytes)      unlimited
locks                unlimited
 
注意
coredump(blocks)     0
指定了core 文件的大小为0 block
现在修改这个限制,设置成1024个block,如果超过这个值就不再写core文件
Ulimit  -c  1024   
现在用一个测试程序进行验证
[code ]
#include <stdio.h>
int just_a_test()
{
   int * p = NULL;              
   printf("%d /n",*p);
}
int main()
{
 just_a_test();
}
[/code]
在scatchbox 中编译
 
Gcc –Wall  -g  hello.c
将生成的a.out 放入mid中,
加上可执行权限
Chmod +x a.out
执行 ,在同级目录下生成了一个core文件
 
2  定位出错的地方
将core 文件考到编译主机上,在host 上分析该core文件 。
接下来一个很重要的步骤就是编译自己的gdb
在gnu 上下载源码 ,共享中也有
//10.111.0.1/File Exchange Area/zhangwei/gdb/ gdb-7.2.tar.gz
 
解压后进入gdb目录
配置编译参数
Host 默认在x86上,target 则为arm
./configure --target=arm-linux --enable-shared --prefix=/home/shenghuai/3G-Works/3G-Encoder/src/ampleksy/gdb/gdb-7.2 --without-x --disable-gdbtk --disable-tui --without-included-regex --without-included-gettext
Make
Make install
将生成的arm-linux-gdb 加入到path路径中来
运行 arm-linux-gdb 用--core 指定core文件
 
 
 
 
henghuai@shenghuai-3G:~/3G-Works/3G-Encoder/src/amplesky/gdb$ arm-linux-gdb --core=core
GNU gdb (GDB) 7.2
Copyright (C) 2010 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 "--host=i686-pc-linux-gnu --target=arm-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
[New Thread 1491]
Core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
#0  0x000083a0 in ?? ()
 
接下来指定可执行文件(含调试信息)
(gdb) file ./a.out
Reading symbols from /scratchbox/users/shenghuai/home/shenghuai/marvell-sdk/pxalinux/3G-encoder/src/amplesky/gdb/a.out...done.
(gdb) bt
#0  0x000083a0 in just_a_test () at hello.c:7
#1  0x000083c4 in main () at hello.c:14
 
很清晰的列出了出错的callstack 。

    PS笔刷下载 PS滤镜下载 PS形状下载 PS样式下载 PS动作下载 PS图案下载