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]

[commit/AIX] cannot resume after attaching to process


Hello,

This is a patch that AdaCore has had in its internal tree for a little
while, now.  It fixes an issue on AIX where the user is unable to continue
after having attached to a problem that has threads.

The problem is that the thread debug library maintains a list of threads
which does not include the "main" thread.  As a result, when we try to
synchronize GDB's thread list with the list returned by the pthread
debug library, GDB thinks that the "main" thread has disappeared/died.
As such, it removes that thread from GDB's list of threads.  Later, when
we try to do a "continue", the inferior ptid is still set to that same
main thread.  That's when we detect that the thread is dead, and we
can't resume the execution of a thread that no longer exists...

The solution I chose was to tweak the iterators used to build GDB's list
of thread to exclude the main thread.  That thread is easy to identify,
as it's the only thread that has a null tid.  As a result, the main
thread is always excluded from the synchronization process, and stays
until the program exits.

2009-05-20  Joel Brobecker  <brobecker@adacore.com>

        * aix-thread.c (giter_count): Do not count the main thread.
        (giter_accum): Do not include the main thread.

Tested on powerpc-aix. Will commit shortly.

-- 
Joel
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 1eeeadb..35103f5 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -570,22 +570,36 @@ pcmp (const void *p1v, const void *p2v)
   return p1->pthid < p2->pthid ? -1 : p1->pthid > p2->pthid;
 }
 
-/* iterate_over_threads() callback for counting GDB threads.  */
+/* iterate_over_threads() callback for counting GDB threads.
+
+   Do not count the main thread (whose tid is zero).  This matches
+   the list of threads provided by the pthreaddebug library, which
+   does not include that main thread either, and thus allows us
+   to compare the two lists.  */
 
 static int
 giter_count (struct thread_info *thread, void *countp)
 {
-  (*(int *) countp)++;
+  if (PD_TID (thread->ptid))
+    (*(int *) countp)++;
   return 0;
 }
 
-/* iterate_over_threads() callback for accumulating GDB thread pids.  */
+/* iterate_over_threads() callback for accumulating GDB thread pids.
+
+   Do not include the main thread (whose tid is zero).  This matches
+   the list of threads provided by the pthreaddebug library, which
+   does not include that main thread either, and thus allows us
+   to compare the two lists.  */
 
 static int
 giter_accum (struct thread_info *thread, void *bufp)
 {
-  **(struct thread_info ***) bufp = thread;
-  (*(struct thread_info ***) bufp)++;
+  if (PD_TID (thread->ptid))
+    {
+      **(struct thread_info ***) bufp = thread;
+      (*(struct thread_info ***) bufp)++;
+    }
   return 0;
 }
 

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