From e3b29afad9af06e4aef3224b6331c3804f6940d9 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 10 Apr 2025 23:28:34 +0100 Subject: [PATCH] Suspended REPLY_LATER (WIP) This should be needed, but I haven't managed to trigger it, yet... Change-Id: I38aa876fe93a9427d43d17f1888c01ee43fe431c --- gdb/windows-nat.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 60521e60a8d..0dab5fcf6da 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -2164,6 +2164,30 @@ windows_nat_target::get_windows_debug_event gdb_assert (event_code != EXIT_THREAD_DEBUG_EVENT && event_code != EXIT_PROCESS_DEBUG_EVENT); + /* If the thread was indeed forced-exited, then it is no longer + considered suspended by Windows, which unblocks the + DBG_REPLY_LATER event, even if we thought the thread was + suspended. So try resuming and re-suspending. If the thread + is indeed gone, then suspend will fail and we will end up + with suspended==-1. This is important so that we take the + path that does DBG_CONTINUE below instead of the + DBG_REPLY_LATER path, so that we get past the reply-later + event and get to the thread exit event. */ + if (result_th->suspended == 1) + { + result_th->resume (); + result_th->suspend (); + + if (result_th->suspended == -1) + { + /* Pending stop. See the comment by the definition of + "pending_status" for details on why this is needed. */ + DEBUG_EVENTS ("XXX: unexpected reply-later stop in now-dead suspended thread 0x%x", + result_th->tid); + gdb_assert (0); + } + } + if (result_th->suspended == 1) { /* Pending stop. See the comment by the definition of -- 2.47.2