LinuxSir.cn,穿越时空的Linuxsir!

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

问个关于GDB的问题~

[复制链接]
发表于 2005-1-14 03:26:33 | 显示全部楼层 |阅读模式
测试程序如下:
// name is : debugme.c

#include<stdlib.h>
#include<stdio.h>

#define BIGNUM 5000

void index_to_the_moon(int ary[]);

int main(void)
{
        int intary[100];

        index_to_the_moon(intary);

        exit(EXIT_SUCCESS);
}

void index_to_the_moon(int ary[])
{
        int i;
        for(i=0;i<BIGNUM;++i)
                ary=i;
}

使用gcc debugme.c -o debugme
ulimit -c unlimited
gdb debugme core

在GDB中执行run命令
显示如下:

(gdb) run
Starting program: /home/smile/src/debugme
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.

Program received signal SIGSEGV, Segmentation fault.
0x080483d9 in index_to_the_moon ()

如后又用list命令
显示如下:
(gdb) list
1       /var/tmp/portage/glibc-2.3.4.20040808-r1/work/build/csu/crti.S: No such file or directory.
        in /var/tmp/portage/glibc-2.3.4.20040808-r1/work/build/csu/crti.S

然后用pirnt i ,显示如下:
(gdb) print i
No symbol "i" in current context.

这些都不对阿,是不是我GDB装的有问题阿?????
我的系统是GENTOO 2004.3 使用了nptl。

请教一下这是什么原因?

:help
发表于 2005-1-14 08:19:20 | 显示全部楼层
编译的时候要加-g选项吧!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-1-14 15:31:58 | 显示全部楼层
十分感谢!
的确是要加上g~
回复 支持 反对

使用道具 举报

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

本版积分规则

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