Linux中的选择性核心转储-如何选择转储的部分? [英] Selective core dump in Linux - How can I select the dumped sections?

查看:105
本文介绍了Linux中的选择性核心转储-如何选择转储的部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种选择核心转储中包含的节和内存区域的方法.
我的应用程序的核心转储大小约为30GB,其中大部分位于预先分配的缓冲区中,我什至不需要调试(以后可以将其清零).但是,由于转储很大,因此应用程序要花费太多时间才能完成崩溃并开始恢复.
任何人都可以想到一种方法来预先选择哪些段将在核心转储中吗?
谢谢

I am looking for a way to select the sections and memory regions included in a core dump.
My application's core dump size is about 30GB, most of it is in preallocated buffers which I don't even need in debugging (and can be zeroed later). However, since the dump is so big, it takes too much time for the application to finish crashing and begin recovery.
Can anyone think of a way to select in advance which segments will be in the core dump?
Thanks

推荐答案

根据

According to the core(5) manpage, you can set which mappings are written to the core file:

自内核2.6.23起, 特定于Linux /proc/PID/coredump_filter文件可以是 用于控制哪些内存段 被写入核心转储文件中 核心转储是 为该过程执行的 相应的进程ID.

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.

文件中的值是的位掩码 内存映射类型(请参阅mmap(2)). 如果在掩码中设置了一位,则 对应的内存映射 类型被转储;否则他们是 不倾倒.该文件中的位 具有以下含义:

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.

默认情况下,会设置以下位:0、1、4(如果 CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS 启用了内核配置选项),以及5. 该文件的值以十六进制显示. (这 因此默认值显示为33.) 内存映射的I/O页面(例如帧缓冲区)永远不会被转储,并且 不管coredump_filter如何,虚拟DSO页始终会被转储 值.

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.

...

仅当内核是使用 CONFIG_ELF_CORE配置选项.

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

这篇关于Linux中的选择性核心转储-如何选择转储的部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆