[binutils-gdb] Windows gdb: extra thread info => show exiting
Pedro Alves 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=70e01ad62ec25e434ddbc7ba339a64e4b1b9c464 commit 70e01ad62ec25e434ddbc7ba339a64e4b1b9c464 Author: Pedro Alves <[email protected]> Date: Tue Apr 22 11:28:11 2025 +0100 Windows gdb: extra thread info => show exiting Now that we have easy access to each thread's last event, we can easily include some extra info in "info threads" output related to each thread's last event. This patch makes us show whether the thread is exiting, or causing a whole-process exit. This is useful when multiple threads hit events at the same time, and the thread/process exit events are still pending until the user re-resumes the program. This is similar to how linux-thread-db.c also shows "Exiting" in its target_extra_thread_info implementation. This will be relied on by the testcase added by the following patch. Approved-By: Tom Tromey <[email protected]> Change-Id: I493b7ea3e14574dc972b1341eb5062fbbfda1521 commit-id:51b6d728 Diff: --- gdb/windows-nat.c | 21 +++++++++++++++++++++ gdb/windows-nat.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 6f3803c887b..638e87f6f60 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -3345,6 +3345,27 @@ windows_nat_target::thread_name (struct thread_info *thr) return th->thread_name (); } +/* Implementation of the target_ops::extra_thread_info method. */ + +const char * +windows_nat_target::extra_thread_info (thread_info *info) +{ + windows_thread_info *th = windows_process->find_thread (info->ptid); + + if (!th->suspended) + return nullptr; + + if (th->pending_status.kind () == TARGET_WAITKIND_THREAD_EXITED + || th->last_event.dwDebugEventCode == EXIT_THREAD_DEBUG_EVENT) + return "exiting"; + else if (th->pending_status.kind () == TARGET_WAITKIND_EXITED + || th->pending_status.kind () == TARGET_WAITKIND_SIGNALLED + || th->last_event.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT) + return "exiting process"; + + return nullptr; +} + /* Implementation of the target_ops::supports_non_stop method. */ bool diff --git a/gdb/windows-nat.h b/gdb/windows-nat.h index 5ef68dff274..2d6981ada0b 100644 --- a/gdb/windows-nat.h +++ b/gdb/windows-nat.h @@ -214,6 +214,8 @@ struct windows_nat_target : public inf_child_target bool thread_alive (ptid_t ptid) override; + const char *extra_thread_info (thread_info *info) override; + std::string pid_to_str (ptid_t) override; void interrupt () override;