From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id unkSGHZmmGrHbh8AWB0awg (envelope-from ) for ; Wed, 02 Sep 2026 14:09:58 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=EGlJeIeE; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4A6891E166; Wed, 02 Sep 2026 14:09:58 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 B95761E033 for ; Wed, 02 Sep 2026 14:09:56 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5B59D4BAE7D1 for ; Wed, 2 Sep 2026 18:09:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B59D4BAE7D1 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=EGlJeIeE Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by sourceware.org (Postfix) with ESMTPS id 837264BA2E3F for ; Wed, 2 Sep 2026 18:09:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 837264BA2E3F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 837264BA2E3F Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c32 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788372571; cv=none; b=jwmgEk/7UP9HGf5ctqgUlnFrFJbPO1R1ZoiDGJOPxWKFm5FDBr3BlnTudPh6Rsc6kZBHmpx+4MHuK2WVhKTVs8S+f+8+OM6cksLzzbeqM/w6y7wV7Nk4WpNyQGt9weoTU6CJT38RWx+VGJAaNHAeR1X4za7NX33r7GvUZUnoN0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788372571; c=relaxed/simple; bh=SI5LSD6stchbqfgzL9B/P8G6K75dIGfbVUvif4lQD+4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AYWuamQRgt4EMptYrmvyOUfU9jP34hHSRq81pj0ACe9eqNECRE6e93uPisBI0UtKU5rubNvNcm8/AkMww5rr+03y4YlwR1dIVMK5hm0cdwRG9TSsH8ZHysWzd0XSAz3ur60RdJ/26EpZVsAuc+lweZngvhGwoPS+/3rqhcgd17Y= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=EGlJeIeE DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 837264BA2E3F Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-6b057877851so941695eaf.0 for ; Wed, 02 Sep 2026 11:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1788372571; x=1788977371; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=IHQc63knhmvOa1VNsMDP2D8OXNVPxwA8IdSIxt3wNW4=; b=EGlJeIeE8qZzCdaf+bddjCm/8PFdAoLfiWd7Nzm3Tt0gU61kzmiAwyApn7jwrNZ4Wi Lt1JcydwqWK0bgeiqqk/BjPqGF4JPEQfOQ1Un6ht/WK6cEBrFSDg4n4TokYiCqCsbj5a kSaiFkF0BfCAtnt3l0gtsnG3zaxFIiy70tIZPgTgFiGTO8uwpvPBk3peZP0zITO06TXi elhSgYB9VgPVpY0If16LuUrlgz6UuQptGyMMckljlFVHchD/aVsp2z/62GwoHE/+5ZwE eXFTmUI927I7sisYSbyvKv/EanC9jvnM/IpiySf7bUEW+SgE6RVj6FMejeyjCFGMz3Oc GTEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788372571; x=1788977371; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=IHQc63knhmvOa1VNsMDP2D8OXNVPxwA8IdSIxt3wNW4=; b=H5gleXa71NGT8NbNLZBdTsPrGUWR76G0h4Hl0bUiiCn1jBA6NHKVTIJTnnpQS8MTpe UhSeEET82XRVJCKGPV4lEDsxZbZWn4wlxPnWylc6gipL6lsHC5wUCtbH4NKpcFHwhrW0 uGIWKv0hoO3MqXPXAnAMIzeg0aftcgWFSA5C6x/Yt9HF+ifsMj2aVoyLt2aIuuulKKoc 5vqvz7iINraQ4YFvhFHIMFW4PmVZrb11JCRZnp7AQfgMRyW9UWXA9pVII5/XdFsn0Jln ivnjfzgUR4jXy7OMCO8uPUZ3sOzYMVIs7vxPMpOTs0lRDO4D2Ps2zdXHjWZQQY672EjE WEow== X-Gm-Message-State: AFuF++nhrVFNgB3EjFQTDiNwFY6rqm3eo7rZxvkyIMzE5/pzJKq0LNgI UJBqFYAN8It6vggy3JJDs5ZHsSF5xaBKlgNc+OCDyB2CFTiCrYhihhuJnRM8sYT4Ds5FtdJ+aKZ 4ilvCuA== X-Gm-Gg: AR+sD10m8yeygNUbajttnzYHlhizjdaxCHWsXuF8uFZI28xA+9c6yxNwp/D+mXo9dUf 8GEqt4bmi0yoPr253Oxj7tuG8q9/ZHkIRwCtXwsvBnnZomHh2EtpXZ12gUvNY71iT31y4B/HmlA H8uttdJbu0l3G4qhJ+Fk60BdmC0O/Z069sEaWh0+ebJ98lYk4WaAH7VS+YFzBuGze+fpIWbyrWH HOw1SCOIdqx615q92O4zSnTnXpD8vfC3VkhhXioPvTC6EofRlq8/CcSSRc2missyuVGU2FdyDa3 IZoCFvGr2s2weJ9PqSkZ4PezQW6gVd7FI9I2iNCKP68zuB0wF2c3PIpFNpUOiLd+l2Apo9wsCWv U1yFbE+zjKHiaQrTAfHmCQ6tS7rqu0XNdgEiXN1AbFnFyeqyWVwTrPGI9JWRSUrz9z9GsapmxfS 4TlTWxYY5bw4yJTVzD7wR5tyKWq5KoYm2f9SLT5M+PtlL9+WUxxAoSLyc/lac1Y1Cfwmqn0Xk80 mSG X-Received: by 2002:a05:6820:1996:b0:6ae:8fc0:dbaf with SMTP id 006d021491bc7-6b47edd352cmr5164839eaf.1.1788372570733; Wed, 02 Sep 2026 11:09:30 -0700 (PDT) Received: from bapiya (97-122-117-2.hlrn.qwest.net. [97.122.117.2]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-46f9a1052c6sm3018638fac.4.2026.09.02.11.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2026 11:09:30 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Return correct thread for cached event Date: Wed, 2 Sep 2026 12:09:28 -0600 Message-ID: <20260902180928.3545493-1-tromey@adacore.com> X-Mailer: git-send-email 2.55.0 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 Commit 2e1aacf15a9 ("Windows gdb+gdbserver: Make current_event per-thread state") introduced a regression. This was detected by the AdaCore internal test suite in a somewhat unusual configuration: when using "attach" with a 32-bit Windows process, an extra stop would be generated, like: (gdb) break break_me Breakpoint 1 at 0x1211a04: file pck.adb, line 18. (gdb) continue Continuing. Thread 4 received signal SIGINT, Interrupt. [Switching to thread 4 (Thread 6652)] 0x77034210 in ntdll!RtlUserThreadStart () from C:/Windows/SysWOW64/ntdll.dll Here, we expect to stop in break_me, but instead stop in some Windows DLL. I tracked this down to this hunk in the aforementioned commit: - return debug_event_ptid (&windows_process.current_event); + return ptid_t (windows_process.process_id, + windows_process.main_thread_id, 0); What happens here is that the "cached" stop ends up being reported in the main thread, rather than whatever thread actually caused this stop. This patch fixes the problem by arranging to also cache the thread ptid. I am not sure whether the call to switch_to_thread here is really needed; but since other returns seem to switch the thread, I thought this one ought to as well. I tested this using the AdaCore internal test suite. As this is a regression, when it lands I also plan to apply it to the gdb 18 branch. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34583 --- gdbserver/win32-low.cc | 5 +++-- gdbserver/win32-low.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc index 13c14a7c69f..55e4b2e2fe3 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -337,6 +337,7 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached) || status.kind () == TARGET_WAITKIND_STOPPED) { windows_process.cached_status = status; + windows_process.cached_ptid = current_thread->id; break; } @@ -1145,8 +1146,8 @@ win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus, fails). Report it now. */ *ourstatus = windows_process.cached_status; windows_process.cached_status.set_ignore (); - return ptid_t (windows_process.process_id, - windows_process.main_thread_id, 0); + switch_to_thread (find_thread_ptid (windows_process.cached_ptid)); + return windows_process.cached_ptid; } while (1) diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h index 439adb84bc2..f4f02851734 100644 --- a/gdbserver/win32-low.h +++ b/gdbserver/win32-low.h @@ -193,6 +193,8 @@ struct gdbserver_windows_process : public windows_nat::windows_process_info win32_wait should return it next, instead of fetching the next debug event off the win32 API. */ struct target_waitstatus cached_status; + /* The ptid corresponding to the above status. */ + ptid_t cached_ptid; /* True if current_process_handle needs to be closed. */ bool open_process_used = false; base-commit: 49c379f8c2f8ff888b621b4a070dc1976b942577 -- 2.55.0