From patchwork Tue Mar 29 15:49:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1610711 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=QqE7s5qH; 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 4KSYtr5x3wz9sFk for ; Wed, 30 Mar 2022 02:50:44 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KSYtr5Rwrz2xBK for ; Wed, 30 Mar 2022 02:50:44 +1100 (AEDT) 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=QqE7s5qH; 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::62a; helo=mail-pl1-x62a.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=QqE7s5qH; dkim-atps=neutral Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) (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 4KSYtp19cpz2yJQ for ; Wed, 30 Mar 2022 02:50:42 +1100 (AEDT) Received: by mail-pl1-x62a.google.com with SMTP id i11so18039780plr.1 for ; Tue, 29 Mar 2022 08:50:42 -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=oZpMib/GIUYvVKRjtCGrdWvB2vEcG8hIKKgZ+PcM9jI=; b=QqE7s5qHAsotFIHEaTJWiJRBDpu+CFJkl9EOA/UBFsocX1zOJVUt9B+ySe6pMTxN6A FKIqM1ksdlAAl+HM26ODHkzfKQvnFv7iC0wFjN9POdR7f9kGP/FKAQNApQX86NqZ9kgV VLT2+1G+axIwqZRcZOU78sR9urwIETaAQC7uovMsut9RaZ0+f61HDPpgsPdwUOe1Ssju zJdQa79mcRqX0hL8AMCk6V0D9tdAZjAZnyN/rT7kQsV0DJFf5GkXIN04y2ArEQAiu7kg fpEFCw/4Qz/c1Z+pjZiNyuROcwYi8ZDpqqzF/E12Rru21lm+3FKD9U4bjpiIUajY5vHa b2UQ== 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=oZpMib/GIUYvVKRjtCGrdWvB2vEcG8hIKKgZ+PcM9jI=; b=LtPkDB0UeuC2UK/9CYI5OaJ32jVDj9dgNqDaeQ+MaT8Witw0EJw2Ko4dqQjR6egpsf bqDxEHJ0KqXdERyg21lercg9V7TKN+QQp2V/oIcdKVx4aoeItOxTSolsqnueEb0s+HNi kYiMmlbBPIxDpr4RXyqInw68WwlC2zLoZDNSrvPKbW3SVwhtoxj3ffPkKfBqVKCpHld/ ZVGz0BnA0vYXku5Ni9DM3kg2Gnx3kKJAsh9kk55wmi2PooVkocylomyttPrZriUZ+ohy mHYQ9d4cQI5utYs43N90Zp4QMgK1zs35ubYzx9gZhZbqV+6zRi7vDpUKATontq1Ztbov qH/A== X-Gm-Message-State: AOAM530ApAygxsMMKzc7rXobBhLpjI6siDCw8nghfiZDLEl58YkeYhLr 7WSx4KRztKK77HrVfRY38Sb2wZ2BPv4= X-Google-Smtp-Source: ABdhPJwqzu+1eak9Efov0jRILxwVqcjOa01LtcAxD6R1E1cK27ygZfA8Xlwy1jZDP/LkZ3HjfTc7cA== X-Received: by 2002:a17:902:c944:b0:154:38b8:aa46 with SMTP id i4-20020a170902c94400b0015438b8aa46mr31211039pla.144.1648569040389; Tue, 29 Mar 2022 08:50:40 -0700 (PDT) Received: from bobo.ibm.com (58-6-255-110.tpgi.com.au. [58.6.255.110]) by smtp.gmail.com with ESMTPSA id s35-20020a056a001c6300b004fb20b5d6c1sm14163564pfw.40.2022.03.29.08.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Mar 2022 08:50:40 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Wed, 30 Mar 2022 01:49:22 +1000 Message-Id: <20220329154931.493851-30-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220329154931.493851-1-npiggin@gmail.com> References: <20220329154931.493851-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 29/38] 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 --- src/pdbgproxy.c | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 139b29e..d34a64e 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)