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 2/2] Trim trailing directory separators from new sysroots.
Date: Wed, 23 Jan 2019 01:04:00 -0000	[thread overview]
Message-ID: <2c219947da76ada8ee0596dc61a4abef3ebdc256.1548205042.git.jhb@FreeBSD.org> (raw)
In-Reply-To: <cover.1548205042.git.jhb@FreeBSD.org>

The separate debugfile logic assumes that the sysroot does not include
a trailing separator (all of the sysroot logic in
find_separate_debug_file requires the next character after the sysroot
in a object file path to be a directory separator).  However, normal
filename completion will result in setting a sysroot with a trailing
directory separator.  If the directory portion of a new sysroot ends
with a directory separator and is not specifying the root directory,
trim the trailing separator.  This permits the sysroot logic to work
the same if a sysroot of "/myroot/" is specified instead of "/myroot".

Note that the sysroot displayed by 'show sysroot' will reflect the
trimmed sysroot.

gdb/ChangeLog:

	* solib.c (gdb_sysroot_changed): Trim trailing directory separator
	from new sysroot.
---
 gdb/ChangeLog | 5 +++++
 gdb/solib.c   | 8 ++++++++
 2 files changed, 13 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a401cfc784..c9f2d049bc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-22  John Baldwin  <jhb@FreeBSD.org>
+
+	* solib.c (gdb_sysroot_changed): Trim trailing directory separator
+	from new sysroot.
+
 2019-01-22  John Baldwin  <jhb@FreeBSD.org>
 
 	* symfile.c (find_separate_debug_file): Look for separate debug
diff --git a/gdb/solib.c b/gdb/solib.c
index 3a6db5e12d..a837f27c73 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1433,6 +1433,14 @@ gdb_sysroot_changed (const char *ignored, int from_tty,
 	}
     }
 
+  /* Trim trailing directory separator.  */
+  char *sysroot_dir = gdb_sysroot;
+  if (startswith (gdb_sysroot, TARGET_SYSROOT_PREFIX))
+    sysroot_dir += strlen (TARGET_SYSROOT_PREFIX);
+  size_t len = strlen (sysroot_dir);
+  if (len > 1 && IS_DIR_SEPARATOR (sysroot_dir[len - 1]))
+      sysroot_dir[len - 1] = '\0';
+
   reload_shared_libraries (ignored, from_tty, e);
 }
 
-- 
2.19.2


  reply	other threads:[~2019-01-23  1:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-23  1:04 [PATCH 0/2] Some fixes for debug files and sysroots John Baldwin
2019-01-23  1:04 ` John Baldwin [this message]
2019-01-26 19:10   ` [PATCH 2/2] Trim trailing directory separators from new sysroots Simon Marchi
2019-01-28 20:41     ` John Baldwin
2019-01-23  1:04 ` [PATCH 1/2] Look for separate debug files in debug directories under a sysroot John Baldwin
2019-01-26  5:17   ` Simon Marchi
2019-01-26 17:12     ` Simon Marchi
2019-01-28 18:53       ` John Baldwin
2019-02-22 20:51         ` Simon Marchi

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=2c219947da76ada8ee0596dc61a4abef3ebdc256.1548205042.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