|
|
|
|
| GDB中命令和它的源码的函数怎样对应的,比如 set debug remote 20 |
 GDB中命令和它的源码的函数怎样对应的,比如 set debug remote 20 - qiyoa [ 2006-04-18 18:54 | 3,605 byte(s)]
 Re: GDB中命令和它的源码的函数怎样对应的,比如 set debug remote 20 - teawater [ 2006-04-19 09:30 | 800 byte(s)]
 Re: GDB中命令和它的源码的函数怎样对应的,比如 set debug remote 20 - qiyoa [ 2006-04-22 15:31 | 66 byte(s)]
 Re: GDB中命令和它的源码的函数怎样对应的,比如 set debug remote 20 - canopy [ 2006-04-18 21:24 | 6 byte(s)]
 Re: GDB中命令和它的源码的函数怎样对应的,比如 set debug remote 20 - qiyoa [ 2006-04-19 09:13 | 1,833 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]
|
|
[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]
|
|
[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]
|
|
|