[PATCH 5/5] Also look for debug files in gdb_sysroot

Gary Benson
2015-06-16T09:50:39Z

This commit makes GDB look for separate debug files in gdb_sysroot if
not found in the currently searched locations. This allows for easier
analysis of core files from foreign machines using the sysroot option.
The user creates or mounts a directory containing the necessary
binaries and debuginfo and then sets GDB's sysroot to that directory
before starting their debug session.

gdb/ChangeLog:

* gdb/symfile.c (find_separate_debug_file): In debugdir loop,
also try alternate directory prefixed with gdb_sysroot.
---
gdb/ChangeLog | 6 ++++++
gdb/symfile.c | 11 +++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/gdb/symfile.c b/gdb/symfile.c
index 0cc940a..1cd99ea 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1613,6 +1613,7 @@ find_separate_debug_file (const char *dir,

if (altdir != NULL)
{
+ /* Try in the alternate directory directly. */
debugfile = build_debug_file_name (no_prefix, debugdir,
altdir, debuglink, NULL);
if (separate_debug_file_exists (debugfile, crc32, objfile))
@@ -1621,6 +1622,16 @@ find_separate_debug_file (const char *dir,
return debugfile;
}
xfree (debugfile);
+
+ /* Try in the alternate directory in gdb_sysroot. */
+ debugfile = build_debug_file_name (gdb_sysroot, debugdir,
+ altdir, debuglink, NULL);
+ if (separate_debug_file_exists (debugfile, crc32, objfile))
+ {
+ do_cleanups (back_to);
+ return debugfile;
+ }
+ xfree (debugfile);
}
}

--
1.7.1