如何在 Mac OS X 中生成核心转储? [英] How to generate core dumps in Mac OS X?

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

问题描述

我似乎无法在 Mac OS X 10.6.8 中生成核心转储.

It seems like I can not generate core dumps in Mac OS X 10.6.8.

$ ulimit -c unlimited
$ ./a.out 
Hello world!
Segmentation fault
$ find ~/ -type f -name core 

# ls -la /cores/
total 0
drwxrwxr-t@  2 root  admin    68 24 jui  2010 .
drwxrwxr-t  31 root  admin  1122 17 oct 15:52 ..

我的当前目录,我的 HOME 和/cores/保持空...

My current directory, my HOME and /cores/ remain empty…

推荐答案

默认情况下,崩溃会报告到 .crash 文件中,这些文件可以在 /Library/Logs/DiagnosticReports 中找到code>(系统范围)和 ~/Library/Logs/DiagnosticReports(用户).这些文件可以使用控制台应用程序在用户系统报告中打开..crash 文件采用纯文本格式,应包含有关崩溃的相关信息.

By default, crashes are reported into .crash files which can be found in /Library/Logs/DiagnosticReports (system-wide) and ~/Library/Logs/DiagnosticReports (user). These files can be opened by using Console app, in User or System Reports. The .crash files are in plain text format and should include relevant information about the crash.

为了激活完整的核心转储,请确保 /cores 目录具有当前用户的写入权限(测试方式:touch/cores/test && rm/核心/测试).此外,请确保您对核心文件大小没有任何限制:

In order to activate the full core dumps, make sure that /cores directory has write permissions for the current user (test by: touch /cores/test && rm /cores/test). In addition, make sure that you don't have any limits on core file sizes by:

ulimit -c unlimited

核心转储文件的名称格式为:core.PID.

The name of the core dump file is in format: core.PID.

如果目录是隐藏的,您可以通过以下方式显示隐藏文件:

If the directory is hidden, you can show the hidden files by:

defaults write com.apple.finder AppleShowAllFiles TRUE

您可以通过以下命令进行测试:

You can test that by the following commands:

sleep 100 &
killall -SIGSEGV sleep

Segmentation fault消息之后,应该说额外的(core dumped).

which should say extra (core dumped), after Segmentation fault message.

核心转储文件默认位于 /cores 目录中.

The core dump files should be found by default in /cores directory.

命令示例:

$ ulimit -c unlimited
$ sleep 100 &
$ killall -SIGSEGV sleep # Then press Enter few times till below message is shown
[1]+  Segmentation fault: 11  (core dumped) sleep 100
$ ls /cores
core.13652
$ lldb -c /cores/core.*
(lldb) target create --core "/cores/core.13652"
Core file '/cores/core.13652' (x86_64) was loaded.
(lldb) bt
* thread #1, stop reason = signal SIGSTOP
  * frame #0: 0x00007fffa7d13fde libsystem_kernel.dylib`__semwait_signal + 10
    frame #1: 0x00007fffa7c9ab92 libsystem_c.dylib`nanosleep + 199
    frame #2: 0x000000010c090002 sleep`rpl_nanosleep + 128

<小时>

另见:技术说明 TN2118 - 内核核心转储.

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

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