From patchwork Wed Jan 23 01:03:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 31175 Received: (qmail 52912 invoked by alias); 23 Jan 2019 01:04:17 -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 52751 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=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:13 +0000 Received: from ralph.com (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 8B33710B4CE for ; Tue, 22 Jan 2019 20:04:11 -0500 (EST) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH 2/2] Trim trailing directory separators from new sysroots. Date: Tue, 22 Jan 2019 17:03:44 -0800 Message-Id: <2c219947da76ada8ee0596dc61a4abef3ebdc256.1548205042.git.jhb@FreeBSD.org> In-Reply-To: References: MIME-Version: 1.0 X-IsSubscribed: yes 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 + + * solib.c (gdb_sysroot_changed): Trim trailing directory separator + from new sysroot. + 2019-01-22 John Baldwin * 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); }