gdbstub: Add q-packet handling function
Add `gdb_q_packet` function to handle proccessing of query packets. Also add `gdb_qsupported` function to serve as a single place to process and respond to `qSupported` packets. Signed-off-by: Robert Zieba <robertzieba@google.com>
This commit is contained in:
parent
e410e2b740
commit
43cb0572e9
1 changed files with 29 additions and 0 deletions
|
|
@ -585,6 +585,28 @@ static int gdb_send_exception(uint8_t *buf, size_t len, uint8_t exception)
|
|||
return gdb_send_packet(buf, size);
|
||||
}
|
||||
|
||||
static bool gdb_qsupported(uint8_t *buf, size_t len, enum gdb_loop_state *next_state)
|
||||
{
|
||||
size_t n = 0;
|
||||
const char *c_buf = (const char *) buf;
|
||||
|
||||
if (strstr(buf, "qSupported") != c_buf) {
|
||||
return false;
|
||||
}
|
||||
|
||||
gdb_send_packet(buf, n);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void gdb_q_packet(uint8_t *buf, size_t len, enum gdb_loop_state *next_state)
|
||||
{
|
||||
if (gdb_qsupported(buf, len, next_state)) {
|
||||
return;
|
||||
}
|
||||
|
||||
gdb_send_packet(NULL, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously communicate with gdb on the host
|
||||
*/
|
||||
|
|
@ -809,6 +831,13 @@ int z_gdb_main_loop(struct gdb_ctx *ctx)
|
|||
ctx->exception);
|
||||
break;
|
||||
|
||||
/* Query packets*/
|
||||
case 'q':
|
||||
__fallthrough;
|
||||
case 'Q':
|
||||
gdb_q_packet(buf, sizeof(buf), &state);
|
||||
break;
|
||||
|
||||
/*
|
||||
* Not supported action
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue