如何在Mac上生成核心文件? [英] How to generate core files on a Mac?
本文介绍了如何在Mac上生成核心文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试 $ ulimit -c unlimited
,但是当运行程序,然后导航到/ cores /时,当我键入时,没有生成核心文件ls
。
我在这里缺少什么?
提前感谢! / p>
解决方案
启用核心文件生成的方式取决于你的shell。您显示的语法是针对某人使用 sh
或 bash
作为其shell,并且它应该可以正常工作。例如
%sh
sh-3.2 $ cat> / tmp / ac
int main b $ b {
void(* f)()= 0;
f();
}
sh-3.2 $ clang -g / tmp / ac -o /tmp/a.out
sh-3.2 $ ulimit -c unlimited
sh-3.2 $ / tmp /a.out
分段错误:11(核心转储)
sh-3.2 $ ls -l /cores/core.10893
-r -------- 1 jason admin 367714304 Nov 16 13:13 /cores/core.10893
sh-3.2 $ gdb -q /tmp/a.out /cores/core.10893
阅读共享库的符号.. done
读取共享库的符号。完成
读取共享库的符号
警告:找不到对象文件/var/folders/5h/nlzqfv116jnc68g495d_3j4m0000gn/T/a-pUbMeU.o - 没有调试信息可用于/ tmp / ac 。
.......................... done
#0 0x0000000000000000 in ?? ()
(gdb)add-dsym /tmp/a.out.dSYM
将dsym/tmp/a.out.dSYM添加到[memory object/private/tmp/a.out 0x10f5d7000]。
(gdb)bt
#0 0x0000000000000000在?? ()
#1 0x000000010f5d7f3d在main()在/tmp/a.c:4
(gdb)
I have a program that I hope to debug in gdb for a segmentation fault, but I'm not sure how I can generate a core file from it.
I tried $ ulimit -c unlimited
, but when ran the program and then navigated into /cores/, there is no core file generated there when I typed ls
.
Am I missing anything here?
Thanks in advance!
解决方案
The way you enable core file generation is dependent on your shell. The syntax you're showing is for someone using sh
or bash
as their shell, and it should work fine. e.g.
% sh
sh-3.2$ cat>/tmp/a.c
int main ()
{
void (*f)() = 0;
f();
}
sh-3.2$ clang -g /tmp/a.c -o /tmp/a.out
sh-3.2$ ulimit -c unlimited
sh-3.2$ /tmp/a.out
Segmentation fault: 11 (core dumped)
sh-3.2$ ls -l /cores/core.10893
-r-------- 1 jason admin 367714304 Nov 16 13:13 /cores/core.10893
sh-3.2$ gdb -q /tmp/a.out /cores/core.10893
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries
warning: Could not find object file "/var/folders/5h/nlzqfv116jnc68g495d_3j4m0000gn/T/a-pUbMeU.o" - no debug information available for "/tmp/a.c".
.......................... done
#0 0x0000000000000000 in ?? ()
(gdb) add-dsym /tmp/a.out.dSYM
Added dsym "/tmp/a.out.dSYM" to "[memory object "/private/tmp/a.out" at 0x10f5d7000]".
(gdb) bt
#0 0x0000000000000000 in ?? ()
#1 0x000000010f5d7f3d in main () at /tmp/a.c:4
(gdb)
这篇关于如何在Mac上生成核心文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文