macos Mac 上写的核心转储在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2080918/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:41:25  来源:igfitidea点击:

Where are core dumps written on Mac?

macosunixsignalscoredump

提问by xyz

On Mac OS X, if I send SIGQUIT to my C program, it terminates, but there is no core dump file.

在 Mac OS X 上,如果我将 SIGQUIT 发送到我的 C 程序,它会终止,但没有核心转储文件。

Do you have to manually enable core dumps on Mac OS X (how?), or are they written to somewhere else instead of the working directory?

您是否必须在 Mac OS X 上手动启用核心转储(如何?),还是将它们写入其他地方而不是工作目录?

回答by xyz

It seems they are suppressed by default. Running

似乎默认情况下它们被抑制了。跑步

$ ulimit -c unlimited

Will enable core dumps for the current terminal, and it will be placed in /coresas core.PID. When you open a new session, it will be set to the default value again.

将启用当前终端核心转储,并且它将被放置在/cores作为core.PID。当您打开一个新会话时,它将再次设置为默认值。

回答by kenorb

On macOS, your crash dumps are automatically handled by Crash Reporter.

在 macOS 上,您的故障转储由Crash Reporter自动处理。

You can find backtrace files by executing Consoleand going to User Diagnostic Reportssection (under 'Diagnostic and Usage Information' group) or you can locate them in ~/Library/Logs/DiagnosticReports.

您可以通过执行Console并转到“用户诊断报告”部分(在“诊断和使用信息”组下)来查找回溯文件,也可以在~/Library/Logs/DiagnosticReports.

You can also check where dumps are generated by monitoring system.logfile, e.g.

您还可以通过监视system.log文件检查转储生成的位置,例如

tail -f /var/log/system.log | grep crash

The actual coredump files you can find in /cores.

实际的核心转储文件,你可以找到/cores

See also:

也可以看看:

回答by Joshua Richardson

The answer above,

楼上的回答,

ulimit -c unlimited

ulimit -c 无限制

works -- but be sure to run that in the same terminal from which you will run the program that dumps core. You need to run the ulimit command first.

工作 - 但一定要在你将运行转储核心程序的同一个终端中运行它。您需要先运行 ulimit 命令。

回答by user666406

Additionally, the /cores directory must exist and the user running the program must have write permissions on it.

此外,/cores 目录必须存在,并且运行该程序的用户必须对其具有写入权限。

回答by Gnark

by default, specific directories in mac osx are hidden. you might want to enable this feature in the terminal and then the core dump should be visible within the directory /cores.

默认情况下,mac osx 中的特定目录是隐藏的。您可能希望在终端中启用此功能,然后核心转储应该在目录 /cores 中可见。

defaults write com.apple.finder AppleShowAllFiles TRUE

默认写入 com.apple.finder AppleShowAllFiles TRUE