如何在Linux发生分段故障时生成核心转储? [英] How to generate a core dump in Linux on a segmentation fault?

查看:102
本文介绍了如何在Linux发生分段故障时生成核心转储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux中有一个进程出现分段错误.我如何告诉它在失败时生成核心转储?

I have a process in Linux that's getting a segmentation fault. How can I tell it to generate a core dump when it fails?

推荐答案

这取决于您所使用的shell.如果使用的是bash,则ulimit命令控制与程序执行有关的一些设置,例如是否应该转储core.如果您输入

This depends on what shell you are using. If you are using bash, then the ulimit command controls several settings relating to program execution, such as whether you should dump core. If you type

ulimit -c unlimited

然后将告诉bash它的程序可以转储任何大小的内核.您可以根据需要指定诸如52M的大小,而不是无限制的大小,但是实际上,这不是必需的,因为核心文件的大小可能永远不会成为您的问题.

then that will tell bash that its programs can dump cores of any size. You can specify a size such as 52M instead of unlimited if you want, but in practice this shouldn't be necessary since the size of core files will probably never be an issue for you.

在tcsh中,您输入

limit coredumpsize unlimited

这篇关于如何在Linux发生分段故障时生成核心转储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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