Re: Remote protocol question: the documentation says '?' is not required, but maybe it is?

Reuben Thomas
2020-07-21T20:49:02Z

On Tue, 21 Jul 2020 at 21:26, Reuben Thomas <rrt@sc3d.org> wrote:

> On Tue, 21 Jul 2020 at 21:24, Reuben Thomas <rrt@sc3d.org> wrote:
>
>> On Tue, 21 Jul 2020 at 20:34, Maciej W. Rozycki <macro@wdc.com> wrote:
>>
>>> On Tue, 21 Jul 2020, Reuben Thomas wrote:
>>>
>>> > > FYI, I do believe `?' is indeed mandatory, as GDB needs to figure
>>> out the
>>> > > initial state of the remote target as it has connected to it, and
>>> there is
>>> > > no other way.
>>> >
>>> > It seems to be more complicated than that. In principle, '?' isn't
>>> needed
>>> > in principle to figure out the initial state: the T packet, or in my
>>> > current case, the S packet tells GDB the signal, and yet GDB still
>>> asks for
>>> > it again with '?'. The signal that caused the remote to halt is not
>>> going
>>> > to change until the next 'c', so there's no need for GDB to ask for it
>>> > again; and yet it does.
>>>
>>
> As I mentioned earlier, gdb discards this first 'T' packet, so that
> explains why it needs to send '?', even in principle. But that doesn't seem
> to be relevant, as gdb always sends '?' at the start of a conversation.
>

Just to eliminate this source of potential error, I adjusted my stub so
that when it first connects to gdb it does not send a packet. This does not
change the exchange with gdb in any way, except that the first packet from
the stub is not sent.