about summary refs log tree commit diff
path: root/nptl_db/td_thr_validate.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2004-06-01 21:42:02 +0000
committerRoland McGrath <roland@gnu.org>2004-06-01 21:42:02 +0000
commit090addb473b6e5e1fa23fbf5525bfe468f4ca459 (patch)
treece25f2a4c69a76a41285004d0663b6e7a84e43ee /nptl_db/td_thr_validate.c
parentfbf86ddab2cd53c0a63173c1eb8b39c2b970fb8d (diff)
downloadglibc-090addb473b6e5e1fa23fbf5525bfe468f4ca459.tar.gz
glibc-090addb473b6e5e1fa23fbf5525bfe468f4ca459.tar.xz
glibc-090addb473b6e5e1fa23fbf5525bfe468f4ca459.zip
2004-05-27 Roland McGrath <roland@redhat.com>
	* td_thr_validate.c: When we find no threads and the inferior appears
	uninitialized, validate the main thread as a special case.
Diffstat (limited to 'nptl_db/td_thr_validate.c')
-rw-r--r--nptl_db/td_thr_validate.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/nptl_db/td_thr_validate.c b/nptl_db/td_thr_validate.c
index e0b05f52e7..3d560a621b 100644
--- a/nptl_db/td_thr_validate.c
+++ b/nptl_db/td_thr_validate.c
@@ -1,5 +1,5 @@
 /* Validate a thread handle.
-   Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 1999.
 
@@ -19,10 +19,10 @@
    02111-1307 USA.  */
 
 #include "thread_dbP.h"
-
+#include <stdbool.h>
 
 static td_err_e
-check_thread_list (const td_thrhandle_t *th, psaddr_t head)
+check_thread_list (const td_thrhandle_t *th, psaddr_t head, bool *uninit)
 {
   td_err_e err;
   psaddr_t next, ofs;
@@ -31,7 +31,10 @@ check_thread_list (const td_thrhandle_t *th, psaddr_t head)
   if (err == TD_OK)
     {
       if (next == 0)
-	return TD_NOTHR;
+	{
+	  *uninit = true;
+	  return TD_NOTHR;
+	}
       err = DB_GET_FIELD_ADDRESS (ofs, th->th_ta_p, 0, pthread, list, 0);
     }
 
@@ -59,9 +62,10 @@ td_thr_validate (const td_thrhandle_t *th)
   LOG ("td_thr_validate");
 
   /* First check the list with threads using user allocated stacks.  */
+  bool uninit = false;
   err = DB_GET_SYMBOL (list, th->th_ta_p, __stack_user);
   if (err == TD_OK)
-    err = check_thread_list (th, list);
+    err = check_thread_list (th, list, &uninit);
 
   /* If our thread is not on this list search the list with stack
      using implementation allocated stacks.  */
@@ -69,7 +73,18 @@ td_thr_validate (const td_thrhandle_t *th)
     {
       err = DB_GET_SYMBOL (list, th->th_ta_p, stack_used);
       if (err == TD_OK)
-	err = check_thread_list (th, list);
+	err = check_thread_list (th, list, &uninit);
+
+      if (err == TD_NOTHR && uninit)
+	{
+	  /* __pthread_initialize_minimal has not run yet.
+	     But the main thread still has a valid ID.  */
+	  td_thrhandle_t main_th;
+	  err = td_ta_map_lwp2thr (th->th_ta_p,
+				   ps_getpid (th->th_ta_p->ph), &main_th);
+	  if (err == TD_OK && th->th_unique != main_th.th_unique)
+	    err = TD_NOTHR;
+	}
     }
 
   return err;