aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2013-02-03 16:00:36 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2013-02-03 16:00:36 +0000
commitaf529f8f61348016fc75bcb2e09c8f5d8bd1cc3a (patch)
tree35fad556c4526038451b6e46eb1c7264e94dfc54 /gdb/symtab.c
parent2f202fde0a4586f88b98439b436e7b0bb1336b26 (diff)
downloadgdb-af529f8f61348016fc75bcb2e09c8f5d8bd1cc3a.zip
gdb-af529f8f61348016fc75bcb2e09c8f5d8bd1cc3a.tar.gz
gdb-af529f8f61348016fc75bcb2e09c8f5d8bd1cc3a.tar.bz2
gdb/
Code cleanup. * breakpoint.c (clear_command): Remove variable is_abs, unify the call of filename_cmp with compare_filenames_for_search. * dwarf2read.c (dw2_map_symtabs_matching_filename): Remove variable is_abs, unify the call of FILENAME_CMP with compare_filenames_for_search. New gdb_asserts for real_path and name. Unify the call of compare_filenames_for_search with FILENAME_CMP. * psymtab.c (partial_map_symtabs_matching_filename): Likewise. * symfile.h (struct quick_symbol_functions): Extend the comment for map_symtabs_matching_filename. * symtab.c (compare_filenames_for_search): Remove the function comment relative path requirement. Handle absolute filenames, with a comment. (iterate_over_some_symtabs): Remove variable is_abs, unify the call of FILENAME_CMP with compare_filenames_for_search. New gdb_asserts for real_path and name. Unify the call of compare_filenames_for_search with FILENAME_CMP. (iterate_over_symtabs): New gdb_assert on REAL_PATH. gdb/testsuite/ * gdb.mi/mi-fullname-deleted.exp: Use double last slash for $srcfileabs. (compare_filenames_for_search does not match) (compare_filenames_for_search does match): New tests.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 3615cbf..15c845e 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -146,8 +146,8 @@ const struct block *block_found;
/* See whether FILENAME matches SEARCH_NAME using the rule that we
advertise to the user. (The manual's description of linespecs
- describes what we advertise). We assume that SEARCH_NAME is
- a relative path. Returns true if they match, false otherwise. */
+ describes what we advertise). Returns true if they match, false
+ otherwise. */
int
compare_filenames_for_search (const char *filename, const char *search_name)
@@ -166,12 +166,18 @@ compare_filenames_for_search (const char *filename, const char *search_name)
preceding the trailing SEARCH_NAME segment of FILENAME must be a
directory separator.
+ The check !IS_ABSOLUTE_PATH ensures SEARCH_NAME "/dir/file.c"
+ cannot match FILENAME "/path//dir/file.c" - as user has requested
+ absolute path. The sama applies for "c:\file.c" possibly
+ incorrectly hypothetically matching "d:\dir\c:\file.c".
+
The HAS_DRIVE_SPEC purpose is to make FILENAME "c:file.c"
compatible with SEARCH_NAME "file.c". In such case a compiler had
to put the "c:file.c" name into debug info. Such compatibility
works only on GDB built for DOS host. */
return (len == search_len
- || IS_DIR_SEPARATOR (filename[len - search_len - 1])
+ || (!IS_ABSOLUTE_PATH (search_name)
+ && IS_DIR_SEPARATOR (filename[len - search_len - 1]))
|| (HAS_DRIVE_SPEC (filename)
&& STRIP_DRIVE_SPEC (filename) == &filename[len - search_len]));
}
@@ -198,18 +204,10 @@ iterate_over_some_symtabs (const char *name,
{
struct symtab *s = NULL;
const char* base_name = lbasename (name);
- int is_abs = IS_ABSOLUTE_PATH (name);
for (s = first; s != NULL && s != after_last; s = s->next)
{
- /* Exact match is always ok. */
- if (FILENAME_CMP (name, s->filename) == 0)
- {
- if (callback (s, data))
- return 1;
- }
-
- if (!is_abs && compare_filenames_for_search (s->filename, name))
+ if (compare_filenames_for_search (s->filename, name))
{
if (callback (s, data))
return 1;
@@ -228,17 +226,13 @@ iterate_over_some_symtabs (const char *name,
{
const char *fullname = symtab_to_fullname (s);
+ gdb_assert (IS_ABSOLUTE_PATH (real_path));
+ gdb_assert (IS_ABSOLUTE_PATH (name));
if (FILENAME_CMP (real_path, fullname) == 0)
{
if (callback (s, data))
return 1;
}
-
- if (!is_abs && compare_filenames_for_search (fullname, name))
- {
- if (callback (s, data))
- return 1;
- }
}
}
@@ -268,6 +262,7 @@ iterate_over_symtabs (const char *name,
{
real_path = gdb_realpath (name);
make_cleanup (xfree, real_path);
+ gdb_assert (IS_ABSOLUTE_PATH (real_path));
}
ALL_OBJFILES (objfile)