linux - Linux 中的选择性核心转储 - 如何选择转储部分?

标签 linux memory coredump

我正在寻找一种方法来选择核心转储中包含的部分和内存区域。
我的应用程序的核心转储大小约为 30GB,其中大部分位于我在调试时甚至不需要的预分配缓冲区中(以后可以归零)。但是,由于转储太大,应用程序需要很长时间才能完成崩溃并开始恢复。
谁能想到一种方法来提前选择核心转储中的哪些段?
谢谢

最佳答案

根据core(5)手册页,您可以设置将哪些映射写入核心文件:

Since kernel 2.6.23, the Linux-specific /proc/PID/coredump_filter file can be used to control which memory segments are written to the core dump file in the event that a core dump is performed for the process with the corresponding process ID.

The value in the file is a bit mask of memory mapping types (see mmap(2)). If a bit is set in the mask, then memory mappings of the corresponding type are dumped; otherwise they are not dumped. The bits in this file have the following meanings:

       bit 0  Dump anonymous private mappings.
       bit 1  Dump anonymous shared mappings.
       bit 2  Dump file-backed private mappings.
       bit 3  Dump file-backed shared mappings.
       bit 4 (since Linux 2.6.24)
              Dump ELF headers.
       bit 5 (since Linux 2.6.28)
              Dump private huge pages.
       bit 6 (since Linux 2.6.28)
              Dump shared huge pages.

By default, the following bits are set: 0, 1, 4 (if the CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS kernel configuration option is enabled), and 5. The value of this file is displayed in hexadecimal. (The default value is thus displayed as 33.) Memory-mapped I/O pages such as frame buffer are never dumped, and virtual DSO pages are always dumped, regardless of the coredump_filter value.

...

This file is only provided if the kernel was built with the CONFIG_ELF_CORE configuration option.

关于linux - Linux 中的选择性核心转储 - 如何选择转储部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4817867/

相关文章:

python - gdb-python : Parsing structure's each field and print them with proper value, 如果存在

c++ - 如何使用 gdb 从核心文件中获取 lua 堆栈跟踪

python - 如何使用 Python distutils?

python - Kivy 在 Samsung Exynos5422 w/Mali-T628 MP6 上表现不佳

c - linux自动删除文件

c++ - 指向指针/C++ 的指针中的数据类型声明意义)

linux - 在 linux devicetree (arm) 中定义 3 个由相同 GPIO 引脚控制的调节器

java - 滚动 GridView 导致 GC_FOR_ALLOC 释放问题

java.lang.OutOfMemory错误: Java heap space creating a long list of Myclass

linux - 为什么对/etc/limits 的更改不起作用