]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb, multi-target: pass a target argument to delete_exited_threads
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Tue, 21 Apr 2026 07:11:02 +0000 (09:11 +0200)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Tue, 21 Apr 2026 07:11:02 +0000 (09:11 +0200)
Similar to the parent commit, delete_exited_threads is also mostly
used in the context of a particular target.  Pass that target as a
parameter and skip other targets.

There seems to be two cases where we actually would want to iterate
all targets.  One use is in inferior_appeared (inferior.c) and the
other is in thread_select (thread.c).  To handle these cases, allow
the argument to be nullptr.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/fbsd-nat.c
gdb/gdbthread.h
gdb/inferior.c
gdb/linux-nat.c
gdb/netbsd-nat.c
gdb/thread.c

index a1c7801ec1e68060e34937b0f0654d7b1c7ef4c8..706d6efd3426344d13b21f1eb8e940eb96c0f0e9 100644 (file)
@@ -1004,7 +1004,7 @@ fbsd_nat_target::update_thread_list ()
 #ifdef PT_LWP_EVENTS
   /* With support for thread events, threads are added/deleted from the
      list as events are reported, so just try deleting exited threads.  */
-  delete_exited_threads ();
+  delete_exited_threads (this);
 #else
   prune_threads (this);
 
index 1e3b42265aa8e0cd610d65304414d5a24f2aafd9..b3052b28d1abc6baea35c0d7b5f6a7dacdaff324 100644 (file)
@@ -983,9 +983,9 @@ extern void update_thread_list (void);
 extern void prune_threads (process_stratum_target *target);
 
 /* Delete threads marked THREAD_EXITED.  Unlike prune_threads, this
-   does not consult the target about whether the thread is alive right
-   now.  */
-extern void delete_exited_threads (void);
+   does not consult TARGET about whether the thread is alive right
+   now.  If TARGET is nullptr, operate on all targets.  */
+extern void delete_exited_threads (process_stratum_target *target);
 
 /* Return true if PC is in the stepping range of THREAD.  */
 
index e050dec402e8f421710d721f0c1a290bd131c1a3..1481f46cdd18210583383bead4c612b0cf87b833 100644 (file)
@@ -368,7 +368,7 @@ inferior_appeared (struct inferior *inf, int pid)
 {
   /* If this is the first inferior with threads, reset the global
      thread id.  */
-  delete_exited_threads ();
+  delete_exited_threads (nullptr);
   if (!any_thread_p ())
     init_thread_list ();
 
index 6018d6c9914086d48e695bd551103fc1b44ec2c2..d7d5e010748b7cbe6fffb6991b449f08eaea8dcf 100644 (file)
@@ -3967,7 +3967,7 @@ linux_nat_target::update_thread_list ()
   /* We add/delete threads from the list as clone/exit events are
      processed, so just try deleting exited threads still in the
      thread list.  */
-  delete_exited_threads ();
+  delete_exited_threads (this);
 
   /* Update the processor core that each lwp/thread was last seen
      running on.  */
index 6b9029bf0ef9d9098888ab6ee903d2f18a10b1e5..36bd91f968c3af3d4b363b52ba21ee670822876c 100644 (file)
@@ -155,7 +155,7 @@ nbsd_nat_target::post_attach (int pid)
 void
 nbsd_nat_target::update_thread_list ()
 {
-  delete_exited_threads ();
+  delete_exited_threads (this);
 }
 
 /* Convert PTID to a string.  */
index 64c06dc87f6527968d24407e3abf54c88ad1aa10..74124596b282b5d76d9e3bda63c14e8f4bea6d5c 100644 (file)
@@ -779,9 +779,9 @@ prune_threads (process_stratum_target *target)
 /* See gdbthreads.h.  */
 
 void
-delete_exited_threads (void)
+delete_exited_threads (process_stratum_target *target)
 {
-  for (thread_info &tp : all_threads_safe ())
+  for (thread_info &tp : all_threads_safe (target))
     if (tp.state () == THREAD_EXITED)
       delete_thread (&tp);
 }
@@ -2112,7 +2112,7 @@ thread_select (const char *tidstr, thread_info *tp)
 
   /* Since the current thread may have changed, see if there is any
      exited thread we can now delete.  */
-  delete_exited_threads ();
+  delete_exited_threads (nullptr);
 }
 
 /* Print thread and frame switch command response.  */