From patchwork Mon Jan 28 20:47:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 31234 Received: (qmail 120298 invoked by alias); 28 Jan 2019 20:53:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 120289 invoked by uid 89); 28 Jan 2019 20:53:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 28 Jan 2019 20:53:31 +0000 Received: from ralph.baldwin.cx (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 6CDC210B6E9 for ; Mon, 28 Jan 2019 15:47:15 -0500 (EST) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH v2 4/4] Try to use the canonical version of a sysroot for debug file links. Date: Mon, 28 Jan 2019 12:47:05 -0800 Message-Id: <5fc92b598a9f6354ecbe51b4922afcbc71984794.1548707934.git.jhb@FreeBSD.org> In-Reply-To: References: MIME-Version: 1.0 X-IsSubscribed: yes Object file paths passed to find_separate_debug_file are always canonical paths with symbolic links resolved. If a sysroot path traverses a symbolic link, it will not match the object file paths. Generate a canonical version of the sysroot directory. If it is valid, use it instead of gdb_sysroot with child_path to dtermine if an object file is under a system root. gdb/ChangeLog: * symfile.c (find_separate_debug_file): Use canonical path of sysroot while child_path instead of gdb_sysroot if it is valid. --- gdb/ChangeLog | 5 +++++ gdb/symfile.c | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e65182d84d..f581c63198 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-01-28 John Baldwin + + * symfile.c (find_separate_debug_file): Use canonical path of + sysroot while child_path instead of gdb_sysroot if it is valid. + 2019-01-28 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. */