From patchwork Wed Apr 24 14:26:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1090166 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="P1Et8lnc"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44q2t7277Xz9sD4 for ; Thu, 25 Apr 2019 00:35:39 +1000 (AEST) Received: from localhost ([127.0.0.1]:42617 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJIzn-0004kg-UH for incoming@patchwork.ozlabs.org; Wed, 24 Apr 2019 10:35:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJIyy-0004hj-FD for qemu-devel@nongnu.org; Wed, 24 Apr 2019 10:34:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJIrx-0000NS-5G for qemu-devel@nongnu.org; Wed, 24 Apr 2019 10:27:30 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:35029) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hJIrw-0000Mc-VQ for qemu-devel@nongnu.org; Wed, 24 Apr 2019 10:27:29 -0400 Received: by mail-wm1-x343.google.com with SMTP id y197so5377928wmd.0 for ; Wed, 24 Apr 2019 07:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sqCWStzfcMsu/tEXfh9fQdnW8vNIxC4MXrF6FZGiMas=; b=P1Et8lnck0wntDh1ayJdW/2NS2E0yN89+RKpnCyihUZNjMH5ZOJbIANhr9EMrWB3L5 ti+qRqCtMigjdQY+Iis7tBCiRsKqlXFeN9rAlQy0rfEb4AL6hNn4uTxjxb1QSZKYe/+H EIuGwhVy1X4lD24iGMS15eEZ5oA1VileXCpxyMRAYPAP0SgfYT8YouyqFYLLudb64N1T vrSUrsRBlF4wAQ6s+9AXKrbKN+QruR3ykXGFah/uuITe00tBbuMmAMvCLx6kNCBm0aT5 KTVyENeYOawt0MHo1o4JMsMUzhOfC/Bvwy6d9Ye9Y1zWIwD22bMSVwUBYhYCu/W/8jrh RtpQ== 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=sqCWStzfcMsu/tEXfh9fQdnW8vNIxC4MXrF6FZGiMas=; b=W4IZ3nA10lcdpyTAeaPLQQ0Nmt7D3pxlxMq2WxNj1Xp/djiReT1KiANgR1xnL35xPS qk18zGpMUmsxQUzrm6KZQ18w9iq0Rl4XfISrc/fKyC/VM9paX3GQwZRn3B7be1stEA7Q wrAHzWvw1TIZzAeT3OTC4P+x2NHGMCGGQY747ziiraa3a0V9XCDlDnXSvL0BikTHa31T FxXHzSYd+f7gR/DE4+LFUhKQDACfG3yRQ2S2qH31l2f0q46VXrjiLJNYQCCOqZrEW/32 tHamHbrjRD/SwOVo799AczuzCx/rt7cU10Z5rs+eKAMmJusJ7+Hw8mRf5PoIg1DsGhTj 1KcQ== X-Gm-Message-State: APjAAAVFviKhThEZCXxdTaK52sTVQyM/PjyuEMeYPwSBrz1cilmMHxcI EqnYLqHYFDxoY8AwslrXNfNDK/Bz X-Google-Smtp-Source: APXvYqzK5Ff77NwLwvg1k/Vao2nfGjplriub4Ws4szTtL+ZVxf+tXg4yxyyOGvxWuDdBFZEMzUORbw== X-Received: by 2002:a1c:6587:: with SMTP id z129mr6590092wmb.84.1556116047221; Wed, 24 Apr 2019 07:27:27 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id q7sm5518041wmc.11.2019.04.24.07.27.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2019 07:27:26 -0700 (PDT) From: arilou@gmail.com To: qemu-devel@nongnu.org Date: Wed, 24 Apr 2019 17:26:57 +0300 Message-Id: <20190424142714.28460-3-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190424142714.28460-1-arilou@gmail.com> References: <20190424142714.28460-1-arilou@gmail.com> 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::343 Subject: [Qemu-devel] [PATCH v3 03/20] gdbstub: Implement thread_alive (T pkt) with new infra X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jon Doron Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: 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 34e6722a8c..435b492b4f 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1514,6 +1514,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; @@ -1813,17 +1837,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 GdbCmdParseEntry thread_alive_cmd_desc = { + .handler = handle_thread_alive, + .cmd = "T", + .cmd_startswith = 1, + .schema = "t0" + }; + process_string_cmd(s, NULL, line_buf, &thread_alive_cmd_desc, 1); } break; case 'q':