免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3131 | 回复: 14
打印 上一主题 下一主题

初学gdb中的问题求助。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-12-16 22:55 |只看该作者 |倒序浏览
我写了下面一个简单程序,学习一下gdb的用法:
main()
{
  printf ("hello world\n";
}
用gcc -g -o hello hello.c编译,直接在终端下执行没错,在gdb下用file hello 后run,
(gdb) run
Starting program: /home/all/debug
Error while mapping shared library sections:
: 成功.
Error while reading shared library symbols:
: 没有那个文件或目录.
Error while reading shared library symbols:
: 没有那个文件或目录.
Error while reading shared library symbols:
: 没有那个文件或目录.
hello world

Program exited with code 014.

结果出现了上面一大堆,这是怎么回事。 谢谢

论坛徽章:
0
2 [报告]
发表于 2004-12-17 09:59 |只看该作者

初学gdb中的问题求助。

从来没遇到这个问题。按理说既然./hello能运行,那共享库的加载、符号表什么的都应该没问题,怎么gdb识别不出来呢?我在自己机器上试了一下,没问题的,我是RH9环境,楼主你呢?

论坛徽章:
0
3 [报告]
发表于 2004-12-17 12:10 |只看该作者

初学gdb中的问题求助。

我现在用eclipse来写C/C++,这里面调试,编译看起来方便多了。

论坛徽章:
0
4 [报告]
发表于 2004-12-17 15:30 |只看该作者

初学gdb中的问题求助。

[quote]原帖由 "albcamus"]从来没遇到这个问题。按理说既然./hello能运行,那共享库的加载、符号表什么的都应该没问题,怎么gdb识别不出来呢?我在自己机器上试了一下,没问题的,我是RH9环境,楼主你呢?[/quote 发表:



我的是Fedora2, 我也纳闷,要是有错在终端和emacs的那个Shell下也该不行啊。我又运行了以前学的几个小程序,结果都对,就是还有那个不能加载共享库符号表之类的。
这是我的gdb版本号,
$ gdb --version
GNU gdb Red Hat Linux (6.0post-0.20040223.19rh)
Copyright 2004 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".

论坛徽章:
0
5 [报告]
发表于 2004-12-18 19:29 |只看该作者

初学gdb中的问题求助。

顺便问问sco、aix上需要安装什么软件才能用gdb,我现在就只安装了开发系统。

论坛徽章:
0
6 [报告]
发表于 2004-12-18 20:50 |只看该作者

初学gdb中的问题求助。

[quote]原帖由 "lifyman"]顺便问问sco、aix上需要安装什么软件才能用gdb,我现在就只安装了开发系统。[/quote 发表:


要装 gdb 才能使用 gdb。

论坛徽章:
0
7 [报告]
发表于 2004-12-20 19:43 |只看该作者

初学gdb中的问题求助。

呵呵
还没试过呢

论坛徽章:
0
8 [报告]
发表于 2004-12-21 14:45 |只看该作者

初学gdb中的问题求助。

需要用b来设置断点 ,比如b main

论坛徽章:
0
9 [报告]
发表于 2004-12-21 15:20 |只看该作者

初学gdb中的问题求助。

[quote]原帖由 "jetwins"]需要用b来设置断点 ,比如b main[/quote 发表:


和断点好像没大关系. thank you all the same.
另外在程序调试结束的时候有的是一个exit with code, 有的时候显示exit normally. 这个和什么有关?仅仅是后面的那个return语句?还有一点返回码是023的时候比较多.

这就是上面的那个程序
(gdb) run
Starting program: /home/all/c134
Error while mapping shared library sections:
: 成功.
Error while reading shared library symbols:
: 没有那个文件或目录.
(no debugging symbols found)...(no debugging symbols found)...Error while reading shared library symbols:
: 没有那个文件或目录.
Error while reading shared library symbols:
: 没有那个文件或目录.
input some letters:
aaa
the input string is aaa

that's OK!

Program exited with code 013.
(gdb)

这是另一个小程序:c129.c
int a(int i)
{
  int j = 0;
  printf ("the stack address is %p\n", &i);
  if (i >; 0)
    a (--i);
  else
    printf ("i has reached zero ";
   return 0;
}
int main()
{
  a(2);
  return 0;
}

(gdb) r
Starting program: /home/all/c129
Error while mapping shared library sections:
: 成功.
Error while reading shared library symbols:
: 没有那个文件或目录.
Error while reading shared library symbols:
: 没有那个文件或目录.
Error while reading shared library symbols:
: 没有那个文件或目录.
the stack address is 0xfeec8a70
the stack address is 0xfeec8a50
the stack address is 0xfeec8a30
i has reached zero
Program exited normally.
(gdb)

论坛徽章:
0
10 [报告]
发表于 2004-12-21 15:47 |只看该作者

初学gdb中的问题求助。

用eclipse,在里面调试也是用gdb而且全部图形化了,容易操作,也更直观一些。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP