Fix assertion failure in linux-thread-db
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 27 Aug 2015 17:12:49 +0000 (19:12 +0200)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 27 Aug 2015 17:12:49 +0000 (19:12 +0200)
Since we are no longer using thread events by default in linux-thread-db,
the find_new_threads_once routine contains an assertion that it should
never be called on a live inferior unless using thread events:
  gdb_assert (!target_has_execution || thread_db_use_events ());

However, there is a code path from thread_db_get_thread_local_address
that will in fact call find_new_threads_once in some scenarios.  In
particular, this is currently always triggered when starting up any
Cell/B.E. combined exeuctable.

To fix this, this patch removes the call to thread_db_find_new_threads_1
when the current thread was not yet detected.  In its place, we now just
call thread_from_lwp to detect this one thread if necessary.

ChangeLog:

* linux-thread-db.c (thread_db_get_thread_local_address): If the
thread was not yet discovered, use thread_from_lwp instead of
calling thread_db_find_new_threads_1.

gdb/ChangeLog
gdb/linux-thread-db.c

index b572271..8319083 100644 (file)
@@ -1,3 +1,9 @@
+2015-08-08  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       * linux-thread-db.c (thread_db_get_thread_local_address): If the
+       thread was not yet discovered, use thread_from_lwp instead of
+       calling thread_db_find_new_threads_1.
+
 2015-08-27  Simon Marchi  <simon.marchi@ericsson.com>
 
        * m88k-tdep.c (m88k_analyze_prologue): Fix inverted allocation
index d6bf56f..855629b 100644 (file)
@@ -1849,13 +1849,16 @@ thread_db_get_thread_local_address (struct target_ops *ops,
   struct thread_info *thread_info;
   struct target_ops *beneath;
 
-  /* If we have not discovered any threads yet, check now.  */
-  if (!have_threads (ptid))
-    thread_db_find_new_threads_1 (ptid);
-
   /* Find the matching thread.  */
   thread_info = find_thread_ptid (ptid);
 
+  /* We may not have discovered the thread yet.  */
+  if (thread_info != NULL && thread_info->priv == NULL)
+    {
+      thread_from_lwp (ptid);
+      thread_info = find_thread_ptid (ptid);
+    }
+
   if (thread_info != NULL && thread_info->priv != NULL)
     {
       td_err_e err;