[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] gdbstub: implement remote debugging protocol es
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH] gdbstub: implement remote debugging protocol escapes for command receive |
Date: |
Mon, 8 May 2017 10:01:10 +0100 |
On Sun, May 7, 2017 at 4:26 PM, Doug Gale <address@hidden> wrote:
> On Fri, May 5, 2017 at 10:45 AM, Stefan Hajnoczi <address@hidden> wrote:
>> On Tue, May 02, 2017 at 10:32:40AM -0400, Doug Gale wrote:
>>> + } else {
>>> + /* decode repeat length */
>>> + int repeat = (unsigned char)ch - ' ' + 3;
>>> + if (s->line_buf_index + repeat >= sizeof(s->line_buf) - 1)
>>> {
>>> + /* that many repeats would overrun the command buffer
>>> */
>>> +#ifdef DEBUG_GDB
>>> + printf("gdbstub command buffer overrun,"
>>> + " dropping command\n");
>>> +#endif
>>> + s->state = RS_IDLE;
>>> + } else if (s->line_buf_index <= 2) {
>>
>> Why s->line_buf_index <= 2? I expected s->line_buf_index < 1 since we
>> just need 1 character to clone for run-length decoding.
>
> Yes, on second thought, <= 2 is off by one. [0] would be the '$', [1]
> would be the repeated character, and [2] would be the '*'.
'$' and '*' are not placed into line_buf[] and do not increment
line_buf_index. They don't count.
I think the correct condition is line_buf_index < 1 so that the
following input from the GDB documentation parses: "$0* " -> "0000".
https://sourceware.org/gdb/onlinedocs/gdb/Overview.html