From patchwork Wed Apr 20 06:50:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1619357 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=XLB/m/T/; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kjrtg3nsKz9sG0 for ; Wed, 20 Apr 2022 16:51:39 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Kjrtg1HqWz2yZf for ; Wed, 20 Apr 2022 16:51:39 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=XLB/m/T/; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::42b; helo=mail-pf1-x42b.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=XLB/m/T/; dkim-atps=neutral Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Kjrtd3N0hz2ymS for ; Wed, 20 Apr 2022 16:51:37 +1000 (AEST) Received: by mail-pf1-x42b.google.com with SMTP id a15so1076030pfv.11 for ; Tue, 19 Apr 2022 23:51:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oaQ5pJ3MjXwsMBH/CpDWzxXs3EJwynKNDVbiID0LuDY=; b=XLB/m/T/LztuFleWco5nqo5OtCQLMuDz037KAE5x/4lSXQfqOCR6xPNjp5/uOGltAo 0Bq/WWXxWH/QHc/LFpM/xAnrMN+JCCfZPYt4Grl0s8AXVjpfhVIBBDo/ibbi5cdLzBNb 7H3a8O3HcIOTXa8MZjbMBWG4FQBxSI0SSRTB2Q9bMq2MHJSYwcJ3CCzmfGcZ/ECF613X AUA9mJM18V9uW0YjJ7X05bdLjhcMovwoDjdmL6xCBOOppkmrfqtD+IEzjpcS3xK7+00G vP8wMrf42vTZkA/77Hfpi4AB+a02KngNsZRvPsIs+LbyAZTkEyWG+W1+V32VUWPOJWQ9 x0bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oaQ5pJ3MjXwsMBH/CpDWzxXs3EJwynKNDVbiID0LuDY=; b=jwvFw5M38XSUpg+fAZXtIFFwwzTXE2w+IYjf/en0x9t5h1pUTav3QCoUQvfRkxlxLm WIvnfY0s3HUMVDPmbr0VG+yeyxkqkDtkVxeaT/OZGWIyb0z8okT+diINeXsSAtd/JBEw oiuJvhYOXkjRk+lWy0i0QDFWnuo+QSomUCNhCxple4ozS/YnSMRDElCmxXP6T0U2sQFx CM5RatrPGQKoe3oybJ/mblqDmb/cAby9Pgv4L4aU0fDJilElMrImaB+PRHdhUlmtcjnk pfGyiucU+EGj5LaoKqDBKN1lzDoYv+b54BwcKjsxQG3IKdsYR1PdGDQmjp1RImsmrGZo pHWg== X-Gm-Message-State: AOAM532WMvFb4dK9ui0CJpQ+L7zbbGNOodX2kDAVP+QRujNm6Ev0lTGX 7U1Pnkk7NvTN8z+YbJV7gjejvq8dwEhhHg== X-Google-Smtp-Source: ABdhPJzcu15cdHJYIUObgnha2Ew8Xw2vPkTR/4HplQmMgQpNF2ttR8ZMCmyuXSThH2W/BAdXqZhluA== X-Received: by 2002:a05:6a00:22d3:b0:50a:9709:fbfc with SMTP id f19-20020a056a0022d300b0050a9709fbfcmr6363601pfj.74.1650437495437; Tue, 19 Apr 2022 23:51:35 -0700 (PDT) Received: from bobo.ozlabs.ibm.com ([203.221.203.144]) by smtp.gmail.com with ESMTPSA id x20-20020aa79574000000b005061f4782c5sm18481235pfq.183.2022.04.19.23.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 23:51:35 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Wed, 20 Apr 2022 16:50:04 +1000 Message-Id: <20220420065013.222816-31-npiggin@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220420065013.222816-1-npiggin@gmail.com> References: <20220420065013.222816-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 30/39] gdbserver: tidy poll() X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Remove the pointless case statement and reduce indentation. Signed-off-by: Nicholas Piggin Reviewed-by: Joel Stanley --- src/pdbgproxy.c | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 01419108..c5870091 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -708,40 +708,36 @@ static void poll(void) { struct thread_state status; + if (state != SIGNAL_WAIT) + return; + thread_target->probe(thread_target); status = thread_status(thread_target); - switch (state) { - case IDLE: - break; - - case SIGNAL_WAIT: - if (!(status.quiesced)) - break; - - set_attn(false); + if (!(status.quiesced)) + return; - state = IDLE; - poll_interval = VCONT_POLL_DELAY; + set_attn(false); - if (thread_check_attn(thread_target)) { - uint64_t nia; + state = IDLE; + poll_interval = VCONT_POLL_DELAY; - if (!(status.active)) { - PR_ERROR("Thread inactive after trap\n"); - send_response(fd, ERROR(EPERM)); - return; - } + if (thread_check_attn(thread_target)) { + uint64_t nia; - /* Restore NIA */ - if (thread_getnia(thread_target, &nia)) - PR_ERROR("Error during getnia\n"); - if (thread_putnia(thread_target, nia - 4)) - PR_ERROR("Error during putnia\n"); + if (!(status.active)) { + PR_ERROR("Thread inactive after trap\n"); + send_response(fd, ERROR(EPERM)); + return; } - send_response(fd, TRAP); - break; + + /* Restore NIA */ + if (thread_getnia(thread_target, &nia)) + PR_ERROR("Error during getnia\n"); + if (thread_putnia(thread_target, nia - 4)) + PR_ERROR("Error during putnia\n"); } + send_response(fd, TRAP); } static void cmd_default(uint64_t *stack, void *priv)