This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Make "info threads" look for threads in all inferiors in linux native too.


"info threads" currently displays threads of all inferiors.
But linux-thread-db.c's target_find_new_threads implementation only
tried to find new threads of the current inferior, unlike, e.g., the
remote.c implementation.  This fixes it.

Tested on x86_64-linux and applied.

-- 
Pedro Alves

2011-09-13  Pedro Alves  <pedro@codesourcery.com>

	gdb/
	* inferior.h (ALL_INFERIORS): New.
	* linux-thread-db.c (thread_db_find_new_threads_2): Remove check
	for a stopped thread.
	(thread_db_find_new_threads): Look for threads in all inferiors.

---
 gdb/inferior.h        |    5 +++++
 gdb/linux-thread-db.c |   34 ++++++++++++++++------------------
 2 files changed, 21 insertions(+), 18 deletions(-)

Index: src/gdb/inferior.h
===================================================================
--- src.orig/gdb/inferior.h	2011-09-13 18:04:19.361056835 +0100
+++ src/gdb/inferior.h	2011-09-13 18:32:32.111057421 +0100
@@ -615,6 +615,11 @@ extern void set_current_inferior (struct
 
 extern struct cleanup *save_current_inferior (void);
 
+/* Traverse all inferiors.  */
+
+#define ALL_INFERIORS(I) \
+  for ((I) = inferior_list; (I); (I) = (I)->next)
+
 extern struct inferior *inferior_list;
 
 /* Prune away automatically added inferiors that aren't required
Index: src/gdb/linux-thread-db.c
===================================================================
--- src.orig/gdb/linux-thread-db.c	2011-09-13 18:04:19.361056835 +0100
+++ src/gdb/linux-thread-db.c	2011-09-13 18:32:32.111057421 +0100
@@ -1552,20 +1552,6 @@ thread_db_find_new_threads_2 (ptid_t pti
   int pid = ptid_get_pid (ptid);
   int i, loop;
 
-  if (target_has_execution)
-    {
-      struct lwp_info *lp;
-
-      /* In linux, we can only read memory through a stopped lwp.  */
-      ALL_LWPS (lp, ptid)
-	if (lp->stopped && ptid_get_pid (lp->ptid) == pid)
-	  break;
-
-      if (!lp)
-	/* There is no stopped thread.  Bail out.  */
-	return;
-    }
-
   info = get_thread_db_info (GET_PID (ptid));
 
   /* Access an lwp we know is stopped.  */
@@ -1607,13 +1593,25 @@ static void
 thread_db_find_new_threads (struct target_ops *ops)
 {
   struct thread_db_info *info;
+  struct inferior *inf;
 
-  info = get_thread_db_info (GET_PID (inferior_ptid));
+  ALL_INFERIORS (inf)
+    {
+      struct thread_info *thread;
+
+      if (inf->pid == 0)
+	continue;
 
-  if (info == NULL)
-    return;
+      info = get_thread_db_info (inf->pid);
+      if (info == NULL)
+	continue;
 
-  thread_db_find_new_threads_1 (inferior_ptid);
+      thread = any_live_thread_of_process (inf->pid);
+      if (thread == NULL || thread->executing)
+	continue;
+
+      thread_db_find_new_threads_1 (thread->ptid);
+    }
 
   if (target_has_execution)
     iterate_over_lwps (minus_one_ptid /* iterate over all */,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]