LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 894|回复: 3

问个 core

[复制链接]
发表于 2006-12-20 20:47:04 | 显示全部楼层 |阅读模式
redhat 9.0

问下他是否自动产生core 文件,,
文件在哪 个地方.
比如运行下面程序的可执行文件,是否自动产生core 及 地方(gcc -g 了)
#include

int main()

{

    int i=0;

    int j=5;

    int tmp;

    for(; i < 10; i++, j--)

    {

        tmp=i/j;

        printf("%d/%d=%dn", i, j, tmp);

    }

}
发表于 2006-12-22 18:27:56 | 显示全部楼层
两三个月没来,越来越发觉这个论坛变得让人难以理解了。
回复 支持 反对

使用道具 举报

发表于 2006-12-22 18:47:21 | 显示全部楼层
你可以使用 gdb 来产生一个 core 文件。

[yichi@localhost ~]$ gdb a.out
GNU gdb Red Hat Linux (6.5-15.fc6rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) run a.out
Starting program: /home/yichi/a.out a.out

Program received signal SIGFPE, Arithmetic exception.
0x0804837d in main () at test.c:11
11                      tmp=i/j;
(gdb) generate-core-file
Saved corefile core.27470
(gdb)
回复 支持 反对

使用道具 举报

发表于 2006-12-22 18:59:30 | 显示全部楼层
其实你可以打开 core dump

看看有没有打开:
$ ulimit -c
0
为 0 表示没打开
$ ulimit -c unlimited
这就打开了

确定是否打开:
$ ulimit -c
unlimited
呵呵,打开了。

现在运行你的程序,你就会看到 core 文件了。

如果你想一直打开,就修改:(不建议这么做)
/etc/profile 文件
搜索 core 就会看到了。

更多信息:
http://www.network-theory.co.uk/docs/gccintro/gccintro_38.html
书:
google for 'gcc intro' will bring you a pdf book.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表