gdbstub: Implement target halted (? pkt) with new infra

Note: The user-mode thread-id has been correctly reported since bd88c780e6

Signed-off-by: Jon Doron <arilou@gmail.com>
Message-Id: <20190529064148.19856-19-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:46 +03:00 committed by Alex Bennée
parent 2704efad51
commit 7009d57924

View File

@ -2269,13 +2269,29 @@ static void handle_gen_set(GdbCmdContext *gdb_ctx, void *user_ctx)
} }
} }
static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx)
{
char thread_id[16];
gdb_fmt_thread_id(gdb_ctx->s, gdb_ctx->s->c_cpu, thread_id,
sizeof(thread_id));
snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;",
GDB_SIGNAL_TRAP, thread_id);
put_packet(gdb_ctx->s, gdb_ctx->str_buf);
/*
* Remove all the breakpoints when this query is issued,
* because gdb is doing an initial connect and the state
* should be cleaned up.
*/
gdb_breakpoint_remove_all();
}
static int gdb_handle_packet(GDBState *s, const char *line_buf) static int gdb_handle_packet(GDBState *s, const char *line_buf)
{ {
const char *p; const char *p;
int ch; int ch;
uint8_t mem_buf[MAX_PACKET_LENGTH]; uint8_t mem_buf[MAX_PACKET_LENGTH];
char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */];
char thread_id[16];
const GdbCmdParseEntry *cmd_parser = NULL; const GdbCmdParseEntry *cmd_parser = NULL;
trace_gdbstub_io_command(line_buf); trace_gdbstub_io_command(line_buf);
@ -2287,15 +2303,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
put_packet(s, "OK"); put_packet(s, "OK");
break; break;
case '?': case '?':
/* TODO: Make this return the correct value for user-mode. */ {
snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, static const GdbCmdParseEntry target_halted_cmd_desc = {
gdb_fmt_thread_id(s, s->c_cpu, thread_id, sizeof(thread_id))); .handler = handle_target_halt,
put_packet(s, buf); .cmd = "?",
/* Remove all the breakpoints when this query is issued, .cmd_startswith = 1
* because gdb is doing and initial connect and the state };
* should be cleaned up. cmd_parser = &target_halted_cmd_desc;
*/ }
gdb_breakpoint_remove_all();
break; break;
case 'c': case 'c':
{ {