URN Logo
UNIX Resources » Linux » China Linux Forum » CPU 与 编译器 » 4 » GDB中命令和它的源码的函数怎样对应的,比如 set debug remote 20
announcement 声明: 本页内容为中国Linux论坛的内容镜像,文章的版权以及其他所有的相关权利属于中国Linux论坛和相应文章的作者,如果转载,请注明文章来源及相关版权信息。
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.net
  业界新闻与评论
  自由软件杂谈
  IT 人生
  Linux软件快递
  翻译作坊
  Linux图书与评论
  GNU Emacs/XEmacs
  Linux 中文环境和中文化
  Linux桌面与办公软件
  Linux 多媒体与娱乐版
  自由之窗Mozilla
  笔记本电脑上的Linux
  Gentoo
  Debian 一族
  网络管理技术
  Linux 安装与入门
  WEB服务器和FTP服务器
  域名服务器和邮件服务器
  Linux防火墙和代理服务器应用
  文件及打印服务器
  技术培训与认证
  Linux内核技术
  Linux 嵌入技术
  Linux设备驱动程序
  Linux 集群技术
  LINUX平台数据库
  系统和网络安全
  CPU 与 编译器
  系统计算研究所专栏
  Linux下的GUI软件开发
  C/C++编程版
  PHP 技 术
  Java&jsp技术
  Shell编程技术
  Perl 编 程
  Python 编 程
  XML/Web Service 技术
  永远的Unix
  FreeBSD世界
   
GDB中命令和它的源码的函数怎样对应的,比如 set debug remote 20
 
 
 
 
 
Subject: GDB中命令和它的源码的函数怎样对应的,比如 set debug remote 20
Author: qiyoa    Posted: 2006-04-18 18:54    Length: 3,605 byte(s)
[Original] [Print] [Top]
我用gdb调试gdb,现在关心 set debug remote 20 具体做了什么,想在相应的操作位置设置断点,但是现在不知道断点设置在哪里,:(

看了代码,好像只有一个函数sr_scan_args设置了变量remote_debug, 于是就在sr_scan_args处下了断点,然后运行被调试的gdb,具体过程如下,

[@localhost gdb]$ gdb ./gdb
GNU gdb Red Hat Linux (6.3.0.0-1.21rh)
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"...Using host libthread_db library "/lib/libthread_db.so.1".

Setting up the environment for debugging gdb.
Breakpoint 1 at 0x808303a: file ../../gdb-6.4/gdb/utils.c, line 817.
Breakpoint 2 at 0x80add8a: file ../../gdb-6.4/gdb/cli/cli-cmds.c, line 189.
(top-gdb) b sr_scan_args
Breakpoint 3 at 0x80a0f38: file ../../gdb-6.4/gdb/remote-utils.c, line 112.
(top-gdb) run
Starting program: /home/qiyao/gdb/gdb-6.4-x86/gdb/gdb
Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0x6cf000
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 "i686-pc-linux-gnu".
Setting up the environment for debugging gdb.
No symbol table is loaded. Use the "file" command.
No symbol table is loaded. Use the "file" command.
.gdbinit:8: Error in sourced command file:
No breakpoint number 0.
(gdb) set debug remote 20
(gdb) target remote :1234
Remote debugging using :1234
Sending packet: $Hc-1#09...Ack
Packet received: OK
Sending packet: $qC#b4...Ack
Packet received:
Sending packet: $qOffsets#4b...Ack
Packet received:
Sending packet: $?#3f...Ack
Packet received: T0505:00000000;04:2081d1bf;08:00382400;
Sending packet: $m243800,8#02...Ack
Packet received: 89e0e86014000089
Sending packet: $m243800,7#01...Ack
Packet received: 89e0e860140000
0x00243800 in ?? ()
Sending packet: $qPart:auxv:read::0,147#48...Ack
Packet received: 2000000000b45d002100000000b05d0010000000fff3eb0f060000000010000011000000640000000300000034800408040000002000000005000000070000000700000000000000080000000000000009000000d88204080b000000f40100000c000000f40100000d000000f40100000e000000f401000017000000000000000f0000002b82d1bf0000000000000000
Packet qPart_auxv (read-aux-vector) is supported
Sending packet: $qPart:auxv:read::90,147#81...Ack
Packet received: OK
warning: Could not load vsyscall page because no executable was specified
try using the "file" command first.


被调试的gdb好像没有运行到sr_scan_args,我也不知道断点设置到什么位置才能看到,请大家指点了,谢谢!
[Original] [Print] [Top]
Subject: Re: GDB中命令和它的源码的函数怎样对应的,比如 set debug remote 20
Author: canopy    Posted: 2006-04-18 21:24    Length: 6 byte(s)
[Original] [Print] [Top]
watch?
[Original] [Print] [Top]
Subject: Re: GDB中命令和它的源码的函数怎样对应的,比如 set debug remote 20
Author: qiyoa    Posted: 2006-04-19 09:13    Length: 1,833 byte(s)
[Original] [Print] [Top]
我试过了,好像没有办法,至少我不会用watch,:(
Thanks all the same!

现在看代码,有了一点线索!

在cli/cli-cmds.c L1259,
add_setshow_zinteger_cmd ("remote", no_class, &remote_debug, _("
Set debugging of remote protocol."), _("
Show debugging of remote protocol."), _("
When enabled, each packet sent or received with the remote target
is displayed."),
NULL,
show_remote_debug,
&setdebuglist, &showdebuglist);

这个应该就是和 set debug remote 1对应的那个函数,下来add_setshow_zinteger_cmd的定义如下,

在 cli/cli-decode.c --L581,
/* Add element named NAME to both the set and show command LISTs (the
list for set/show or some sublist thereof). CLASS is as in
add_cmd. VAR is address of the variable which will contain the
value. SET_DOC and SHOW_DOC are the documentation strings. */
void
add_setshow_zinteger_cmd (char *name, enum command_class class,
int *var,
const char *set_doc, const char *show_doc,
const char *help_doc,
cmd_sfunc_ftype *set_func,
show_value_ftype *show_func,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list)

所以可以看出,相应的set_func是空的,只有在add_setshow_zinteger_cmd设置全局变量remote_debug,这个变量在remote.c , remote-utils.c到处在使用!
[Original] [Print] [Top]
Subject: Re: GDB中命令和它的源码的函数怎样对应的,比如 set debug remote 20
Author: teawater    Posted: 2006-04-19 09:30    Length: 800 byte(s)
[Original] [Print] [Top]
gdb6.3 cli-cmds.c
deprecate_cmd (c, "set debug remote");
deprecate_cmd (deprecated_add_show_from_set (c, &showlist),
"show debug remote");

deprecated_add_show_from_set
(add_set_cmd ("remote", no_class, var_zinteger,
(char *) &remote_debug,
"Set debugging of remote protocol.
When enabled, each packet sent or received with the remote target
is displayed.", &setdebuglist),
&showdebuglist);


set debug remote 20
最后修改的应该是 remote_debug 这个变量

在6.4中这种deprecate 的用法已经被换掉 不过还是看同一个文件中对 remote_debug 的操作就可以找到
----
有因就有果 洗洗就能吃
[Original] [Print] [Top]
Subject: Re: GDB中命令和它的源码的函数怎样对应的,比如 set debug remote 20
Author: qiyoa    Posted: 2006-04-22 15:31    Length: 66 byte(s)
[Original] [Print] [Top]
好的,谢谢!

我现在看的就是6.4的gdb!
[Original] [Print] [Top]
« Previous thread
找书:see mips run(英文版)
CPU 与 编译器
4
Next thread »
请问什么是交叉编译
     

Copyright © 2007 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
备案序号: 京ICP备05006143    webmaster: webmaster@unixresources.net
This page created on 2008-07-17 03:47:15, cost 0.041347026824951 ms.