Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
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 20:53:00 -0000	[thread overview]
Message-ID: <5fc92b598a9f6354ecbe51b4922afcbc71984794.1548707934.git.jhb@FreeBSD.org> (raw)
In-Reply-To: <cover.1548707934.git.jhb@FreeBSD.org>

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  <jhb@FreeBSD.org>
+
+	* 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  <jhb@FreeBSD.org>
 
 	* 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<gdb::unique_xmalloc_ptr<char>> debugdir_vec
     = dirnames_to_char_ptr_vec (debug_file_directory);
+  gdb::unique_xmalloc_ptr<char> canon_sysroot = gdb_realpath (gdb_sysroot);
 
   for (const gdb::unique_xmalloc_ptr<char> &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.  */
-- 
2.19.2


  parent reply	other threads:[~2019-01-28 20:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-28 20:47 [PATCH v2 0/4] Some fixes for debug files and sysroots John Baldwin
2019-01-28 20:47 ` [PATCH v2 3/4] Use child_path to determine if an object file is under a sysroot John Baldwin
2019-01-28 20:47 ` [PATCH v2 1/4] Look for separate debug files in debug directories " John Baldwin
2019-01-28 20:47 ` [PATCH v2 2/4] Add a new function child_path John Baldwin
2019-02-12  2:43   ` Simon Marchi
2019-02-12  2:46     ` Simon Marchi
2019-02-12 16:52       ` John Baldwin
2019-02-12 16:56         ` Simon Marchi
2019-01-28 20:53 ` John Baldwin [this message]
2019-02-11 17:54 ` [PING] [PATCH v2 0/4] Some fixes for debug files and sysroots John Baldwin
2019-02-12  2:53   ` Simon Marchi
2019-02-12 21:59     ` John Baldwin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5fc92b598a9f6354ecbe51b4922afcbc71984794.1548707934.git.jhb@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox