From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sMC4HKMyK2g2NyoAWB0awg (envelope-from ) for ; Mon, 19 May 2025 09:31:15 -0400 Received: by simark.ca (Postfix, from userid 112) id 7262A1E11C; Mon, 19 May 2025 09:31:15 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.0 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0CC401E102 for ; Mon, 19 May 2025 09:31:15 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D20FC3857B96 for ; Mon, 19 May 2025 13:31:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D20FC3857B96 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by sourceware.org (Postfix) with ESMTPS id 28D233858023 for ; Mon, 19 May 2025 13:24:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 28D233858023 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 28D233858023 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747661044; cv=none; b=fjDULEdJuLIIRA42zCdbYk5L1Jdle7f0/tgxYrCvOYdb2zHb3PI8WumLHNZMIbGGfrHBlUDEDftHP0JNTP1q15Pj8+thDScHMQTk50GxRvttgRdg3nTf5pUeKJbukKx9yyOfN8UHRqYnGxlwByzHkGw3U/sDCaxZV1L9i/MMCww= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747661044; c=relaxed/simple; bh=11mukZhVLtpJdAynxRdvEPpFJHiIJEqF8AHUX5zmMzQ=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=ovX9+dy/g7HbPGMfm6v3q1gej3nBB+AIuBOeiznWWrWcQA1hM8xxNnOnpZor4X5ZwbeZI89LQeKJpW21mtVuNKFBJ4rIFJS68aX1MoKOT00g/98H3fwk2bbnQ24yyC2bhQZEIThIZbwDy6JVVWKdfmw5alHEpTMolNeVxBBpF78= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 28D233858023 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-3a3771c0f8cso137521f8f.3 for ; Mon, 19 May 2025 06:24:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747661043; x=1748265843; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ac/ihYwGUaYRuwzZORR8moB16CMr+eIeEnW2gsJbTdY=; b=OE4vK6/ipOuochI/Dp4utwUQ2zfgsE90ET0DZGZiSUyWqVXbaCgGfSuiPhu+7HCMVo rzkHyeTKkhe6FJbEZ8vLzPUkalH1fB7lvE0lOXfDwg+BL+B0xbnwV7ooqjQePgWTzEJY pnxg/zJolPoCxRDlP0MriQ82CF6EZq+0ExF1m0sai8qsseu4VSXCgJPUKjn55MNvSU5d jCecZwfvnwof/t49pNSYMt9jBqckXH4O4cFqP8h7b9onrgitgnkthxgTWQIKtTqgly3U gYvbCZD5OBtlgblSYtj4BLjPc2GZ8Ed6OqwpX+QFuFrB/kGCYsUZlLIbDwnOcDM0ESNG I3UQ== X-Gm-Message-State: AOJu0YxuI03NcDazT7c6kV9jH8FFkWTNBi73SYerIauWobKB3esgQ+kl K/MXUez/SDJirLCk8NvzrIKAr9/YrQFVKFwqRj4UqOtbhivKJO84BLkudN/m9sRw X-Gm-Gg: ASbGncvwBVumgkJyq9tI+Yr1K1IYbYTE5q2gP+lx2ht5hSk16i/EZ7DrRFCnaHDs2jM ob9etECH0TeCX3cZ1azaBcF0W+sV/xgqeUKu6pum1f7RL2G7CFDDGIYiJAOYBCmfdLBmdm0QLx6 181hVpYKOctU/hXbgPuRoLryaE7Il2jjD3xoy7iYW7CfsZreMOhKT1nqwZLLYnLN9Wn2YPghLIZ HVT09xGFZ/IqB2RCY3qzGfoqUbRjasL3SszD/Mtr5U5JcsRKB+OFdgb6eWb61WrBZqdcBO5dZ79 6iiMdl8GCPkSKvFuQrr4Gj2HW1HH7KomqIQkb3VrsTsq/ce8hOI= X-Google-Smtp-Source: AGHT+IEZsUNCF/5gNWk3QCEBhQiSQ8RNOP/QkxHRvu/8wRkNHIj2oJ1V84VCksN7wKtR2OmxUJDZyA== X-Received: by 2002:a05:6000:22c8:b0:3a3:76cd:3e80 with SMTP id ffacd0b85a97d-3a376cd4028mr983572f8f.21.1747661042633; Mon, 19 May 2025 06:24:02 -0700 (PDT) Received: from localhost ([2001:8a0:4fe9:b400:8d90:6f0d:36bf:32df]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-442f338050csm208331425e9.10.2025.05.19.06.24.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 May 2025 06:24:02 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 16/47] Windows gdb: Introduce continue_last_debug_event_main_thread Date: Mon, 19 May 2025 14:22:37 +0100 Message-ID: <20250519132308.3553663-17-pedro@palves.net> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250519132308.3553663-1-pedro@palves.net> References: <20250519132308.3553663-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org We have code using do_synchronously to call continue_last_debug_event, and later patches in the series would need to add the same code in few more places. Factor it out to a continue_last_debug_event_main_thread function so these other places in future patches can just call it. In v2: - Fix context_str not used in the body of the method. Change-Id: I945e668d2b3daeb9de968219925a7b3c7c7ce9ed --- gdb/windows-nat.c | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 61bccb365d0..6393f394804 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -347,6 +347,12 @@ struct windows_nat_target final : public x86_nat_target needed. */ void wait_for_debug_event_main_thread (DEBUG_EVENT *event); + /* This continues the last debug event, dispatching to the worker + thread as needed. */ + void continue_last_debug_event_main_thread (const char *context_str, + DWORD continue_status, + bool last_call = false); + /* Force the process_thread thread to return from WaitForDebugEvent. PROCESS_ALIVE is set to false if the inferior process exits while we're trying to break out the process_thread thread. This can @@ -505,6 +511,28 @@ windows_nat_target::wait_for_debug_event_main_thread (DEBUG_EVENT *event) m_continued = false; } +void +windows_nat_target::continue_last_debug_event_main_thread + (const char *context_str, DWORD continue_status, bool last_call) +{ + std::optional err; + do_synchronously ([&] () + { + if (!continue_last_debug_event (continue_status, debug_events)) + err = (unsigned) GetLastError (); + + /* On the last call, do not block waiting for an event that will + never come. */ + return !last_call; + }); + if (err.has_value ()) + throw_winerror_with_name (string_printf (_("ContinueDebugEvent failed: %s"), + context_str).c_str (), + *err); + + m_continued = !last_call; +} + /* See nat/windows-nat.h. */ windows_thread_info * @@ -1229,22 +1257,9 @@ windows_nat_target::windows_continue (DWORD continue_status, int id, th->resume (); } - std::optional err; - do_synchronously ([&] () - { - if (!continue_last_debug_event (continue_status, debug_events)) - err = (unsigned) GetLastError (); - /* On the last call, do not block waiting for an event that will - never come. */ - return !last_call; - }); - - if (err.has_value ()) - throw_winerror_with_name (_("Failed to resume program execution" - " - ContinueDebugEvent failed"), - *err); - - m_continued = !last_call; + continue_last_debug_event_main_thread + (_("Failed to resume program execution"), continue_status, + last_call); return TRUE; } -- 2.49.0