How do I get a core dump on OS X Lion?

拥有回忆 提交于 2019-12-11 07:59:58

问题


I am working on a PostgreSQL extension in C that segfaults, so I want to look at the core dump file on my OS X Lion box. However, there are no core files in /cores or anywhere else that I can find. It appears that they are enabled in the system but are limited to a size of 0:

> sysctl kern.coredump               
kern.coredump: 1
> ulimit -c
0

I tried setting ulimit -c unlimited in the shell session I'm using to start and stop PostgreSQL, and it seems to stick:

> ulimit -c
unlimited

And yet no matter what I do, no core files. I am starting PostgreSQL with pg_ctl -c, where the -c tells PostgreSQL to generate core dumps. But the system has nothing. How can I get Lion to dump core files?


回答1:


The /cores/ directory is not necessarily there in Lion , and if it's not there, you won't get cores. You should be able to set the ulimit (as you have), run a program like cat(1), quit with a SIGQUIT (control-backslash) and get a coredump:

lion:~ user$ ulimit -c unlimited lion:~ user$ cat ^\ ^\ Quit: 3 (core dumped) lion:~ user$ ls -l /cores/ total 716584 -r-------- 1 user user 366891008 Jun 21 23:35 core.1263 lion:~ user$

Technical Note TN2124 http://developer.apple.com/library/mac/#technotes/tn2124/ as suggested by Yuji in https://stackoverflow.com/a/3783403/225077 is helpful.



来源:https://stackoverflow.com/questions/9386683/how-do-i-get-a-core-dump-on-os-x-lion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!