From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:60203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJePE-0007vO-W9 for qemu-devel@nongnu.org; Thu, 25 Apr 2019 09:27:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJePE-0000Lc-2C for qemu-devel@nongnu.org; Thu, 25 Apr 2019 09:27:16 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:36420) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hJePD-0000KJ-Sa for qemu-devel@nongnu.org; Thu, 25 Apr 2019 09:27:16 -0400 Received: by mail-wr1-x441.google.com with SMTP id b1so19006421wru.3 for ; Thu, 25 Apr 2019 06:27:15 -0700 (PDT) From: Jon Doron Date: Thu, 25 Apr 2019 16:26:18 +0300 Message-Id: <20190425132636.31636-4-arilou@gmail.com> In-Reply-To: <20190425132636.31636-1-arilou@gmail.com> References: <20190425132636.31636-1-arilou@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v6 03/21] gdbstub: Implement thread_alive (T pkt) with new infra List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jon Doron Signed-off-by: Jon Doron --- gdbstub.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index fdad1ac466..29ca6be3df 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1499,6 +1499,30 @@ static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx) 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) { CPUState *cpu; @@ -1799,17 +1823,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'T': - thread_kind = read_thread_id(p, &p, &pid, &tid); - if (thread_kind == GDB_READ_THREAD_ERR) { - put_packet(s, "E22"); - break; - } - cpu = gdb_get_cpu(s, pid, tid); - - if (cpu != NULL) { - put_packet(s, "OK"); - } else { - put_packet(s, "E22"); + { + static const GdbCmdParseEntry thread_alive_cmd_desc = { + .handler = handle_thread_alive, + .cmd = "T", + .cmd_startswith = 1, + .schema = "t0" + }; + cmd_parser = &thread_alive_cmd_desc; } break; case 'q': -- 2.20.1