
gdb ./yourfile core.5245
根据你给出的命令和gdb错误提示,可以断定,你gdb命令用错了,第二个参数是你的可执行程序,比如,你的可执行芦告程序叫DataIntegrityCheck,第3个输入项才是core文件的名字。那么整个命令应该是
cd /home/liubo/DataIntegrityCheck/bin
gdb ./DataIntegrityCheck core.5245
DataIntegrityCheck这里一定是你编译好的可执行程序,我只是举个例子而已。如果你编译没有指定,它甚至可以是a.out
你再试试吧。
core文件,御哗春改成.c是没有用的
通常情况下coredmp包含了程序运行时的内存,寄存器状态,堆栈指针,内存雀拿管理信息等。可以理解为凳李把程序工作的当前状态存储成一个文件。许多程序和 *** 作系统出错时会自动生成一个core文件。内存访问越界a)由于使用错误的下标,导致数组访问越界枣岁迟第一步,需要打开这个设置。用chenconodeskcom:~ chencon$ ulimit -c
unlimited
来查看,显示0表示关闭
chenconodeskcom:~ chencon$ ulimit -c unlimited
来打开,但是这个只在当前窗口有效果。态猜晌如果需要变成系统全局设置。
就需要去改/etc/profile文件,打开,然后加上上面这行。就可以了,这样当产生Crash的时候就会自动产生dump文件。
上面/etc/profile这文件通常是只读的,右键Get Info(显示简介)可以显示权限设置,在最后一个分类里。共享与权限,修改就可以了。
之兆埋后需要配置一下dump产生的规则和路径
sudo sysctl kern.corefile=/cores/core.%N.%P
其中%N表示进程名字,%P表示进程id。Linux还有%S,%T分别表示最后一个信号和时间,在MAC上没找到对应的。
最后如何用lldb来查看一个core dump文件
在命令行中,需要输入
chenconodeskcom:~ chencon$ lldb -c /cores/core.Conan.52661
(lldb) target create --core "/cores/core.Conan.52661"
warning: (x86_64) /cores/帆锋core.Conan.52661 load command 115 LC_SEGMENT_64 has a fileoff + filesize (0x21c49000) that extends beyond the end of the file (0x21c48000), the segment will be truncated to match
warning: (x86_64) /cores/core.Conan.52661 load command 116 LC_SEGMENT_64 has a fileoff (0x21c49000) that extends beyond the end of the file (0x21c48000), ignoring this section
Core file '/cores/core.Conan.52661' (x86_64) was loaded.
(lldb) command source -s 1 '/Users/chencon/./.lldbinit'
warning: failed to set breakpoint site at 0x7fff668dc000 for breakpoint 2.1: error: mach-o-core does not support enabling breakpoints
(lldb) bt
* thread #1: tid = 0x0000, 0x000000010729fb8e Conan`main(argc=1, argv=0x00007fff58960a90) + 30 at main.cpp:24, stop reason = signal SIGSTOP
* frame #0: 0x000000010729fb8e Conan`main(argc=1, argv=0x00007fff58960a90) + 30 at main.cpp:24
frame #1: 0x00007fff9143d5ad libdyld.dylib`start + 1
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)