[patch 8/9] Fix .gdb_index for real and absolute filenames
Jan Kratochvil
jan.kratochvil@redhat.com
Thu Jan 17 22:24:00 GMT 2013
Hi,
other issues apply also for .gdb_index.
Thanks,
Jan
gdb/
2013-01-15 Jan Kratochvil <jan.kratochvil@redhat.com>
* dwarf2read.c (dw2_expand_symtabs_matching): New variable
this_real_name. Use it with dw2_get_real_path for file_matcher.
(file_full_name): Prepend COMP_DIR even for relative lh->INCLUDE_DIRS.
* symtab.c (search_symbols): New variable match. Match FILES also
against gdb_realpath.
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3572,11 +3572,20 @@ dw2_expand_symtabs_matching
for (j = 0; j < file_data->num_file_names; ++j)
{
+ const char *this_real_name;
+
if (file_matcher (file_data->file_names[j], data))
{
per_cu->v.quick->mark = 1;
break;
}
+
+ this_real_name = dw2_get_real_path (objfile, file_data, j);
+ if (file_matcher (this_real_name, data))
+ {
+ per_cu->v.quick->mark = 1;
+ break;
+ }
}
slot = htab_find_slot (per_cu->v.quick->mark
@@ -18054,23 +18063,19 @@ file_full_name (int file, struct line_header *lh, const char *comp_dir)
else
{
const char *dir;
- int dir_len;
- char *full_name;
- if (fe->dir_index)
- dir = lh->include_dirs[fe->dir_index - 1];
- else
+ if (fe->dir_index == 0)
dir = comp_dir;
+ else
+ {
+ dir = lh->include_dirs[fe->dir_index - 1];
+ if (!IS_ABSOLUTE_PATH (dir))
+ return concat (comp_dir, SLASH_STRING, dir, SLASH_STRING,
+ fe->name, NULL);
+ }
if (dir)
- {
- dir_len = strlen (dir);
- full_name = xmalloc (dir_len + 1 + strlen (fe->name) + 1);
- strcpy (full_name, dir);
- full_name[dir_len] = '/';
- strcpy (full_name + dir_len + 1, fe->name);
- return full_name;
- }
+ return concat (dir, SLASH_STRING, fe->name, NULL);
else
return xstrdup (fe->name);
}
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3604,10 +3604,24 @@ search_symbols (char *regexp, enum search_domain kind,
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
struct symtab *real_symtab = SYMBOL_SYMTAB (sym);
+ int match = 0;
QUIT;
- if (file_matches (symtab_to_fullname (real_symtab), files, nfiles)
+ if (file_matches (symtab_to_fullname (real_symtab), files, nfiles))
+ match = 1;
+ else if (basenames_may_differ
+ || file_matches (lbasename (real_symtab->filename), files,
+ nfiles))
+ {
+ char *symtab_real;
+
+ symtab_real = gdb_realpath (symtab_to_fullname (real_symtab));
+ if (file_matches (symtab_real, files, nfiles))
+ match = 1;
+ xfree (symtab_real);
+ }
+ if (match
&& ((!datum.preg_p
|| regexec (&datum.preg, SYMBOL_NATURAL_NAME (sym), 0,
NULL, 0) == 0)
More information about the Gdb-patches
mailing list