From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by sourceware.org (Postfix) with ESMTPS id F148A3849ACC for ; Tue, 7 May 2024 23:43:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F148A3849ACC 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 F148A3849ACC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715125394; cv=none; b=tXhHlloPZ2HJBu8Z7LH0B746k/NJ6BPLNKsIfoLINbN/z0XqUrITIEGRRcWT/gBdwZNjtWTVbqGw0HPzg6HDb3UJF215EUYAAjsdhC6kUQiiDFgfwmK1QO2sMuh3pVr1RbxcVR7Siizp5H2le2OnxQSQSyBDYDCXsCFWPCwkVeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715125394; c=relaxed/simple; bh=y0mitKeA7sE605wL2SwH+Ov2ccmBkecfLAa3Zr55OF4=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=GQ5gLzCu5hggY9CPwn6HSPkhMvI1O2pDJnscnmXj54DcUp07+/fOjffIcC66IoUEYFtPodp/mCHSqRFmrEfQNynmi8LkuG5tRiDCfTU0qAuZmCowRXoeYzDwz/So4wJhuY/Oq8jnUH2rHXzq55+5woCv88PR3VnjUjw3xovjtBs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-41ebcf01013so1526045e9.0 for ; Tue, 07 May 2024 16:43:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715125392; x=1715730192; 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=3jsa6AoOr08KH4m7iE0GDY731UhjxH2WtZG25i/bQx8=; b=jjREYChYAXdkXGNCb6qsoq1zHAFBkZCRLsVCgexrW+79WdDVwuYOcdaMmUYOVP2oav RhalMOpdgxcTVHv5032wFDthK+9veNRVLNsYnP+/zCJITS34KZT2GDhzHp97GtyPVle0 fN2+/A9VNiTQs0OuD0D1vClCbUeOPCycO2+Et6Pk1tcBbsmm9y64b4112WPc8RVmtXf7 j8Q8UaWN5OiUJaXW1rs5llCkXHLrDu+qDUYB+0ICaeoh4Elkkhw8UJ1/5OErRU1sxRRF xuTKQcAUqkA40E3at90tLPQX2AaAnDpWC+7dmHyuMGLWwMXto8EwV9Eoeav5oJ4MtOMp EKiA== X-Gm-Message-State: AOJu0YzmtEvAzmG44L58q56Oquv2aQ+cAFY8w6IcANyGtjRUVbfgIjOU y6k8R05SNezLHxJDUFdJsxPEivOqVDLPgdIiNBaQ3ITN39v8MP1QPPp0oe5g X-Google-Smtp-Source: AGHT+IEJNQtsWDxZUYgO+RAu/Q2FPGk2ZsMKEatJYqHd+0XPUwkc0T3gAAMf7P4cCIPSw8GW/bHTWw== X-Received: by 2002:a05:600c:5128:b0:418:3ea8:46c0 with SMTP id 5b1f17b1804b1-41f2da2d4bcmr34920485e9.13.1715125391703; Tue, 07 May 2024 16:43:11 -0700 (PDT) Received: from localhost ([2001:8a0:f908:4900:2dd1:1a0d:2b75:dc42]) by smtp.gmail.com with UTF8SMTPSA id bi18-20020a05600c3d9200b0041bff91ea43sm194036wmb.37.2024.05.07.16.43.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 May 2024 16:43:11 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 11/34] Windows gdb: Introduce continue_last_debug_event_main_thread Date: Wed, 8 May 2024 00:42:10 +0100 Message-ID: <20240507234233.371123-12-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240507234233.371123-1-pedro@palves.net> References: <20240507234233.371123-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. Change-Id: I945e668d2b3daeb9de968219925a7b3c7c7ce9ed --- gdb/windows-nat.c | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index aa531c4208a..93ba7850c88 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -354,6 +354,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 @@ -512,6 +518,27 @@ 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 (_("ContinueDebugEvent failed"), + *err); + + m_continued = !last_call; +} + /* See nat/windows-nat.h. */ windows_thread_info * @@ -1319,22 +1346,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.43.2