From patchwork Wed Apr 20 06:49:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1619338 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=iCKjuszR; 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 4Kjrss0Fwdz9sG0 for ; Wed, 20 Apr 2022 16:50:57 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Kjrsr6dfGz2yn1 for ; Wed, 20 Apr 2022 16:50:56 +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=iCKjuszR; 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::1031; helo=mail-pj1-x1031.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=iCKjuszR; dkim-atps=neutral Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) (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 4Kjrsp369Tz2yh9 for ; Wed, 20 Apr 2022 16:50:54 +1000 (AEST) Received: by mail-pj1-x1031.google.com with SMTP id bx5so1067409pjb.3 for ; Tue, 19 Apr 2022 23:50:54 -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=UUxyziwNz4TuyrOGHpCNG3+sxYGC9S4Nqsi1P1CNy28=; b=iCKjuszRCxcBcGlavIywYUUCMG03SzgwP1nhrQ4+hiIM5NTahxrrIx/jqnN92mQdBv N/+My2Pb5FDLq5FZ0gpHV38jfuypDDRsJSbgQvEpdRJ/UD6vYJUArQkhZaw6w6xa7fHR S5KkqQUJlha34yQ48pz36NPSf1PkklVx6Gd5Yo2ri6JNVu8YkH5/RvBSIZ6budtTiyow 0LyCoscqRArUOnL5Wn2jCY4Hk3HvBJsV0vZzcox97++IgDHHQNJPBcJrAPqLXR3gCH0V qy/CsCdfn58KCRgvp/Xgmgvqe6XtLskv5iBHYkfxSSt60ODAqGvhcEhQaie1PSGWgwrV azKA== 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=UUxyziwNz4TuyrOGHpCNG3+sxYGC9S4Nqsi1P1CNy28=; b=I9hLLy9byNkXiSN3hzUmlYAh0+gaTGQbnZ1itxXraJQjrh4KDJnofKycC8TbuHv2FQ Jj2ZKGWDdFk+u3Q3pRemQDMaeu22Av7rkBVZft8nB3wM5hCmzVE/eBl5Z/pcPhEWoafD sjpPsB1qBLS3+vUb8QJCICMVXmXXP12GCTPcP38YZ1SbPOPQ5uJTPEf3itb5JrWocl3A kbO+gLqUeVu5EJOwLlLiHXKEgJFM9B3/VeukyLS4vr2u0R2fb2tvJ5mzRaGzbq/w6yx9 8d7+ZfcKBTp4LdwnikYlVQwDjRqsNL0dBK03fnojTXkUYO/yYjGSRqgXz8vx6UJRnLSK 7kjA== X-Gm-Message-State: AOAM530kIZFw9oNqldxhZFUkIqMxxT9p4Nr58zY1ZQZBkYQ60IZnjZrZ aY8D1XoSIUMgAGYFNHLYfn7teMC4rMs1Jg== X-Google-Smtp-Source: ABdhPJyUgP6poz9szKZ86fUHO6ui3Gx/4KK0Q8GvHUsCQWoRarJTaqjfOyhLBMh3GTxxnMrZnByrCA== X-Received: by 2002:a17:90a:c504:b0:1bf:6d9f:65a6 with SMTP id k4-20020a17090ac50400b001bf6d9f65a6mr2699373pjt.204.1650437452263; Tue, 19 Apr 2022 23:50:52 -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.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 23:50:51 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Wed, 20 Apr 2022 16:49:46 +1000 Message-Id: <20220420065013.222816-13-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 12/39] gdbserver: fix interrupt double stop reason response 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" The interrupt command sends a stop reason (TRAP) response, then the main loop notices that the thread was stopped and also sends a stop reason response. Prevent the second response by having the interrupt handler move the state to IDLE. Signed-off-by: Nicholas Piggin --- src/pdbgproxy.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 9e5e7d80..1668126f 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -320,11 +320,20 @@ static void v_contc(uint64_t *stack, void *priv) static void interrupt(uint64_t *stack, void *priv) { - PR_INFO("Interrupt\n"); + struct thread_state status; + + PR_INFO("Interrupt from gdb client\n"); + thread_stop(thread_target); - send_response(fd, TRAP); - return; + status = thread_status(thread_target); + if (!(status.quiesced)) { + PR_ERROR("Could not quiesce thread\n"); + return; + } + state = IDLE; + poll_interval = VCONT_POLL_DELAY; + send_response(fd, TRAP); } static void poll(void)