Skip to content

Commit

Permalink
gdbstub: do not split gdb_monitor_write payload
Browse files Browse the repository at this point in the history
Since we can now send packets of arbitrary length:
simplify gdb_monitor_write() and send the whole payload
in one packet.

Suggested-by: Luc Michel <luc.michel@greensocs.com>
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20191211160514.58373-3-damien.hedde@greensocs.com>
Message-Id: <20200316172155.971-28-alex.bennee@linaro.org>
  • Loading branch information
Damien Hedde authored and stsquad committed Mar 17, 2020
1 parent d116e81 commit d86b467
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions gdbstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -3200,28 +3200,11 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent event)
}
}

static void gdb_monitor_output(const char *msg, int len)
{
g_autoptr(GString) buf = g_string_new("O");
memtohex(buf, (uint8_t *)msg, len);
put_packet(buf->str);
}

static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len)
{
const char *p = (const char *)buf;
int max_sz;

max_sz = (MAX_PACKET_LENGTH / 2) + 1;
for (;;) {
if (len <= max_sz) {
gdb_monitor_output(p, len);
break;
}
gdb_monitor_output(p, max_sz);
p += max_sz;
len -= max_sz;
}
g_autoptr(GString) hex_buf = g_string_new("O");
memtohex(hex_buf, buf, len);
put_packet(hex_buf->str);
return len;
}

Expand Down

0 comments on commit d86b467

Please sign in to comment.