From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kVa8KlzX62kyVDkAWB0awg (envelope-from ) for ; Fri, 24 Apr 2026 16:49:32 -0400 Received: by simark.ca (Postfix, from userid 112) id A49001E093; Fri, 24 Apr 2026 16:49:32 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 140911E093 for ; Fri, 24 Apr 2026 16:49:32 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id AFAB84B920D8 for ; Fri, 24 Apr 2026 20:49:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AFAB84B920D8 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by sourceware.org (Postfix) with ESMTPS id 8AC174B920F4 for ; Fri, 24 Apr 2026 20:45:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8AC174B920F4 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 8AC174B920F4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777063543; cv=none; b=mcbxCzIN60k2U1KbWXZdo97yrj0YvcPV/Cmbaq3z696Gc0tHOs2KvkVXbnWMpma2bqsTz7nXv8mUIClxnkM0pBMTREfHQadxJ8JzY51qa2WEeFzmkkYlv7S0WFTwfoE5IBHE9AQeJFYlLvyJOGFgZMx/wyP/gwIZL/06QRmIvIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777063543; c=relaxed/simple; bh=i2JbRJd1gdDI2U+AVkNAfYRH5DdSsMh1fvUkmgOS0/M=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=b3I4DsIvPI49tVjZXnXfMIYns1kstJ366IRQICo+dvFf6cbWRyha2DWlarh2tsbAJZIqRio9w2pZa/iCtEhZGEyGyWTtTOMXFL/np3BbNakrms6/TbRpwkLRNK10aTKvaQfFF7Yy+ul7Os1IuvmK+0jAyXXY/jLHYGeJL1dY/HU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8AC174B920F4 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4891c0620bcso53452875e9.1 for ; Fri, 24 Apr 2026 13:45:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777063542; x=1777668342; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2wY23GM5KhsQSi5TKWB4GBkRDwgmeyCKhFb1/K84cmw=; b=k7HgpypenuNF5GY+1EhFJfunBPW2aV9vkEjuYk6Pn9zzEP6GymQoapeimEgdoIzps+ sAKnejBeUvFxjnkAVtQawiwgVi2eNpXivtrLA5GEyRenhv2bjWo6hOtOB22A6Fo79c47 jjTg5C0PtZuD8+8VzlcCCbSLLaGIkHNWclcFbs16ez5AHsHBuL/5XRlACBNQUsYGuorN k0cVV33cTaJl1eeBVMPanq6Y4wkIz/psimgqvqWh4/62wQtqauldLeIpCB43U7+jpyQb LsA7ovGq7WmaKcx7aI/CcCZadRAg8TNuJjLmoiuab4G0O0osGklDUWOcx0wIGFESrduJ ngMg== X-Gm-Message-State: AOJu0YzDrmt6mspA47EjnDn3zdsCaHcBOgikj5yMuDBcziOtCjl7fr9W MiSEAotxNS3Rq136UG73Uly7z3reOLKdTlevXxkP2H9Jr0/zoa4g9FAoP2hNKBLE X-Gm-Gg: AeBDieuO6Irh3q4bry0QKyipuxb/jTd8zOZOE8wPfCyxpUfoUTzsh2GOU8MBm9mt7jp RKJDVc2f9vYrq9TsFP5Fkx0h+TtjcicLyioLkjGZMbjf7hb2+81N005IvK24MNP465BNchC2RO9 72hpGx6ctrVr34EmYUehV+elE04u3JkxiqWC/9Trck0Nc8ysrstCueTsH/Fa/nOzVz70ZLYtKlF 2rQGUp12S/BUDInJQNxJzyvZmOzKA02jIk5fZ8PgUklI+SQB42lJn8cXkVQL+eBevXWEzMfij65 aN2ZRrIZgfoAViz6d6cne+Or0XAPB4LctgpASwV7fk+K6w+v1gNK5sVHfWacGoPEdcyvO4AQDVt Khe1G9NP5VDgSt/jrwSvpEbWJtIPEY5n4Zzm/gb6I4JkUwju2ky33Mwb/AvqoJHqZ/O1Mk09fHj t0Ghi95dEdYldvLfMxJN0hRCoNcAsH9JZK9grVx4JK4NU= X-Received: by 2002:a05:600c:34c3:b0:485:41c4:e2e4 with SMTP id 5b1f17b1804b1-488fb792dd0mr453155865e9.23.1777063541701; Fri, 24 Apr 2026 13:45:41 -0700 (PDT) Received: from localhost ([2001:8a0:facb:a800:7315:8865:c664:fc06]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4899dc95920sm113670965e9.6.2026.04.24.13.45.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Apr 2026 13:45:41 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [pushed 09/28] Windows gdb: Introduce continue_last_debug_event_main_thread Date: Fri, 24 Apr 2026 21:44:49 +0100 Message-ID: <20260424204508.1343973-10-pedro@palves.net> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424204508.1343973-1-pedro@palves.net> References: <20260424204508.1343973-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. Approved-By: Tom Tromey Change-Id: I945e668d2b3daeb9de968219925a7b3c7c7ce9ed commit-id:ee04461a --- gdb/windows-nat.c | 43 ++++++++++++++++++++++++++----------------- gdb/windows-nat.h | 6 ++++++ 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 468f451595d..174b54eda78 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -261,6 +261,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 * @@ -711,22 +733,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; } @@ -1188,7 +1197,7 @@ windows_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, /* All-stop, suspend all threads until they are explicitly resumed. */ - for (auto &thr : windows_process.thread_list) + for (auto &thr : windows_process->thread_list) thr->suspend (); } diff --git a/gdb/windows-nat.h b/gdb/windows-nat.h index 2907d97d655..8866408567c 100644 --- a/gdb/windows-nat.h +++ b/gdb/windows-nat.h @@ -249,6 +249,12 @@ struct windows_nat_target : public inf_child_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 -- 2.53.0