From: Pedro Alves <pedro@palves.net>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Return correct thread for cached event
Date: Fri, 4 Sep 2026 13:51:54 +0100 [thread overview]
Message-ID: <f2991f10-3c8c-42e0-8532-490ebe113b39@palves.net> (raw)
In-Reply-To: <20260902180928.3545493-1-tromey@adacore.com>
On 2026-09-02 19:09, Tom Tromey wrote:
> 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.
Ouch, sorry about this. And thanks for all the investigation.
I must have very early on in the non-stop work assumed that the initial events
all come from the main thread, but later on I learned that they don't (I even
ran into that very nasty bug that led to the state => internal_state split), and
missed this assumption here.
>
> 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
Approved-by: Pedro Alves <pedro@palves.net>
prev parent reply other threads:[~2026-09-04 12:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 18:09 Tom Tromey
2026-09-03 14:15 ` Hannes Domani
2026-09-03 15:06 ` Tom Tromey
2026-09-04 12:51 ` Pedro Alves [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f2991f10-3c8c-42e0-8532-490ebe113b39@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox