[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v9 06/27] gdbstub: Implement set_thread (H pkt) with
From: |
Jon Doron |
Subject: |
[Qemu-devel] [PATCH v9 06/27] gdbstub: Implement set_thread (H pkt) with new infra |
Date: |
Thu, 2 May 2019 11:15:33 +0300 |
Signed-off-by: Jon Doron <address@hidden>
---
gdbstub.c | 79 ++++++++++++++++++++++++++++++++++---------------------
1 file changed, 49 insertions(+), 30 deletions(-)
diff --git a/gdbstub.c b/gdbstub.c
index 469aaeb875..21cdaf4678 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1547,6 +1547,47 @@ 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;
+ }
+
+ 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;
@@ -1560,7 +1601,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);
@@ -1823,35 +1863,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':
--
2.20.1
- Re: [Qemu-devel] [PATCH v9 14/27] gdbstub: Implement read all registers (g pkt) with new infra, (continued)
[Qemu-devel] [PATCH v9 10/27] gdbstub: Implement get register (p pkt) with new infra, Jon Doron, 2019/05/02
[Qemu-devel] [PATCH v9 09/27] gdbstub: Implement set register (P pkt) with new infra, Jon Doron, 2019/05/02
[Qemu-devel] [PATCH v9 17/27] gdbstub: Implement v commands with new infra, Jon Doron, 2019/05/02
[Qemu-devel] [PATCH v9 06/27] gdbstub: Implement set_thread (H pkt) with new infra,
Jon Doron <=
[Qemu-devel] [PATCH v9 22/27] gdbstub: Implement generic query qemu.Supported, Jon Doron, 2019/05/02
[Qemu-devel] [PATCH v9 07/27] gdbstub: Implement insert breakpoint (Z pkt) with new infra, Jon Doron, 2019/05/02
[Qemu-devel] [PATCH v9 20/27] gdbstub: Implement target halted (? pkt) with new infra, Jon Doron, 2019/05/02