From patchwork Tue Jun 16 09:42:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 7199 Received: (qmail 89511 invoked by alias); 16 Jun 2015 09:42:56 -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 89367 invoked by uid 89); 16 Jun 2015 09:42:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 16 Jun 2015 09:42:53 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id BE3A05A098; Tue, 16 Jun 2015 09:42:52 +0000 (UTC) Received: from blade.nx (ovpn-116-89.ams2.redhat.com [10.36.116.89]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5G9gq1J013492; Tue, 16 Jun 2015 05:42:52 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id AE8AC263005; Tue, 16 Jun 2015 10:42:51 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Cc: =?UTF-8?q?C=C3=A9dric=20Buissart?= Subject: [PATCH 3/5] Update how find_separate_debug_file handles CANON_DIR argument Date: Tue, 16 Jun 2015 10:42:46 +0100 Message-Id: <1434447768-17328-4-git-send-email-gbenson@redhat.com> In-Reply-To: <1434447768-17328-1-git-send-email-gbenson@redhat.com> References: <1434447768-17328-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes find_separate_debug_file's CANON_DIR argument is used to create an alternate location to search for debug files. This commit moves that logic out of the loop it's in and introduces a new variable altdir to hold the generated alternate location. A check is added to inhibit the altdir search if alternate location is the same as the regular location specified in DIR. A check was also added for gdb_sysroot == NULL, which the original code was missing. gdb/ChangeLog: * gdb/symfile.c (find_separate_debug_file): Move canon_dir logic out of loop. Add check for NULL gdb_sysroot. Don't check the same location twice. --- gdb/ChangeLog | 6 ++++++ gdb/symfile.c | 25 +++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/gdb/symfile.c b/gdb/symfile.c index 77aaeed..bae144e 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1536,6 +1536,7 @@ find_separate_debug_file (const char *dir, VEC (char_ptr) *debugdir_vec; struct cleanup *back_to; int ix; + const char *altdir = NULL; /* First try in the same directory as the original file. */ debugfile = build_debug_file_name (dir, debuglink, NULL); @@ -1558,6 +1559,20 @@ find_separate_debug_file (const char *dir, debugdir_vec = dirnames_to_char_ptr_vec (debug_file_directory); back_to = make_cleanup_free_char_ptr_vec (debugdir_vec); + /* If the file is in the sysroot, try its base path in the + global debugfile directory as an alternate location. */ + if (canon_dir != NULL + && gdb_sysroot != NULL && *gdb_sysroot != '\0' + && filename_ncmp (canon_dir, gdb_sysroot, + strlen (gdb_sysroot)) == 0 + && IS_DIR_SEPARATOR (canon_dir[strlen (gdb_sysroot)])) + { + altdir = canon_dir + strlen (gdb_sysroot); + + if (strcmp (altdir, dir) == 0) + altdir = NULL; + } + for (ix = 0; VEC_iterate (char_ptr, debugdir_vec, ix, debugdir); ++ix) { debugfile = build_debug_file_name (debugdir, dir, debuglink, @@ -1569,15 +1584,9 @@ find_separate_debug_file (const char *dir, } xfree (debugfile); - /* If the file is in the sysroot, try using its base path in the - 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)])) + if (altdir != NULL) { - debugfile = build_debug_file_name (debugdir, canon_dir - + strlen (gdb_sysroot), + debugfile = build_debug_file_name (debugdir, altdir, debuglink, NULL); if (separate_debug_file_exists (debugfile, crc32, objfile)) {