This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Commands for a minimal GDB stub?


Hi,

I'm trying to write a minimal GDB stub. The documentation states that it is
sufficient to implement the g, G, m, M, c, and s commands and that $#00
should be returned for any command not supported by the stub:

	https://sourceware.org/gdb/onlinedocs/gdb/Overview.html

I've now started by implementing a minimal stub that just returns $#00 to
everything. This is the conversation my stub is having with gdb (not
showing the '+' acknowledgments, '->' for packets from gdb and '<-' for
packets from my stub):

	-> $qSupported:multiprocess+;xmlRegisters=i386;qRelocInsn+#b5
	<- $#00
	-> $Hg0#df
	<- $#00
	-> $qTStatus#49
	<- $#00
	-> $?#3f
	<- $#00
	-> $Hc-1#09
	<- $#00
	-> $qC#b4
	<- $#00
	-> $qAttached#8f
	<- $#00

On the GDB console I see the following (it just hangs after the "Invalid
remote reply:"):

	(gdb) target remote :1234
	Remote debugging using :1234
	warning: Invalid remote reply: 

Note that none of the commands gdb sent is g, G, m, M, c, or s. So sending
those empty replies should be fine, according to the documentation!

And here is the same conversation between gdb and my stub, as recorded by wireshark:

	00000000  2b                                               +
	00000001  24 71 53 75 70 70 6f 72  74 65 64 3a 6d 75 6c 74 $qSupported:mult
	00000011  69 70 72 6f 63 65 73 73  2b 3b 78 6d 6c 52 65 67 iprocess+;xmlReg
	00000021  69 73 74 65 72 73 3d 69  33 38 36 3b 71 52 65 6c isters=i386;qRel
	00000031  6f 63 49 6e 73 6e 2b 23  62 35                   ocInsn+#b5
	    00000000  2b                                               +
	    00000001  24                                               $
	    00000002  23                                               #
	    00000003  30                                               0
	    00000004  30                                               0
	0000003B  2b                                               +
	0000003C  24 48 67 30 23 64 66                             $Hg0#df
	    00000005  2b                                               +
	    00000006  24 23 30 30                                      $#00
	00000043  2b                                               +
	00000044  24 71 54 53 74 61 74 75  73 23 34 39             $qTStatus#49
	    0000000A  2b                                               +
	    0000000B  24 23 30 30                                      $#00
	00000050  2b                                               +
	00000051  24 3f 23 33 66                                   $?#3f
	    0000000F  2b                                               +
	    00000010  24 23 30 30                                      $#00
	00000056  2b                                               +
	00000057  24 48 63 2d 31 23 30 39                          $Hc-1#09 
	    00000014  2b                                               +
	    00000015  24 23 30 30                                      $#00
	0000005F  2b                                               +
	00000060  24 71 43 23 62 34                                $qC#b4
	    00000019  2b                                               +
	    0000001A  24 23 30 30                                      $#00
	00000066  2b                                               +
	00000067  24 71 41 74 74 61 63 68  65 64 23 38 66          $qAttached#8f
	    0000001E  2b                                               +
	    0000001F  24 23 30 30                                      $#00
	00000074  2b                                               +

I did compare that to what I record when gdb is talking to gdbserver, and
the general syntax seems to be the same, meaning I don't think I have
screwed up implementing the low-level protocol..

Is the documentation correct and I only need to implement g, G, m, M, c,
and s? If so: What did I do wrong?

Your help is very appreciated!

thanks,
 - clifford


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]