]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Look for separate debug files in debug directories under a sysroot.
authorJohn Baldwin <jhb@FreeBSD.org>
Tue, 12 Feb 2019 21:56:16 +0000 (13:56 -0800)
committerJohn Baldwin <jhb@FreeBSD.org>
Tue, 12 Feb 2019 21:56:16 +0000 (13:56 -0800)
When an object file is present in a system root, GDB currently looks
for separate debug files under the global debugfile directories.  For
example, if the sysroot is set to "/myroot" and hte global debugfile
directory is set to "/usr/lib/debug", GDB will look for a separate
debug file for "/myroot/lib/libc.so.7" in the following paths:

  /myroot/lib/libc.so.7.debug
  /myroot/lib/.debug/libc.so.7.debug
  /usr/lib/debug//myroot/lib/libc.so.7.debug
  /usr/lib/debug/lib/libc.so.7.debug

However, some system roots include a full system installation
including a nested global debugfile directory under the sysroot.  This
patch adds an additional check to support such systems.  In the
example above the additional path searched is:

  /myroot/usr/lib/debug/lib/libc.so.7.debug

To try to preserve existing behavior as much as possible, this new
path is searched last for each global debugfile directory.

gdb/ChangeLog:

* symfile.c (find_separate_debug_file): Look for separate debug
files in debug directories under the sysroot.

gdb/ChangeLog
gdb/symfile.c

index 194ae4657692f40d96e64c539ef91822cc725b4f..e4f74cdc3e862959dff9b5b2e39b2f5fdb488044 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-12  John Baldwin  <jhb@FreeBSD.org>
+
+       * symfile.c (find_separate_debug_file): Look for separate debug
+       files in debug directories under the sysroot.
+
 2019-02-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
        * symtab.h (struct minimal_symbol data_p): New const method.
index e5ff38462c5e7792b152359fdc8363dc4e863278..b5802e20adc5f1a8a640af0058132f09bae1ce87 100644 (file)
@@ -1452,22 +1452,35 @@ find_separate_debug_file (const char *dir,
       if (separate_debug_file_exists (debugfile, crc32, objfile))
        return debugfile;
 
-      /* If the file is in the sysroot, try using its base path in the
-        global debugfile directory.  */
       if (canon_dir != NULL
          && filename_ncmp (canon_dir, gdb_sysroot,
                            strlen (gdb_sysroot)) == 0
          && IS_DIR_SEPARATOR (canon_dir[strlen (gdb_sysroot)]))
        {
+         /* If the file is in the sysroot, try using its base path in
+            the global debugfile directory.  */
          debugfile = target_prefix ? "target:" : "";
          debugfile += debugdir.get ();
          debugfile += (canon_dir + strlen (gdb_sysroot));
          debugfile += "/";
          debugfile += debuglink;
 
+         if (separate_debug_file_exists (debugfile, crc32, objfile))
+           return debugfile;
+
+         /* If the file is in the sysroot, try using its base path in
+            the sysroot's global debugfile directory.  */
+         debugfile = target_prefix ? "target:" : "";
+         debugfile += gdb_sysroot;
+         debugfile += debugdir.get ();
+         debugfile += (canon_dir + strlen (gdb_sysroot));
+         debugfile += "/";
+         debugfile += debuglink;
+
          if (separate_debug_file_exists (debugfile, crc32, objfile))
            return debugfile;
        }
+
     }
 
   return std::string ();