[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 06/20] gdbstub: Implement set_thread (H pkt) with
From: |
arilou |
Subject: |
[Qemu-devel] [PATCH v3 06/20] gdbstub: Implement set_thread (H pkt) with new infra |
Date: |
Wed, 24 Apr 2019 17:27:00 +0300 |
From: Jon Doron <address@hidden>
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 eaa42713ac..87b364b1d0 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1563,6 +1563,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;
@@ -1576,7 +1617,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;
trace_gdbstub_io_command(line_buf);
@@ -1838,35 +1878,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 GdbCmdParseEntry set_thread_cmd_desc = {
+ .handler = handle_set_thread,
+ .cmd = "H",
+ .cmd_startswith = 1,
+ .schema = "o.t0"
+ };
+ process_string_cmd(s, NULL, line_buf, &set_thread_cmd_desc, 1);
}
break;
case 'T':
--
2.20.1
- [Qemu-devel] [PATCH v3 18/20] gdbstub: Implement generic query (q pkt) with new infra, (continued)
- [Qemu-devel] [PATCH v3 18/20] gdbstub: Implement generic query (q pkt) with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 17/20] gdbstub: Implement v commands with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 16/20] gdbstub: Implement step (s pkt) with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 14/20] gdbstub: Implement read all registers (g pkt) with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 20/20] gdbstub: Refactor parse handle packet to work with a static array, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 15/20] gdbstub: Implement file io (F pkt) with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 10/20] gdbstub: Implement get register (p pkt) with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 07/20] gdbstub: Implement insert breakpoint (Z pkt) with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 06/20] gdbstub: Implement set_thread (H pkt) with new infra,
arilou <=
- [Qemu-devel] [PATCH v3 05/20] gdbstub: Implement continue with signal (C pkt) with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 08/20] gdbstub: Implement remove breakpoint (z pkt) with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 02/20] gdbstub: Implement deatch (D pkt) with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 13/20] gdbstub: Implement write all registers (G pkt) with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 12/20] gdbstub: Implement read memory (m pkt) with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 11/20] gdbstub: Implement write memory (M pkt) with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 09/20] gdbstub: Implement set register (P pkt) with new infra, arilou, 2019/04/24
- [Qemu-devel] [PATCH v3 04/20] gdbstub: Implement continue (c pkt) with new infra, arilou, 2019/04/24