* Commands for a minimal GDB stub?
@ 2015-11-24 13:38 Clifford Wolf
2015-11-24 13:51 ` Tristan Gingold
0 siblings, 1 reply; 5+ messages in thread
From: Clifford Wolf @ 2015-11-24 13:38 UTC (permalink / raw)
To: gdb
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Commands for a minimal GDB stub?
2015-11-24 13:38 Commands for a minimal GDB stub? Clifford Wolf
@ 2015-11-24 13:51 ` Tristan Gingold
2015-11-24 14:38 ` Clifford Wolf
0 siblings, 1 reply; 5+ messages in thread
From: Tristan Gingold @ 2015-11-24 13:51 UTC (permalink / raw)
To: Clifford Wolf; +Cc: gdb
> On 24 Nov 2015, at 14:38, Clifford Wolf <clifford@clifford.at> wrote:
>
> 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):
[…]
> 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?
I think the documentation is slightly incorrect. For an almost minimal
gdb stub, I have also implemented:
?, z, Z, qSupported, qC, qSymbol::, P, k, H
z, Z, H, k, qSupported returned $#00.
You shouldn’t be very far from having a communication.
Tristan.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Commands for a minimal GDB stub?
2015-11-24 13:51 ` Tristan Gingold
@ 2015-11-24 14:38 ` Clifford Wolf
2015-11-24 16:41 ` Tristan Gingold
0 siblings, 1 reply; 5+ messages in thread
From: Clifford Wolf @ 2015-11-24 14:38 UTC (permalink / raw)
To: Tristan Gingold; +Cc: gdb
On Tue, Nov 24, 2015 at 02:51:49PM +0100, Tristan Gingold wrote:
> I think the documentation is slightly incorrect. For an almost minimal
> gdb stub, I have also implemented:
> ?, z, Z, qSupported, qC, qSymbol::, P, k, H
> z, Z, H, k, qSupported returned $#00.
>
> You shouldnât be very far from having a communication.
thanks. I've now added 'S05' as response to '?' and now I get to the point
where gdb actually queries the register file using the 'g' command. So I
think I'm now where the actual work starts.. ;)
again, thanks a lot for your help!
kind regards,
- clifford
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Commands for a minimal GDB stub?
2015-11-24 14:38 ` Clifford Wolf
@ 2015-11-24 16:41 ` Tristan Gingold
2015-11-30 20:58 ` Juha Aaltonen
0 siblings, 1 reply; 5+ messages in thread
From: Tristan Gingold @ 2015-11-24 16:41 UTC (permalink / raw)
To: Clifford Wolf; +Cc: gdb
> On 24 Nov 2015, at 15:38, Clifford Wolf <clifford@clifford.at> wrote:
>
> On Tue, Nov 24, 2015 at 02:51:49PM +0100, Tristan Gingold wrote:
>> I think the documentation is slightly incorrect. For an almost minimal
>> gdb stub, I have also implemented:
>> ?, z, Z, qSupported, qC, qSymbol::, P, k, H
>> z, Z, H, k, qSupported returned $#00.
>>
>> You shouldn’t be very far from having a communication.
>
> thanks. I've now added 'S05' as response to '?' and now I get to the point
> where gdb actually queries the register file using the 'g' command. So I
> think I'm now where the actual work starts.. ;)
>
> again, thanks a lot for your help!
You’re welcome. Note there are a few examples of stubs within gdb/stubs.
Tristan.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Commands for a minimal GDB stub?
2015-11-24 16:41 ` Tristan Gingold
@ 2015-11-30 20:58 ` Juha Aaltonen
0 siblings, 0 replies; 5+ messages in thread
From: Juha Aaltonen @ 2015-11-30 20:58 UTC (permalink / raw)
To: gdb-mailing list
In case it's of any help, I've been writing a bit more than minimal
bare metal standalone stub/server/agent/whatchacallit for Raspberry Pi
2B (Cortex-A7).
It might be helpful if you are wondering about details of the remote
serial protocol.
https://github.com/turboscrew/rpi_stub
On Tue, Nov 24, 2015 at 6:41 PM, Tristan Gingold <gingold@adacore.com> wrote:
>
>> On 24 Nov 2015, at 15:38, Clifford Wolf <clifford@clifford.at> wrote:
>>
>> On Tue, Nov 24, 2015 at 02:51:49PM +0100, Tristan Gingold wrote:
>>> I think the documentation is slightly incorrect. For an almost minimal
>>> gdb stub, I have also implemented:
>>> ?, z, Z, qSupported, qC, qSymbol::, P, k, H
>>> z, Z, H, k, qSupported returned $#00.
>>>
>>> You shouldn’t be very far from having a communication.
>>
>> thanks. I've now added 'S05' as response to '?' and now I get to the point
>> where gdb actually queries the register file using the 'g' command. So I
>> think I'm now where the actual work starts.. ;)
>>
>> again, thanks a lot for your help!
>
> You’re welcome. Note there are a few examples of stubs within gdb/stubs.
>
> Tristan.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-11-30 20:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-24 13:38 Commands for a minimal GDB stub? Clifford Wolf
2015-11-24 13:51 ` Tristan Gingold
2015-11-24 14:38 ` Clifford Wolf
2015-11-24 16:41 ` Tristan Gingold
2015-11-30 20:58 ` Juha Aaltonen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).