[binutils-gdb] Windows gdb: Don't abort get_windows_debug_event with no threads
Hannes Domani via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6e3ecea0e3ca191e81e82ee0194c49eea1ffb101 commit 6e3ecea0e3ca191e81e82ee0194c49eea1ffb101 Author: Hannes Domani <[email protected]> Date: Wed Aug 26 19:35:52 2026 +0200 Windows gdb: Don't abort get_windows_debug_event with no threads When a machine is under heavy load, windows sometimes provides the debug events in a weird order: [windows events] get_windows_debug_event: kernel event for pid=22208 tid=0x6df0 code=CREATE_PROCESS_DEBUG_EVENT [windows events] get_windows_debug_event: kernel event for pid=22208 tid=0xe74 code=CREATE_THREAD_DEBUG_EVENT [windows events] get_windows_debug_event: kernel event for pid=22208 tid=0xe74 code=EXIT_THREAD_DEBUG_EVENT [windows events] get_windows_debug_event: kernel event for pid=22208 tid=0x6df0 code=EXIT_THREAD_DEBUG_EVENT At this point the process has seemingly no threads, even though for the last thread there should be EXIT_PROCESS_DEBUG_EVENT instead of EXIT_THREAD_DEBUG_EVENT. But the next event shows that a new thread was created, which then finally got EXIT_PROCESS_DEBUG_EVENT: [windows events] get_windows_debug_event: kernel event for pid=22208 tid=0x5a7c code=CREATE_THREAD_DEBUG_EVENT [windows events] get_windows_debug_event: kernel event for pid=22208 tid=0x5a7c code=EXIT_PROCESS_DEBUG_EVENT Since the introduction of non-stop support, gdb fails with this error at the point of no threads: No unwaited-for children left. It's because it added this check which prevents getting the next debug event: /* If there are no resumed threads left, bail. */ if (windows_process->windows_initialization_done && !any_resumed_thread ()) { ourstatus->set_no_resumed (); return minus_one_ptid; } This fixes it by changing any_resumed_thread to return true if there is no thread at all. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34195 Approved-By: Tom Tromey <[email protected]> Diff: --- gdb/windows-nat.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index def8fa606f4..94d932a9a1e 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1366,15 +1366,20 @@ windows_nat_target::thread_events (bool enable) m_report_thread_events = enable; } -/* True if there is any resumed thread. */ +/* True if there is any resumed thread, or no thread at all. */ bool windows_nat_target::any_resumed_thread () { + bool has_thread = false; for (thread_info &thread : all_non_exited_threads (this)) - if (thread.internal_state () == THREAD_INT_RUNNING) - return true; - return false; + { + has_thread = true; + if (thread.internal_state () == THREAD_INT_RUNNING) + return true; + } + DEBUG_EVENTS ("any_resumed_thread: has_thread=%d", has_thread); + return !has_thread; } /* Called for both EXIT_THREAD_DEBUG_EVENT and