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]

[PATCH] Improve "set debug separate-debug-file"


"set debug separate-debug-file" shows which candidates are considered,
when trying to find separate debug info.  But it's not clear if GDB used
a certain candidate, and if not, why not.  This patch adds some
precision:

Before:

  Looking for separate debug info (debug link) for /lib/x86_64-linux-gnu/libc.so.6
    Trying /lib/x86_64-linux-gnu/libc-2.23.so
    Trying /lib/x86_64-linux-gnu/.debug/libc-2.23.so
    Trying /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.23.so

After:

  Looking for separate debug info (debug link) for /lib/x86_64-linux-gnu/libc.so.6
    Trying /lib/x86_64-linux-gnu/libc-2.23.so... no, same file as the objfile.
    Trying /lib/x86_64-linux-gnu/.debug/libc-2.23.so... no, unable to open.
    Trying /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.23.so... yes!

gdb/ChangeLog:

	* build-id.c (build_id_to_debug_bfd): Enhance debug output.
	* symfile.c (separate_debug_file_exists): Likewise.
---
 gdb/build-id.c | 28 ++++++++++++++++++++++++----
 gdb/symfile.c  | 36 +++++++++++++++++++++++++++++++-----
 2 files changed, 55 insertions(+), 9 deletions(-)

diff --git a/gdb/build-id.c b/gdb/build-id.c
index c8eacbd1e81..1211d88a8ad 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -98,7 +98,7 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
       link += ".debug";
 
       if (separate_debug_file_debug)
-	printf_unfiltered (_("  Trying %s\n"), link.c_str ());
+	printf_unfiltered (_("  Trying %s..."), link.c_str ());
 
       /* lrealpath() is expensive even for the usually non-existent files.  */
       gdb::unique_xmalloc_ptr<char> filename;
@@ -106,16 +106,36 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
 	filename.reset (lrealpath (link.c_str ()));
 
       if (filename == NULL)
-	continue;
+	{
+	  if (separate_debug_file_debug)
+	    printf_unfiltered (_(" no, unable to compute real path\n"));
+
+	  continue;
+	}
 
       /* We expect to be silent on the non-existing files.  */
       abfd = gdb_bfd_open (filename.get (), gnutarget, -1);
 
       if (abfd == NULL)
-	continue;
+	{
+	  if (separate_debug_file_debug)
+	    printf_unfiltered (_(" no, unable to open.\n"));
+
+	  continue;
+	}
 
       if (build_id_verify (abfd.get(), build_id_len, build_id))
-	break;
+	{
+	  if (separate_debug_file_debug)
+	    printf_unfiltered (_(" yes!\n"));
+
+	  break;
+	}
+      else
+	{
+	  if (separate_debug_file_debug)
+	    printf_unfiltered (_(" no, build-id does not match.\n"));
+	}
 
       abfd.release ();
     }
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 8ab6a25de7c..c5e2661415f 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1285,12 +1285,17 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
     return 0;
 
   if (separate_debug_file_debug)
-    printf_filtered (_("  Trying %s\n"), name.c_str ());
+    printf_filtered (_("  Trying %s..."), name.c_str ());
 
   gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget, -1));
 
   if (abfd == NULL)
-    return 0;
+    {
+      if (separate_debug_file_debug)
+	printf_filtered (_(" no, unable to open.\n"));
+
+      return 0;
+    }
 
   /* Verify symlinks were not the cause of filename_cmp name difference above.
 
@@ -1309,7 +1314,12 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
     {
       if (abfd_stat.st_dev == parent_stat.st_dev
 	  && abfd_stat.st_ino == parent_stat.st_ino)
-	return 0;
+	{
+	  if (separate_debug_file_debug)
+	    printf_filtered (_(" no, same file as the objfile.\n"));
+
+	  return 0;
+	}
       verified_as_different = 1;
     }
   else
@@ -1318,7 +1328,12 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
   file_crc_p = gdb_bfd_crc (abfd.get (), &file_crc);
 
   if (!file_crc_p)
-    return 0;
+    {
+      if (separate_debug_file_debug)
+	printf_filtered (_(" no, error computing CRC.\n"));
+
+      return 0;
+    }
 
   if (crc != file_crc)
     {
@@ -1331,7 +1346,12 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
       if (!verified_as_different)
 	{
 	  if (!gdb_bfd_crc (parent_objfile->obfd, &parent_crc))
-	    return 0;
+	    {
+	      if (separate_debug_file_debug)
+		printf_filtered (_(" no, error computing CRC.\n"));
+
+	      return 0;
+	    }
 	}
 
       if (verified_as_different || parent_crc != file_crc)
@@ -1339,9 +1359,15 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
 		   " does not match \"%s\" (CRC mismatch).\n"),
 		 name.c_str (), objfile_name (parent_objfile));
 
+      if (separate_debug_file_debug)
+	printf_filtered (_(" no, CRC doesn't match.\n"));
+
       return 0;
     }
 
+  if (separate_debug_file_debug)
+    printf_filtered (_(" yes!\n"));
+
   return 1;
 }
 
-- 
2.20.1


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