如何在OS X Lion上获得核心转储? [英] How do I get a core dump on OS X Lion?

查看:106
本文介绍了如何在OS X Lion上获得核心转储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用segfaults的C语言进行PostgreSQL扩展,因此我想查看OS X Lion盒上的核心转储文件.但是,在/cores或我可以找到的其他任何地方都没有核心文件.看来它们已在系统中启用,但大小限制为0:

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

我尝试在用于启动和停止PostgreSQL的shell会话中设置ulimit -c unlimited,但它似乎卡住了:

> ulimit -c
unlimited

但是无论我做什么,都没有核心文件.我从pg_ctl -c开始PostgreSQL,其中-c告诉PostgreSQL生成核心转储.但是系统没有任何东西.如何获得Lion转储核心文件?

解决方案

/cores/目录不一定在Lion中存在,如果不存在,则不会获得内核.您应该能够设置ulimit(如您所愿),运行cat(1)之类的程序,使用SIGQUIT退出(控制反斜杠)并获得coredump:

狮子:〜用户$ ulimit -c无限制 狮子:〜user $ cat ^ \ ^ \ 退出:3(核心已转储) 狮子:〜用户$ ls -l/cores/ 总计716584 -r -------- 1个用户用户366891008 Jun 21 23:35 core.1263 狮子:〜用户$

技术说明TN2124 http://developer.apple.com/library/如Yuji在 https://stackoverflow.com/a/3783403/225077 很有帮助.

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?

解决方案

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.

这篇关于如何在OS X Lion上获得核心转储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆