From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wf/2EYvW62m5UzkAWB0awg (envelope-from ) for ; Fri, 24 Apr 2026 16:46:03 -0400 Received: by simark.ca (Postfix, from userid 112) id 458221E0BA; Fri, 24 Apr 2026 16:46:03 -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 C2F761E093 for ; Fri, 24 Apr 2026 16:46:02 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 4B12A4B92084 for ; Fri, 24 Apr 2026 20:46:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B12A4B92084 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by sourceware.org (Postfix) with ESMTPS id 6E7D04B92087 for ; Fri, 24 Apr 2026 20:45:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E7D04B92087 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 6E7D04B92087 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777063537; cv=none; b=DzS2n97fkKmuoASgANOokSy+BBPV7MteZ+UtD2JR14JHriVyHuSEIpdyo/xpPZb7nv5DM40dVPos06tJsOhtwKewGqhCLTtD4oUDtkUiQh7+Ygt68MiFhp3mIm9tcIn+3h0hbP+0fievTQu26y7o8wuaAJvoykcHyaEjV4VudrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777063537; c=relaxed/simple; bh=SFHTkcAuB2zCTIf7cTZfotmReOC/xhiWyMUVjwamMPs=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=cUP5212AF5PgqoIgQEdLSKuiOuyCiW+xaWhJ+VA3sxDN2bl0UbIbVF6dGDf3En1ZPWfNWx49nhiSYl33XRmWfTQK2lfOBUp7XgU13TP81cDh3ArTWdRxi1hzxL3BgDp3x5BWoaJBht/82JKrZ7bpIP+PEEMEHMschI7a6rw2BDQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E7D04B92087 Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-43d734223e4so5676604f8f.0 for ; Fri, 24 Apr 2026 13:45:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777063536; x=1777668336; 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=gxuZ4FjGjIZBUhlr1zw6QWm9SpSqn4HUN/fUJv/gXKg=; b=UPLsOGebcpR6oou1kSpEDFCVgdTKMTBB9oMWqyJt+520QttTZ5mGVM4TSBylQUdpLU NWmCqeTHTjAbPHxqQReoO+B1bi0sGXv3OmWVl3vJ51T9kRsVWLP0gWQz+DEJlp+6wxiC Iy8Lb4PoFszd7NYOElDlB00+kHbY+DS86pawVLjmqTmA+7SabvVvsvWVzNG0uKaFab32 K7Sjt9oUBtCp2toV/jLe5TT9pId3ymUpb91XKiIkGCfFDy82cLpTIeWO0F4NZ5NiE6zO yk2iUlH28Dp0WHVLBTkHwoP5RVDrwxYs4HcDnniQrDaYgxo/98OrHi0CRQaR2WYUIYux U56g== X-Gm-Message-State: AOJu0Yy4auOrbSwOybmpCDyoM4jKgvj+/exwTEUE9vyJaglBO8qRMti/ ss7vZN8yXbgimg4bRuL+2BS5q6yDDZSV7tmaqJ05pyM0UZjJ96/TV4W+QE/DAPyD X-Gm-Gg: AeBDievy2e0zr8Rx7pKmFxP1F/+kKVZKeP8gcpoPWBO9CsNSZ8AGrRWtFGvkGy6bbQ9 vsNxRaK6C0KPEc3R4shPKHdGTaP9FN2n9ZTJILzvT59/St4Rv02taS9hzXN914QiZrcsdrnf/zN UjpgJWrm8MzWHvBga8ALDVqCP8++6LQ8bBMfZTNv2SE1lElieW03e2CJnpp5Vg1DVWzmsWWGUOf Iy9hwU84KNtOVI5QTEW+W+verc4FNZtRwwdj405Clqa0jIFqsawJZywmBdUsnW1eCb4Kh2aS8Ny /Fv74lZB+j9xSMQ1Ml+cv1ZiThKFZbUov/qAOZrA0RRZa4aaoVoW3Y5EeVV1ypSpHAPW54+/Dtv 8WV3Kp1cwWa2NzkQB+A4bSTpAU0VI5AyXfVxmfpib8Wva5d1j+v5vNLm+ulsIWekHOiQOxJlDGR mCP9sCIPUOw6f4qJ0Ln2DiHgfHg3cA7DR0 X-Received: by 2002:a05:6000:4709:b0:441:2397:f40f with SMTP id ffacd0b85a97d-4412397f431mr22961489f8f.4.1777063535622; Fri, 24 Apr 2026 13:45:35 -0700 (PDT) Received: from localhost ([2001:8a0:facb:a800:7315:8865:c664:fc06]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-43fe4e4d525sm59167240f8f.31.2026.04.24.13.45.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Apr 2026 13:45:35 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [pushed 07/28] Windows gdb: Simplify windows_nat_target::wait Date: Fri, 24 Apr 2026 21:44:47 +0100 Message-ID: <20260424204508.1343973-8-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 The logic in windows_nat_target::wait, where we decide what to do depending on the result from get_windows_debug_event is harder to grasp than it looks. It is not easy to tell what should happen when in async mode get_windows_debug_event returns that there's no event to process. And then, if get_windows_debug_event returns null_ptid / TARGET_WAITKIND_SPURIOUS, then we need to issue a ContinueDebugEvent. There's also this comment in windows_nat_target::wait, which we're not really implementing today: ~~~~ /* We loop when we get a non-standard exception rather than return with a SPURIOUS because resume can try and step or modify things, which needs a current_thread->h. But some of these exceptions mark the birth or death of threads, which mean that the current thread isn't necessarily what you think it is. */ ~~~~ This patch changes things a bit so that the code is more obvious: - look at the status kind, instead of ptid_t. - add an explicit early return case for no-event. - add an explicit case for TARGET_WAITKIND_SPURIOUS. - with those, we no longer need to handle the case of find_thread not finding a thread, so we can drop one indentation level. Approved-By: Tom Tromey Change-Id: I76c41762e1f893a7ff23465856ccf6a44af1f0e7 commit-id:aff7fc4a --- gdb/windows-nat.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 2dd372ae7b2..30b07221b62 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1139,7 +1139,10 @@ windows_nat_target::get_windows_debug_event } if (thread_id == 0) - return null_ptid; + { + ourstatus->set_ignore (); + return null_ptid; + } return ptid_t (windows_process->current_event.dwProcessId, thread_id, 0); } @@ -1160,25 +1163,33 @@ windows_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, { ptid_t result = get_windows_debug_event (pid, ourstatus, options); - if (result != null_ptid) + if ((options & TARGET_WNOHANG) != 0 + && ourstatus->kind () == TARGET_WAITKIND_IGNORE) + return result; + + if (ourstatus->kind () == TARGET_WAITKIND_SPURIOUS) + { + CHECK (windows_continue (DBG_CONTINUE, + windows_process->desired_stop_thread_id, 0)); + } + else if (ourstatus->kind () != TARGET_WAITKIND_IGNORE) { if (ourstatus->kind () != TARGET_WAITKIND_EXITED - && ourstatus->kind () != TARGET_WAITKIND_SIGNALLED) + && ourstatus->kind () != TARGET_WAITKIND_SIGNALLED) { windows_thread_info *th = windows_process->find_thread (result); - if (th != nullptr) + th->stopped_at_software_breakpoint = false; + if (windows_process->current_event.dwDebugEventCode + == EXCEPTION_DEBUG_EVENT + && ((windows_process->current_event.u.Exception.ExceptionRecord.ExceptionCode + == EXCEPTION_BREAKPOINT) + || (windows_process->current_event.u.Exception.ExceptionRecord.ExceptionCode + == STATUS_WX86_BREAKPOINT)) + && windows_process->windows_initialization_done) { - th->stopped_at_software_breakpoint = false; - if (windows_process->current_event.dwDebugEventCode - == EXCEPTION_DEBUG_EVENT - && is_sw_breakpoint (&windows_process->current_event - .u.Exception.ExceptionRecord) - && windows_process->windows_initialization_done) - { - th->stopped_at_software_breakpoint = true; - th->pc_adjusted = false; - } + th->stopped_at_software_breakpoint = true; + th->pc_adjusted = false; } } -- 2.53.0