diff --git a/gdb/ChangeLog b/gdb/ChangeLog index de88a210b4..191863e491 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-02-12 John Baldwin + + * symfile.c (find_separate_debug_file): Use canonical path of + sysroot with child_path instead of gdb_sysroot if it is valid. + 2019-02-12 John Baldwin * symfile.c (find_separate_debug_file): Use child_path to diff --git a/gdb/symfile.c b/gdb/symfile.c index ffcba1a090..61483824f6 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1441,6 +1441,7 @@ find_separate_debug_file (const char *dir, const char *dir_notarget = target_prefix ? dir + strlen ("target:") : dir; std::vector> debugdir_vec = dirnames_to_char_ptr_vec (debug_file_directory); + gdb::unique_xmalloc_ptr canon_sysroot = gdb_realpath (gdb_sysroot); for (const gdb::unique_xmalloc_ptr &debugdir : debugdir_vec) { @@ -1453,9 +1454,15 @@ find_separate_debug_file (const char *dir, if (separate_debug_file_exists (debugfile, crc32, objfile)) return debugfile; - const char *base_path; - if (canon_dir != NULL - && (base_path = child_path (gdb_sysroot, canon_dir)) != NULL) + const char *base_path = NULL; + if (canon_dir != NULL) + { + if (canon_sysroot.get () != NULL) + base_path = child_path (canon_sysroot.get (), canon_dir); + else + base_path = child_path (gdb_sysroot, canon_dir); + } + if (base_path != NULL) { /* If the file is in the sysroot, try using its base path in the global debugfile directory. */