是否可以获得仅包含调用堆栈、线程和局部变量的 Linux coredump? [英] Is it possible to get a Linux coredump that only contains callstack, threads, and local variables?

查看:20
本文介绍了是否可以获得仅包含调用堆栈、线程和局部变量的 Linux coredump?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司正在利用 Linux(特别是 CentOS)中的 coredump 功能来追踪一些难以发现的问题.不幸的是,我们有一堆小型虚拟机在有限的 HD 空间下运行,并且由于堆占用的大量空间,完整的核心转储会导致问题.

My company is utilizing the coredump functionality in Linux (CentOS specifically) to track down some hard to find issues. Unfortunately, we have a bunch of small VMs running with limited HD space and the full core dumps are causing issues because of the large amount of space taken up by the heaps.

当发生分段错误时,是否可以让 Linux 转储调用堆栈、线程和局部变量?我尝试仅将转储限制为 50 兆,但似乎并非所有所需的细节都在前 50 兆字节中(ulimit -c 51200).我们可以像这样截断堆,但我无法找出什么大小可以工作.

Is it possible to just have Linux dump the callstack, threads and local variables when a segmentation fault occurs? I tried just limiting the dumps to 50 megs, but it doesn't seem like all the desired details are in that first 50 megabytes (ulimit -c 51200). We're okay truncating the heap like that, but I haven't been able to find out what size would work.

我知道可以在需要时用一些额外的代码写出你自己的调用堆栈,但我们正处于结束的地步,对于我们正在运行的最后几个问题来说,这将是一个艰难的卖点进入.

I know it's possible to write out your own callstack when desired with some extra code, but we're at the point where we're wrapping up and that'd be a hard sell for these last couple issues we're running into.

推荐答案

您可以将核心转储通过管道传输到程序,然后编写自己的过滤器.摘自 man core

You can pipe core dumps to a program, and so write your own filter. Extract from man core

自内核 2.6.19 起,Linux 支持/proc/sys/kernel/core_pattern 文件.如果这个的第一个字符file 是一个管道符号 (|),那么该行的其余部分是解释为要执行的程序.而不是被写入一个磁盘文件,核心转储作为程序的标准输入给出.

Since kernel 2.6.19, Linux supports an alternate syntax for the /proc/sys/kernel/core_pattern file. If the first character of this file is a pipe symbol (|), then the remainder of the line is interpreted as a program to be executed. Instead of being written to a disk file, the core dump is given as standard input to the program.

您还可以控制将哪些映射写入核心转储,这可能用于减少核心转储的大小.

You can also control which mappings are written to the core dump, this maybe use to reduce the core dump size.

自内核 2.6.23 起,Linux 特定的/proc/PID/coredump_filterfile 可用于控制将哪些内存段写入核心转储文件

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

当然,所有这些都取决于内核版本和配置选项.

Of course, all these depends of kernel version and configuration options.

有关示例或详细信息,请参阅我提供的链接.

see the link I've provided for examples or details.

这篇关于是否可以获得仅包含调用堆栈、线程和局部变量的 Linux coredump?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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