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] Check for separate-debug-info version of libpthread


Hi.

I was seeing a failure in fork-child-threads.exp and traced it
to the fact that gdb had loaded the debug info for libpthread
and thus was looking for libthread_db in the same directory
which was failing.

This patch fixes that.

2011-05-15  Doug Evans  <dje@google.com>

	* linux-thread-db.c (try_thread_db_load_from_pdir_1): New function.
	(try_thread_db_load_from_pdir): Call it.  If unable to find
	libthread_db in directory of libpthread, see if we're looking at
	the separate-debug-info copy.

Index: linux-thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-thread-db.c,v
retrieving revision 1.85
diff -u -p -r1.85 linux-thread-db.c
--- linux-thread-db.c	13 May 2011 22:36:06 -0000	1.85
+++ linux-thread-db.c	16 May 2011 02:10:14 -0000
@@ -812,6 +812,38 @@ try_thread_db_load (const char *library)
   return 0;
 }
 
+/* Subroutine of try_thread_db_load_from_pdir to simplify it.
+   Try loading libthread_db from the same directory as OBJ.
+   The result is true for success.  */
+
+static int
+try_thread_db_load_from_pdir_1 (struct objfile *obj)
+{
+  char path[PATH_MAX], *cp;
+
+  gdb_assert (strlen (obj->name) < sizeof (path));
+  strcpy (path, obj->name);
+  cp = strrchr (path, '/');
+
+  if (cp == NULL)
+    {
+      warning (_("Expected absolute pathname for libpthread in the"
+		 " inferior, but got %s."), path);
+      return 0;
+    }
+  else if (cp + 1 + strlen (LIBTHREAD_DB_SO) + 1 > path + sizeof (path))
+    {
+      warning (_("Unexpected: path to libpthread in the inferior is"
+		 " too long: %s"), path);
+      return 0;
+    }
+  else
+    {
+      strcpy (cp + 1, LIBTHREAD_DB_SO);
+      return try_thread_db_load (path);
+    }
+}
+
 /* Handle $pdir in libthread-db-search-path.
    Look for libthread_db in the directory of libpthread.
    The result is true for success.  */
@@ -824,28 +856,15 @@ try_thread_db_load_from_pdir (void)
   ALL_OBJFILES (obj)
     if (libpthread_name_p (obj->name))
       {
-	char path[PATH_MAX], *cp;
+	if (try_thread_db_load_from_pdir_1 (obj))
+	  return 1;
+
+	/* We may have found the separate-debug-info version of
+	   libpthread, and it may live in a directory without a matching
+	   libthread_db.  */
+	if (obj->separate_debug_objfile_backlink != NULL)
+	  return try_thread_db_load_from_pdir_1 (obj->separate_debug_objfile_backlink);
 
-	gdb_assert (strlen (obj->name) < sizeof (path));
-	strcpy (path, obj->name);
-	cp = strrchr (path, '/');
-
-	if (cp == NULL)
-	  {
-	    warning (_("Expected absolute pathname for libpthread in the"
-		       " inferior, but got %s."), path);
-	  }
-	else if (cp + 1 + strlen (LIBTHREAD_DB_SO) + 1 > path + sizeof (path))
-	  {
-	    warning (_("Unexpected: path to libpthread in the inferior is"
-		       " too long: %s"), path);
-	  }
-	else
-	  {
-	    strcpy (cp + 1, LIBTHREAD_DB_SO);
-	    if (try_thread_db_load (path))
-	      return 1;
-	  }
 	return 0;
       }
 


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