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

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

问题描述

我的公司正在利用Linux(特别是CentOS)中的coredump功能来跟踪一些难以发现的问题.不幸的是,我们有一堆运行在有限HD空间中的小型VM,由于堆占用了大量空间,整个核心转储都引起了问题.

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.

推荐答案

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

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文件.如果这个的第一个字符文件是管道符号(|),则该行的其余部分是解释为要执行的程序.而不是被写入磁盘文件,核心转储作为程序的标准输入提供.

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_filter文件可用于控制将哪些内存段写入核心转储文件

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天全站免登陆