无法为我的崩溃程序创建核心文件 [英] Unable to create a core file for my crashed program

查看:138
本文介绍了无法为我的崩溃程序创建核心文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Ubuntu 12.04 LTS。我写了一个简单的程序,如下所示,以创建崩溃:

  // null.c 
#include< stdio.h>

int main()
{
int * p = NULL;
int k = * p;
printf(%d,sizeof(0));
返回0;
}

现在我运行gcc -g null.c
然后输出./a.out,输出结果如预期。

pre $ code>分段错误(核心转储)

现在我想使用gdb查看核心转储文件。我做了以下事情:


  1. 我检查了当前目录,没有核心转储文件

  2. 我试图用内核core.%e。%p来更改/ proc / sys / kernel / core_pattern。但我无法写入文件。它说Fsync失败。

  3. 我使用了sudo vi / proc / sys / kernel / core_pattern。仍然无法写入文件。

我想在当前目录中创建核心转储。现在该怎么办? 你真正的问题似乎不是我的核心转储在哪里,而是怎么可以我修改 / proc / sys / kernel / core_pattern

  sudo bash -c'echo core。%e。%p> / proc / sys / kernel / core_pattern'

应该这样做。


I am using Ubuntu 12.04 LTS. I wrote a simple program as follows to create crash

// null.c
#include<stdio.h>

int main()
{
   int *p = NULL;
   int k=*p;
   printf("%d",sizeof(0));
   return 0;
}

Now I run with "gcc -g null.c" and then "./a.out" and the output is as expected.

Segmentation fault (core dumped)

Now I want to see the core dump file using gdb. I did the following things

  1. I checked the current directory, there is no core dump file
  2. I tried tried to change the /proc/sys/kernel/core_pattern with the content "core.%e.%p". But i am not able to write into the file. It is saying "Fsync Failed".
  3. I used the "sudo vi /proc/sys/kernel/core_pattern". Still can't write into the file.

I want to create the core dump in my current directory. What to do now?

解决方案

Your real question appears to be not "where is my core dump", but rather "how can I modify /proc/sys/kernel/core_pattern".

sudo bash -c 'echo core.%e.%p > /proc/sys/kernel/core_pattern'

should do the trick.

这篇关于无法为我的崩溃程序创建核心文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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