免费注册 查看新帖 |

Chinaunix

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

gdb远程调试遇到的问题。如果加载symbol table后,不可以调试。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-08-01 18:31 |只看该作者 |倒序浏览
遇到的问题如下:
1.如果没有加载symbol table时,  (list,break等命名不可以用)

pc端 可以continue到底
如下:
[root@localhost /]# arm-linux-gdb
GNU gdb 6.4
Copyright 2005 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 "--host=i686-pc-linux-gnu --target=arm-linux".

(gdb) target remote 172.16.16.114:1111
Remote debugging using 172.16.16.114:1111
0x400009f0 in ?? ()
(gdb) c
Continuing.

Program exited with code 061.

目标端如下:
# ./gdbserver 172.16.16.119:1111 lmjtest
Process lmjtest created; pid = 238
Listening on port 1111
Remote debugging from host 172.16.16.119
the first string is Hello gdbserver!

Child exited with retcode = 25

Child exited with status 37
GDBserver exiting


2如果加载了 symbol table时, list,break命令可以用,但是continue不可以用

pc端:
[root@localhost /]# arm-linux-gdb
GNU gdb 6.4
Copyright 2005 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 "--host=i686-pc-linux-gnu --target=arm-linux".
(gdb) file /home/mjliu/program/lmjtest
Reading symbols from /home/mjliu/program/lmjtest...done.
(gdb) target remote 172.16.16.114:1111
Remote debugging using 172.16.16.114:1111
0x400009f0 in ?? ()
(gdb) b main
Breakpoint 1 at 0x8598: file lmjtest.c, line 5.
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint -2.
Error accessing memory address 0x4000e890: Input/output error.

(gdb) n
Cannot access memory at address 0x0
Cannot find bounds of current function
(gdb) n
Cannot find bounds of current function
(gdb) n
Cannot find bounds of current function
(gdb) s
Cannot find bounds of current function
(gdb) quit
The program is running.  Exit anyway? (y or n) y


目标端如下:
# ./gdbserver 172.16.16.119:1111 lmjtest
Process lmjtest created; pid = 236
Listening on port 1111
Remote debugging from host 172.16.16.119
Killing inferior

论坛徽章:
0
2 [报告]
发表于 2007-08-02 13:36 |只看该作者
你所描述的第一种情况根本不能叫调试。

你所描述的第二种情况也不能叫“continue不可以用”。

当你用break命令插入一个断点时,这个断点只是被加入了gdb的断点链表,而并没有实际写入
被调程序的代码空间。只有当你输入continue、next、step等其它使得被调程序继续运行起来
的命令时,这个断点才会被写入被调程序。因此,你的问题是出在这个断点地址上。

(gdb) c
Continuing.
Warning:
Cannot insert breakpoint -2.
Error accessing memory address 0x4000e890: Input/output error.

这个错误应该是gdbserver调ptrace操作内存的时候返回的:

       EIO    request is invalid, or an attempt was made to read from or write to an invalid area in the  parent's  or
              child's  memory,  or  there  was a word-alignment violation, or an invalid signal was specified during a
              restart request.

看一下你的程序有没有出现上述问题的可能。

如果需要进一步分析,可以看一下你的被调程序的objdump的结果,确认一下main函数第一条
实际指令的地址是多少,或者干脆把结果贴出来。

在启动gdb之后,set debug remote 1,把结果发上来。

如果可以编译gdbserver,可以把linux-low.c里的debug_threads打开,重新编译一下,再把目标端的
打印贴出来。

一般来说,应该只是环境配置问题。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP