From patchwork Fri Jun 7 09:05:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 606DB924 for ; Fri, 7 Jun 2019 10:32:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49C7428B44 for ; Fri, 7 Jun 2019 10:32:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D6CB28B47; Fri, 7 Jun 2019 10:32:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D52D028B44 for ; Fri, 7 Jun 2019 10:32:52 +0000 (UTC) Received: from localhost ([::1]:48065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZCB2-00077Y-1N for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:32:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45011) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB51-0008BK-L0 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB50-0005tM-JO for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:35 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:44857) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB50-0005sG-BZ for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:34 -0400 Received: by mail-wr1-x42d.google.com with SMTP id b17so1381957wrq.11 for ; Fri, 07 Jun 2019 02:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rQDbySq2CCG8eAtAG40D7sD3kPayEKRs8iIxX2EaaA8=; b=bWZ2QkibamH6BQ7pb0DJez2s+LOFU1h++u+GAK2JCBKNEI0foUOlCzAFXxiKm/UPaY DfXtliZZymioa5+BM9VpP/k9o/rFLFnHqFV+EViHKdyuPgqKfNCIAUM87SYanmMSL3hr 8QOFamcIqPmFbCLZRV85JBxLOT69Nu37sOOUXDWggy/RuKdL3EWBDCRP3c1Ll+tfa8ci WKI1PDfGE9t2PvUCvcdB9wVkA0ZwOI2euZdoKtNDVM0h/9iUSSznr7MWXw2hJb6S9kRi oobXZCxIsQkW4ST1jvUubiXxqzJoB7P+9Iw4n5kmPCFN5h3ONBIfTXLJ80YfHAOtGnld F7Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rQDbySq2CCG8eAtAG40D7sD3kPayEKRs8iIxX2EaaA8=; b=HvEPm9pIZJUVW1osOuJVxvhM78SI8Yk41ICNDmWgMOF+JfP7XKqga9jw3mmjmU74+f 4cedh93ERKTX/HK92OYbAmVmqk1n2WXULZMxK1MNlohFKxuKm0Oy6IFRf9SMbqvuNtRp pkA88/jaKf0JzoH9mKNKXWrlgVUHK+u3AYUL7c9Q7jx61DcffN9HW0U7x2mLf50LqHf6 MPHC0T/fV5O7qNS+F+O35ZBWma/NcZYb6PX29OIL1OzXtIerhKp+EFQMa+MN4y3GivYd Kqz5MsQM2wll2bccrYDOCy6DriCjdtBrqcfcZMs90ZdYZI8hAsHDlARS+U2PuX/sE7mB UkIg== X-Gm-Message-State: APjAAAU6IZCYIADKfneZODzIbRMKIpJmeJjNTw6fS/t0zkmYGYfUmQUB lTT84IRUCSrQnyA+o9Yzg1jcDw== X-Google-Smtp-Source: APXvYqx8L+fB4OabjWA8AhloysFaJTN/nxZEjM7LNGY1VmmIBy507ZrbPAi1OtjSu5cyqmGd3onWEg== X-Received: by 2002:a5d:6583:: with SMTP id q3mr35496275wru.184.1559899353421; Fri, 07 Jun 2019 02:22:33 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id h84sm1575073wmf.43.2019.06.07.02.22.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id CD1B51FFBB; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:34 +0100 Message-Id: <20190607090552.12434-36-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42d Subject: [Qemu-devel] [PULL 35/52] gdbstub: Implement thread_alive (T pkt) with new infra X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Reviewed-by: Alex Bennée Message-Id: <20190529064148.19856-4-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 120e52f5d2..ad00f223f2 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1507,6 +1507,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; @@ -1807,17 +1831,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':