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

查看:91
本文介绍了如何在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(系统范围)和~/Library/Logs/DiagnosticReports(用户)中找到.可以使用 Console 应用程序在 User System Reports 中打开这些文件. .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 /cores/test).此外,请通过以下方法确保您对核心文件的大小没有任何限制:

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

在出现细分错误" 消息后,应该多说(core dumped).

默认情况下,应该在/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天全站免登陆