如何在我的Linux C ++程序中启用核心转储 [英] How to enable core dump in my Linux C++ program

查看:243
本文介绍了如何在我的Linux C ++程序中启用核心转储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序是用C ++编写的。使用gcc编译,使用-g3 -O0 -ggdb标志。当它崩溃,我想打开它的核心转储。它是创建核心转储文件,还是我需要做一些事情以启用核心转储创建,在程序本身,或在执行它的计算机上?

My program is written in C++. compiled with gcc, using -g3 -O0 -ggdb flags. When it crashes, I want to open its core dump. Does it create core dump file, or I need to do something to enable core dump creation, in the program itself, or on computer where it is executed? Where this file is created, and what is its name?

推荐答案

您需要设置 ulimit -c 。如果此参数的值为0,则不会创建coredump文件。所以这样做: ulimit -c unlimited 并检查一切是否正确 ulimit -a 。当应用程序做了不恰当的事情时,创建coredump文件。我的系统上的文件名为 core。< process-pid-here>

You need to set ulimit -c. If you have 0 for this parameter a coredump file is not created. So do this: ulimit -c unlimited and check if everything is correct ulimit -a. The coredump file is created when an application has done for example something inappropriate. The name of the file on my system is core.<process-pid-here>.

这篇关于如何在我的Linux C ++程序中启用核心转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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