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 <simark@simark.ca>
[1]: https://inbox.sourceware.org/gdb-patches/590655c1-abed-4a16-b8cc
-762f1d8e6093@simark.ca/
---
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(-)
@@ -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. */
@@ -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."));
@@ -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."));
@@ -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
@@ -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;
@@ -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);
@@ -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);