[binutils-gdb] gdb: rename any_thread_of_inferior to any_non_exited_thread_of_inferior

Matthieu Longo 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=ae413d9abe6be0ec83187d37157de67914d369c8

commit ae413d9abe6be0ec83187d37157de67914d369c8
Author: Matthieu Longo <[email protected]>
Date:   Mon Jul 13 15:37:26 2026 +0100

    gdb: rename any_thread_of_inferior to any_non_exited_thread_of_inferior
    
    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.
    
    [1]: https://inbox.sourceware.org/gdb-patches/[email protected]/
    
    Suggested-By: Simon Marchi <[email protected]>
    Approved-By: Simon Marchi <[email protected]>

Diff:
---
 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 224f1cc8621..5e540f9d09a 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 229abdd1ef8..8c619ffec5a 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 087c5bbe072..a0ff625a41a 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -571,7 +571,7 @@ public:
 
 	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 @@ public:
 	    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);
@@ -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 8b6da41ffeb..4d93859f38e 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -393,7 +393,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."));
 
@@ -1736,7 +1736,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 9571c866276..0f86f6efe38 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -666,7 +666,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);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.