gdbstub: Implement thread_alive (T pkt) with new infra

Signed-off-by: Jon Doron <arilou@gmail.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20190529064148.19856-4-arilou@gmail.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
This commit is contained in:
Jon Doron 2019-05-29 09:41:31 +03:00 committed by Alex Bennée
parent 3e2c12615b
commit 44ffded013

View File

@ -1511,6 +1511,30 @@ static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx)
put_packet(s, "OK"); put_packet(s, "OK");
} }
static void handle_thread_alive(GdbCmdContext *gdb_ctx, void *user_ctx)
{
CPUState *cpu;
if (!gdb_ctx->num_params) {
put_packet(gdb_ctx->s, "E22");
return;
}
if (gdb_ctx->params[0].thread_id.kind == GDB_READ_THREAD_ERR) {
put_packet(gdb_ctx->s, "E22");
return;
}
cpu = gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[0].thread_id.pid,
gdb_ctx->params[0].thread_id.tid);
if (!cpu) {
put_packet(gdb_ctx->s, "E22");
return;
}
put_packet(gdb_ctx->s, "OK");
}
static int gdb_handle_packet(GDBState *s, const char *line_buf) static int gdb_handle_packet(GDBState *s, const char *line_buf)
{ {
CPUState *cpu; CPUState *cpu;
@ -1811,17 +1835,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
} }
break; break;
case 'T': case 'T':
thread_kind = read_thread_id(p, &p, &pid, &tid); {
if (thread_kind == GDB_READ_THREAD_ERR) { static const GdbCmdParseEntry thread_alive_cmd_desc = {
put_packet(s, "E22"); .handler = handle_thread_alive,
break; .cmd = "T",
} .cmd_startswith = 1,
cpu = gdb_get_cpu(s, pid, tid); .schema = "t0"
};
if (cpu != NULL) { cmd_parser = &thread_alive_cmd_desc;
put_packet(s, "OK");
} else {
put_packet(s, "E22");
} }
break; break;
case 'q': case 'q':