From patchwork Wed Jan 23 01:03:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 31174 Received: (qmail 52806 invoked by alias); 23 Jan 2019 01:04:16 -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 52752 invoked by uid 89); 23 Jan 2019 01:04:15 -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=roots, 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; Wed, 23 Jan 2019 01:04:12 +0000 Received: from ralph.com (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id CE18810AFD2 for ; Tue, 22 Jan 2019 20:04:10 -0500 (EST) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH 1/2] Look for separate debug files in debug directories under a sysroot. Date: Tue, 22 Jan 2019 17:03:43 -0800 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-IsSubscribed: yes 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 | 5 +++++ gdb/symfile.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 938fa83ca8..a401cfc784 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-01-22 John Baldwin + + * symfile.c (find_separate_debug_file): Look for separate debug + files in debug directories under the sysroot. + 2019-01-22 John Baldwin * ppc-fbsd-tdep.c (ppcfbsd_get_thread_local_address): New. diff --git a/gdb/symfile.c b/gdb/symfile.c index 7f800add8c..c6d2c7c537 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1465,6 +1465,25 @@ 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 + sysroot's 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)])) + { + 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 ();