[PATCH v1 1/2] gdb: rename any_thread_of_inferior to any_non_exited_thread_of_inferior
Matthieu Longo <[email protected]> Tue, 28 Jul 2026 15:33:16 +0100
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
The name any_thread_of_inferior suggests that the function may return any thread of the inferior. In practice, it only returns a non-exited thread. Rename it to any_non_exited_thread_of_inferior to better reflect its behavior. This is a preparatory change for the following patch, which adds another helper with similar semantics. Suggested-by: Simon Marchi <[email protected]> [1]: https://inbox.sourceware.org/gdb-patches/590655c1-abed-4a16-b8cc [email protected]/ --- gdb/gdbthread.h | 4 ++-- gdb/inferior.c | 6 +++--- gdb/linux-fork.c | 10 +++++----- gdb/mi/mi-main.c | 4 ++-- gdb/remote.c | 4 ++-- gdb/thread.c | 2 +- gdb/top.c | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 1bdbf621982..6588ae0c6a7 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -779,9 +779,9 @@ struct thread_info *find_thread_by_handle /* Finds the first thread of the specified inferior. */ extern struct thread_info *first_thread_of_inferior (inferior *inf); -/* Returns any thread of inferior INF, giving preference to the +/* Returns any non-exited thread of inferior INF, giving preference to the current thread. */ -extern struct thread_info *any_thread_of_inferior (inferior *inf); +extern struct thread_info *any_non_exited_thread_of_inferior (inferior *inf); /* Returns any non-exited thread of inferior INF, giving preference to the current thread, and to not executing threads. */ diff --git a/gdb/inferior.c b/gdb/inferior.c index 1481f46cdd1..ac8c4354b71 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -663,7 +663,7 @@ detach_inferior_command (const char *args, int from_tty) continue; } - thread_info *tp = any_thread_of_inferior (inf); + thread_info *tp = any_non_exited_thread_of_inferior (inf); if (tp == NULL) { warning (_("Inferior ID %d has no threads."), num); @@ -702,7 +702,7 @@ kill_inferior_command (const char *args, int from_tty) continue; } - thread_info *tp = any_thread_of_inferior (inf); + thread_info *tp = any_non_exited_thread_of_inferior (inf); if (tp == NULL) { warning (_("Inferior ID %d has no threads."), num); @@ -771,7 +771,7 @@ inferior_command (const char *args, int from_tty) { if (inf != current_inferior ()) { - thread_info *tp = any_thread_of_inferior (inf); + thread_info *tp = any_non_exited_thread_of_inferior (inf); if (tp == NULL) error (_("Inferior has no threads.")); diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c index 92afa4dde6d..446d3284388 100644 --- a/gdb/linux-fork.c +++ b/gdb/linux-fork.c @@ -571,7 +571,7 @@ class scoped_switch_fork_info if (oldinf != newinf) { - thread_info *tp = any_thread_of_inferior (newinf); + thread_info *tp = any_non_exited_thread_of_inferior (newinf); switch_to_thread (tp); m_oldinf = oldinf; } @@ -593,7 +593,7 @@ class scoped_switch_fork_info remove_breakpoints (); if (m_oldinf != nullptr) { - thread_info *tp = any_thread_of_inferior (m_oldinf); + thread_info *tp = any_non_exited_thread_of_inferior (m_oldinf); switch_to_thread (tp); } fork_load_infrun_state (m_oldfp); @@ -836,7 +836,7 @@ print_checkpoints (struct ui_out *uiout, inferior *req_inf, fork_info *req_fi) if (req_fi != nullptr && req_fi != &fi) continue; - thread_info *t = any_thread_of_inferior (inf); + thread_info *t = any_non_exited_thread_of_inferior (inf); bool is_current = fi.ptid.pid () == inf->pid; ui_out_emit_tuple tuple_emitter (uiout, nullptr); @@ -1063,7 +1063,7 @@ linux_fork_context (struct fork_info *newfp, int from_tty, inferior *newinf) if (newinf != current_inferior ()) { - thread_info *tp = any_thread_of_inferior (newinf); + thread_info *tp = any_non_exited_thread_of_inferior (newinf); switch_to_thread (tp); inferior_changed = true; } @@ -1100,7 +1100,7 @@ restart_command (const char *args, int from_tty) /* Don't allow switching from a thread/fork that's running. */ inferior *curinf = current_inferior (); if (curinf->pid != 0 - && any_thread_of_inferior (curinf)->state () == THREAD_RUNNING) + && any_non_exited_thread_of_inferior (curinf)->state () == THREAD_RUNNING) error (_("Cannot execute this command while " "the selected thread is running.")); diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 73c64b82186..6a79805d75d 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -397,7 +397,7 @@ run_one_inferior (inferior *inf, bool start_p) if (inf->pid != 0) { - thread_info *tp = any_thread_of_inferior (inf); + thread_info *tp = any_non_exited_thread_of_inferior (inf); if (tp == NULL) error (_("Inferior has no threads.")); @@ -1742,7 +1742,7 @@ mi_cmd_remove_inferior (const char *command, const char *const *argv, int argc) set_current_inferior (new_inferior); if (new_inferior->pid != 0) - tp = any_thread_of_inferior (new_inferior); + tp = any_non_exited_thread_of_inferior (new_inferior); if (tp != NULL) switch_to_thread (tp); else diff --git a/gdb/remote.c b/gdb/remote.c index 194c4cbd9bb..30d0d171d1f 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -5761,7 +5761,7 @@ remote_target::start_remote_1 (int from_tty, int extended_p) /* Need to switch to a specific thread, because remote_check_symbols uses INFERIOR_PTID to set the general thread. */ scoped_restore_current_thread restore_thread; - thread_info *thread = any_thread_of_inferior (inf); + thread_info *thread = any_non_exited_thread_of_inferior (inf); switch_to_thread (thread); this->remote_check_symbols (); } @@ -16175,7 +16175,7 @@ remote_objfile_changed_check_symbols (program_space *pspace) called very early in the connection process, while the inferior is being set up, before threads are added. Just skip it, start_remote_1 also calls remote_check_symbols when it's done setting things up. */ - thread_info *thread = any_thread_of_inferior (inf); + thread_info *thread = any_non_exited_thread_of_inferior (inf); if (thread != nullptr) { scoped_restore_current_thread restore_thread; diff --git a/gdb/thread.c b/gdb/thread.c index 96c733e0629..a7d0b8a45dc 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -675,7 +675,7 @@ first_thread_of_inferior (inferior *inf) } thread_info * -any_thread_of_inferior (inferior *inf) +any_non_exited_thread_of_inferior (inferior *inf) { gdb_assert (inf->pid != 0); diff --git a/gdb/top.c b/gdb/top.c index 477c385da61..308b5552fd5 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1862,7 +1862,7 @@ kill_or_detach (inferior *inf, int from_tty) if (inf->pid == 0) return; - thread_info *thread = any_thread_of_inferior (inf); + thread_info *thread = any_non_exited_thread_of_inferior (inf); if (thread != NULL) { switch_to_thread (thread); -- 2.55.0