减少 linux 上的核心转储大小

reduce core dump size on linux

减小核心转储大小的最佳方法是什么?

我的问题是我的 Linux Mint 上几乎没有 space 专门用于此目的。我有大约 200 MB,这远远不足以让我的程序生成像样的转储。我已经尝试配置 coredump 过滤器,但只有匿名私有映射转储在大小上有任何重大变化,但它也使我的转储不可读。我也尝试过使用 ulimit 限制大小,但唯一的结果是每次转储都被截断。

我的问题是控制核心转储大小的最佳方法是什么? 有没有办法只保留转储的前 10-15 帧?另外,如果只生成无用的核心文件,使用 ulimit 设置大小限制有什么用?

考虑使用 Breakpad:https://code.google.com/p/google-breakpad/ https://code.google.com/p/google-breakpad/wiki/GettingStartedWithBreakpad :

Breakpad is a library and tool suite that allows you to distribute an application to users with compiler-provided debugging information removed, record crashes in compact "minidump" files, send them back to your server, and produce C and C++ stack traces from these minidumps. Breakpad can also write minidumps on request for programs that have not crashed.

Whosebug 上似乎有几个相关的答案:

Minimal core dump (stack trace + current frame only)

此 link 建议为 SIGSEGV 设置信号处理程序并以您自己的方式转储核心。

Linux core dumps are too large!

这 link 建议使用 setrlimit 来限制转储的大小。