aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Doron <arilou@gmail.com>2019-05-29 09:41:34 +0300
committerAlex Bennée <alex.bennee@linaro.org>2019-06-12 17:53:23 +0100
commit3a9651d6743778a6d0968d2a56688c98769fbda9 (patch)
tree5a279bbb53599ca5d4a2300a0a1bd67d412a4410
parentccc47d5d01a99d2eaa7fc4f10f78dde844c7d573 (diff)
gdbstub: Implement set_thread (H 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-7-arilou@gmail.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
-rw-r--r--gdbstub.c83
1 files changed, 53 insertions, 30 deletions
diff --git a/gdbstub.c b/gdbstub.c
index 25ee936a8c..aad43c075b 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1564,6 +1564,51 @@ static void handle_cont_with_sig(GdbCmdContext *gdb_ctx, void *user_ctx)
gdb_continue(gdb_ctx->s);
}
+static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx)
+{
+ CPUState *cpu;
+
+ if (gdb_ctx->num_params != 2) {
+ put_packet(gdb_ctx->s, "E22");
+ return;
+ }
+
+ if (gdb_ctx->params[1].thread_id.kind == GDB_READ_THREAD_ERR) {
+ put_packet(gdb_ctx->s, "E22");
+ return;
+ }
+
+ if (gdb_ctx->params[1].thread_id.kind != GDB_ONE_THREAD) {
+ put_packet(gdb_ctx->s, "OK");
+ return;
+ }
+
+ cpu = gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[1].thread_id.pid,
+ gdb_ctx->params[1].thread_id.tid);
+ if (!cpu) {
+ put_packet(gdb_ctx->s, "E22");
+ return;
+ }
+
+ /*
+ * Note: This command is deprecated and modern gdb's will be using the
+ * vCont command instead.
+ */
+ switch (gdb_ctx->params[0].opcode) {
+ case 'c':
+ gdb_ctx->s->c_cpu = cpu;
+ put_packet(gdb_ctx->s, "OK");
+ break;
+ case 'g':
+ gdb_ctx->s->g_cpu = cpu;
+ put_packet(gdb_ctx->s, "OK");
+ break;
+ default:
+ put_packet(gdb_ctx->s, "E22");
+ break;
+ }
+}
+
static int gdb_handle_packet(GDBState *s, const char *line_buf)
{
CPUState *cpu;
@@ -1577,7 +1622,6 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
char thread_id[16];
uint8_t *registers;
target_ulong addr, len;
- GDBThreadIdKind thread_kind;
const GdbCmdParseEntry *cmd_parser = NULL;
trace_gdbstub_io_command(line_buf);
@@ -1840,35 +1884,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
put_packet(s, "E22");
break;
case 'H':
- type = *p++;
-
- thread_kind = read_thread_id(p, &p, &pid, &tid);
- if (thread_kind == GDB_READ_THREAD_ERR) {
- put_packet(s, "E22");
- break;
- }
-
- if (thread_kind != GDB_ONE_THREAD) {
- put_packet(s, "OK");
- break;
- }
- cpu = gdb_get_cpu(s, pid, tid);
- if (cpu == NULL) {
- put_packet(s, "E22");
- break;
- }
- switch (type) {
- case 'c':
- s->c_cpu = cpu;
- put_packet(s, "OK");
- break;
- case 'g':
- s->g_cpu = cpu;
- put_packet(s, "OK");
- break;
- default:
- put_packet(s, "E22");
- break;
+ {
+ static const GdbCmdParseEntry set_thread_cmd_desc = {
+ .handler = handle_set_thread,
+ .cmd = "H",
+ .cmd_startswith = 1,
+ .schema = "o.t0"
+ };
+ cmd_parser = &set_thread_cmd_desc;
}
break;
case 'T':