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

查看:27
本文介绍了如何在 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 命令控制与程序执行相关的几个设置,例如您是否应该转储核心.如果你输入

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 中,你会输入

In tcsh, you'd type

limit coredumpsize unlimited

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

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