如何在Linux中生成核心转储文件?

时间:2022-03-21 16:38:28

I am trying to generate the core dump file using the below program in Linux.

我正在尝试在Linux中使用下面的程序生成核心转储文件。

#include <stdio.h>
#include<iostream>
using namespace std;

int main()
{
     char *temp ="ABCDE";
     int i =0;
     temp[3] ='F';
     for (i =0; i <5; i++)
         printf("% Value is %c\n", temp[i]);

     cout<<"Done"<<endl;
     return 0;
}

I saved the above source code as sample.cpp and build the file using the below command.

我将上面的源代码保存为示例。使用下面的命令构建文件。

     g++ sample.cpp -g -o test

Run the output file "test" which produced the error "Segmentation fault". But it didn't generate the core dump file.

运行输出文件“测试”,产生错误的“分割错误”。但是它没有生成核心转储文件。

    ./test

I refereed this . Thanks for your help.

我思量这。谢谢你的帮助。

1 个解决方案

#1


2  

The generation of core dump files it is not always enabled. Try with the ulimit command.

核心转储文件的生成并不总是被启用。尝试使用ulimit命令。

#1


2  

The generation of core dump files it is not always enabled. Try with the ulimit command.

核心转储文件的生成并不总是被启用。尝试使用ulimit命令。