How to generate core dump file in Ubuntu
This question already has an answer here:
Activate your coredumps by:
ulimit -c unlimited
Also check:
$ sysctl kernel.core_pattern
to see where your dumps are created (%e will be the process name, and %t will be the system time).
You can change it in /etc/sysctl.conf and then reload by sysctl -p
.
You can test it by:
sleep 10 &
killall -SIGSEGV sleep
If core dumping is successful, you will see “(core dumped)” after the segmentation fault indication.
See also:
How to generate a stacktrace when my gcc C++ app crashes
Ubuntu
If you've Ubuntu, your dumps are created by apport
in /var/crash
, but in different format (edit the file to see it).
Please read more at:
https://wiki.ubuntu.com/Apport
OS X
In OS X, your crash dumps are automatically created by Crash Reporter in form of backtraces. You can find these crash files by executing Console and going to 'User Diagnostic Reports' section (under 'Diagnostic and Usage Information' group) or you can locate them in ~/Library/Logs/DiagnosticReports
.
The actual core files are generated in /cores
.
Read more: How to generate core dumps in Mac OS X?
Check the ouput of ulimit -c
, if it output 0, this is why you don't have core dumped.
Use
ulimit -c unlimited
to allow core creation (maybe replace unlimited
by a real size limit to be more secure) .
使用ulimit -c
SIZE设置最大核心转储大小。
上一篇: 查找由智能指针引起的内存泄漏
下一篇: 如何在Ubuntu中生成核心转储文件