From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Cc: "Cédric Buissart" <cedric.buissart@gmail.com>
Subject: [PATCH 3/5] Update how find_separate_debug_file handles CANON_DIR argument
Date: Tue, 16 Jun 2015 09:42:00 -0000 [thread overview]
Message-ID: <1434447768-17328-4-git-send-email-gbenson@redhat.com> (raw)
In-Reply-To: <1434447768-17328-1-git-send-email-gbenson@redhat.com>
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))
{
--
1.7.1
next prev parent reply other threads:[~2015-06-16 9:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-16 9:42 [PATCH 0/5] Separate debugfile improvements Gary Benson
2015-06-16 9:42 ` [PATCH 2/5] Pre-strip now-unnecessary trailing directory separators Gary Benson
2015-07-01 13:45 ` Pedro Alves
2015-06-16 9:42 ` Gary Benson [this message]
2015-07-01 11:13 ` [PATCH 3/5] Update how find_separate_debug_file handles CANON_DIR argument Pedro Alves
2015-06-16 9:42 ` [PATCH 1/5] Introduce build_debug_file_name Gary Benson
2015-06-16 14:47 ` Eli Zaretskii
2015-06-17 9:47 ` Gary Benson
2015-06-17 16:42 ` Eli Zaretskii
2015-06-18 10:55 ` Gary Benson
2015-06-18 12:11 ` Eli Zaretskii
2015-06-19 8:32 ` Gary Benson
2015-07-01 11:05 ` Pedro Alves
2015-07-02 11:18 ` Gary Benson
2015-07-02 11:38 ` Pedro Alves
2015-07-02 13:53 ` Gary Benson
2015-07-25 16:20 ` Jan Kratochvil
2015-06-16 9:48 ` [PATCH 4/5] Add "target:" filename handling to find_separate_debug_file Gary Benson
2015-07-01 13:35 ` Pedro Alves
2015-07-23 14:33 ` Gary Benson
2015-07-24 10:28 ` Gary Benson
2015-07-24 11:54 ` Gary Benson
2015-07-25 18:15 ` Jan Kratochvil
2015-06-16 9:50 ` [PATCH 5/5] Also look for debug files in gdb_sysroot Gary Benson
2015-07-01 13:45 ` Pedro Alves
2015-06-23 8:44 ` [PING][PATCH 0/5] Separate debugfile improvements Gary Benson
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=1434447768-17328-4-git-send-email-gbenson@redhat.com \
--to=gbenson@redhat.com \
--cc=cedric.buissart@gmail.com \
--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