This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch 6/9] Mechanical symtab->filename -> symtab_to_filename
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 17 Jan 2013 23:22:42 +0100
- Subject: [patch 6/9] Mechanical symtab->filename -> symtab_to_filename
Hi,
this patch is mostly a mechanical substitution:
symtab->filename -> symtab_to_filename (symtab)
Few parts are still slightly non-trivial other cases, though.
Thanks,
Jan
gdb/
2013-01-15 Jan Kratochvil <jan.kratochvil@redhat.com>
* ada-lang.c (user_select_syms): Replace symtab->filename refererences
by symtab_to_filename calls.
* breakpoint.c (print_breakpoint_location, resolve_sal_pc): Likewise.
(clear_command): New variable sal_fullname, initialize it. Replace
compare_filenames_for_search by filename_cmp with sal_fullname.
(say_where, update_static_tracepoint): Replace symtab->filename
refererences by symtab_to_filename calls.
* cli/cli-cmds.c (edit_command, list_command, ambiguous_line_spec):
Likewise.
* dwarf2read.c: Include source.h.
(fixup_go_packaging): Replace symtab->filename refererences by
symtab_to_filename calls.
* linespec.c (add_sal_to_sals): Rename variable filename to fullname.
Replace symtab->filename refererences by symtab_to_filename calls.
(create_sals_line_offset, convert_linespec_to_sals): New variable
fullname, initialize it, replace symtab->filename reference by the
variable.
* linux-fork.c: Include source.h.
(info_checkpoints_command): Replace symtab->filename refererences by
symtab_to_filename calls.
* macroscope.c: Include source.h.
(sal_macro_scope): Replace symtab->filename refererences by
symtab_to_filename calls.
* mdebugread.c: Include source.h.
(psymtab_to_symtab_1): Replace symtab->filename refererences by
symtab_to_filename calls.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
(mi_cmd_file_list_exec_source_files): Likewise.
* printcmd.c: Include source.h.
(build_address_symbolic): Replace symtab->filename refererences by
symtab_to_filename calls.
* psymtab.c (partial_map_symtabs_matching_filename)
(read_psymtabs_with_fullname): Call compare_filenames_for_search also
with psymtab_to_fullname.
* python/py-symtab.c (stpy_str): Replace symtab->filename refererences
by symtab_to_filename calls.
(stpy_get_filename): New variable filename, initialize it, use instead
of symtab->filename refererences.
(salpy_str): Make variable filename const char *. Replace
symtab->filename refererences by symtab_to_filename calls.
* skip.c: Include source.h.
(skip_file_command): Remove const from the symtab variable. Replace
symtab->filename refererences by symtab_to_fullname call.
(function_name_is_marked_for_skip): New variables searched_for_fullname
and fullname. Use them to search also with symtab's fullname.
* source.c (find_source_lines): Replace symtab->filename refererences
by symtab_to_filename calls.
(print_source_lines_base): New variable filename, use it instead of
symtab->filename. Replace symtab->filename refererences by
symtab_to_filename calls.
(line_info, forward_search_command, reverse_search_command): Replace
symtab->filename refererences by symtab_to_filename calls.
* stack.c (frame_info): Likewise.
* symmisc.c: Include source.h.
(dump_objfile, dump_symtab_1, maintenance_print_symbols)
(maintenance_info_symtabs): Replace symtab->filename refererences by
symtab_to_filename calls.
* symtab.c (iterate_over_some_symtabs): Call
compare_filenames_for_search also with symtab_to_fullname. New comment
for fullpath fp variable.
(lookup_symbol_aux_quick, basic_lookup_transparent_type_quick): Replace
symtab->filename refererences by symtab_to_filename calls.
(find_line_symtab): Replace symtab->filename refererences by
symtab_to_filename calls.
(file_matches): Replace filename_cmp by compare_filenames_for_search.
(search_symbols): Replace symtab->filename refererence by
symtab_to_fullname call.
(print_symbol_info): Make the last parameter const char *. New
variable s_filename. Use it in the function.
(symtab_symbol_info): Make the last_filename variable const char *.
Replace symtab->filename refererences by symtab_to_filename calls.
(rbreak_command): New variable fullname. Use it. Replace
symtab->filename refererence by symtab_to_filename call.
* tracepoint.c (set_traceframe_context, trace_find_line_command)
(print_one_static_tracepoint_marker): Replace symtab->filename
refererences by symtab_to_filename calls.
* tui/tui-disasm.c (tui_show_disassem_and_update_source): Likewise.
* tui/tui-source.c (tui_set_source_content): New variable filename.
Replace symtab->filename refererences by this variable. Replace other
symtab->filename refererences by symtab_to_filename calls.
* tui/tui-stack.c: Include source.h.
(tui_show_frame_info): Replace symtab->filename refererences by
symtab_to_filename calls.
* tui/tui-winsource.c (tui_display_main): Likewise.
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3573,7 +3573,7 @@ See set/show multiple-symbol."));
else
printf_unfiltered (_("[%d] %s at %s:%d\n"), i + first_choice,
SYMBOL_PRINT_NAME (syms[i].sym),
- sal.symtab->filename, sal.line);
+ symtab_to_filename (sal.symtab), sal.line);
continue;
}
else
@@ -3588,7 +3588,8 @@ See set/show multiple-symbol."));
printf_unfiltered (_("[%d] %s at %s:%d\n"),
i + first_choice,
SYMBOL_PRINT_NAME (syms[i].sym),
- symtab->filename, SYMBOL_LINE (syms[i].sym));
+ symtab_to_filename (symtab),
+ SYMBOL_LINE (syms[i].sym));
else if (is_enumeral
&& TYPE_NAME (SYMBOL_TYPE (syms[i].sym)) != NULL)
{
@@ -3604,7 +3605,7 @@ See set/show multiple-symbol."));
: _("[%d] %s at %s:?\n"),
i + first_choice,
SYMBOL_PRINT_NAME (syms[i].sym),
- symtab->filename);
+ symtab_to_filename (symtab));
else
printf_unfiltered (is_enumeral
? _("[%d] %s (enumeral)\n")
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5711,9 +5711,9 @@ print_breakpoint_location (struct breakpoint *b,
ui_out_wrap_hint (uiout, wrap_indent_at_field (uiout, "what"));
ui_out_text (uiout, "at ");
}
- ui_out_field_string (uiout, "file", loc->symtab->filename);
+ ui_out_field_string (uiout, "file", symtab_to_filename (loc->symtab));
ui_out_text (uiout, ":");
-
+
if (ui_out_is_mi_like_p (uiout))
ui_out_field_string (uiout, "fullname",
symtab_to_fullname (loc->symtab));
@@ -9738,7 +9738,7 @@ resolve_sal_pc (struct symtab_and_line *sal)
{
if (!find_line_pc (sal->symtab, sal->line, &pc))
error (_("No line %d in file \"%s\"."),
- sal->line, sal->symtab->filename);
+ sal->line, symtab_to_filename (sal->symtab));
sal->pc = pc;
/* If this SAL corresponds to a breakpoint inserted using a line
@@ -11909,6 +11909,8 @@ clear_command (char *arg, int from_tty)
make_cleanup (VEC_cleanup (breakpoint_p), &found);
for (i = 0; i < sals.nelts; i++)
{
+ const char *sal_fullname;
+
/* If exact pc given, clear bpts at that pc.
If line given (pc == 0), clear all bpts on specified line.
If defaulting, clear all bpts on default line
@@ -11922,6 +11924,8 @@ clear_command (char *arg, int from_tty)
1 0 <can't happen> */
sal = sals.sals[i];
+ sal_fullname = (sal.symtab == NULL
+ ? NULL : symtab_to_fullname (sal.symtab));
/* Find all matching breakpoints and add them to 'found'. */
ALL_BREAKPOINTS (b)
@@ -11945,14 +11949,12 @@ clear_command (char *arg, int from_tty)
if ((default_match || sal.explicit_line)
&& loc->symtab != NULL
- && sal.symtab != NULL
+ && sal_fullname != NULL
&& sal.pspace == loc->pspace
- && loc->line_number == sal.line)
- {
- if (compare_filenames_for_search (loc->symtab->filename,
- sal.symtab->filename))
- line_match = 1;
- }
+ && loc->line_number == sal.line
+ && filename_cmp (symtab_to_fullname (loc->symtab),
+ sal_fullname) == 0)
+ line_match = 1;
if (pc_match || line_match)
{
@@ -12695,7 +12697,8 @@ say_where (struct breakpoint *b)
more nicely. */
if (b->loc->next == NULL)
printf_filtered (": file %s, line %d.",
- b->loc->symtab->filename, b->loc->line_number);
+ symtab_to_filename (b->loc->symtab),
+ b->loc->line_number);
else
/* This is not ideal, but each location may have a
different file name, and this at least reflects the
@@ -13894,7 +13897,7 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
SYMBOL_PRINT_NAME (sym));
ui_out_text (uiout, " at ");
}
- ui_out_field_string (uiout, "file", sal2.symtab->filename);
+ ui_out_field_string (uiout, "file", symtab_to_filename (sal2.symtab));
ui_out_text (uiout, ":");
if (ui_out_is_mi_like_p (uiout))
@@ -13912,7 +13915,7 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
xfree (b->addr_string);
b->addr_string = xstrprintf ("%s:%d",
- sal2.symtab->filename,
+ symtab_to_filename (sal2.symtab),
b->loc->line_number);
/* Might be nice to check if function changed, and warn if
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -823,11 +823,11 @@ edit_command (char *arg, int from_tty)
printf_filtered ("%s is in %s (%s:%d).\n",
paddress (gdbarch, sal.pc),
SYMBOL_PRINT_NAME (sym),
- sal.symtab->filename, sal.line);
+ symtab_to_filename (sal.symtab), sal.line);
else
printf_filtered ("%s is at %s:%d.\n",
paddress (gdbarch, sal.pc),
- sal.symtab->filename, sal.line);
+ symtab_to_filename (sal.symtab), sal.line);
}
/* If what was given does not imply a symtab, it must be an
@@ -986,11 +986,11 @@ list_command (char *arg, int from_tty)
printf_filtered ("%s is in %s (%s:%d).\n",
paddress (gdbarch, sal.pc),
SYMBOL_PRINT_NAME (sym),
- sal.symtab->filename, sal.line);
+ symtab_to_filename (sal.symtab), sal.line);
else
printf_filtered ("%s is at %s:%d.\n",
paddress (gdbarch, sal.pc),
- sal.symtab->filename, sal.line);
+ symtab_to_filename (sal.symtab), sal.line);
}
/* If line was not specified by just a line number, and it does not
@@ -1451,7 +1451,8 @@ ambiguous_line_spec (struct symtabs_and_lines *sals)
for (i = 0; i < sals->nelts; ++i)
printf_filtered (_("file: \"%s\", line number: %d\n"),
- sals->sals[i].symtab->filename, sals->sals[i].line);
+ symtab_to_filename (sals->sals[i].symtab),
+ sals->sals[i].line);
}
/* Sort function for filter_sals. */
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -67,6 +67,7 @@
#include <ctype.h>
#include "gdb_bfd.h"
#include "f-lang.h"
+#include "source.h"
#include <fcntl.h>
#include "gdb_string.h"
@@ -6832,7 +6833,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
complaint (&symfile_complaints,
_("Symtab %s has objects from two different Go packages: %s and %s"),
(SYMBOL_SYMTAB (sym)
- ? SYMBOL_SYMTAB (sym)->filename
+ ? symtab_to_filename (SYMBOL_SYMTAB (sym))
: cu->objfile->name),
this_package_name, package_name);
xfree (this_package_name);
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -854,19 +854,19 @@ add_sal_to_sals (struct linespec_state *self,
sals->nelts * sizeof (char *));
if (!literal_canonical && sal->symtab)
{
- char *filename = sal->symtab->filename;
+ const char *fullname = symtab_to_fullname (sal->symtab);
/* Note that the filter doesn't have to be a valid linespec
input. We only apply the ":LINE" treatment to Ada for
the time being. */
if (symname != NULL && sal->line != 0
&& self->language->la_language == language_ada)
- canonical_name = xstrprintf ("%s:%s:%d", filename, symname,
+ canonical_name = xstrprintf ("%s:%s:%d", fullname, symname,
sal->line);
else if (symname != NULL)
- canonical_name = xstrprintf ("%s:%s", filename, symname);
+ canonical_name = xstrprintf ("%s:%s", fullname, symname);
else
- canonical_name = xstrprintf ("%s:%d", filename, sal->line);
+ canonical_name = xstrprintf ("%s:%d", fullname, sal->line);
}
else if (symname != NULL)
canonical_name = xstrdup (symname);
@@ -1729,15 +1729,17 @@ create_sals_line_offset (struct linespec_state *self,
if (VEC_length (symtab_p, ls->file_symtabs) == 1
&& VEC_index (symtab_p, ls->file_symtabs, 0) == NULL)
{
+ const char *fullname;
+
set_current_program_space (self->program_space);
/* Make sure we have at least a default source line. */
set_default_source_symtab_and_line ();
initialize_defaults (&self->default_symtab, &self->default_line);
+ fullname = symtab_to_fullname (self->default_symtab);
VEC_pop (symtab_p, ls->file_symtabs);
VEC_free (symtab_p, ls->file_symtabs);
- ls->file_symtabs
- = collect_symtabs_from_filename (self->default_symtab->filename);
+ ls->file_symtabs = collect_symtabs_from_filename (fullname);
use_default = 1;
}
@@ -1939,7 +1941,11 @@ convert_linespec_to_sals (struct linespec_state *state, linespec_p ls)
/* Make sure we have a filename for canonicalization. */
if (ls->source_filename == NULL)
- ls->source_filename = xstrdup (state->default_symtab->filename);
+ {
+ const char *fullname = symtab_to_fullname (state->default_symtab);
+
+ ls->source_filename = xstrdup (fullname);
+ }
}
else
{
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -29,6 +29,7 @@
#include "linux-fork.h"
#include "linux-nat.h"
#include "gdbthread.h"
+#include "source.h"
#include <sys/ptrace.h>
#include "gdb_wait.h"
@@ -583,7 +584,7 @@ info_checkpoints_command (char *arg, int from_tty)
sal = find_pc_line (pc, 0);
if (sal.symtab)
- printf_filtered (_(", file %s"), lbasename (sal.symtab->filename));
+ printf_filtered (_(", file %s"), symtab_to_filename (sal.symtab));
if (sal.line)
printf_filtered (_(", line %d"), sal.line);
if (!sal.symtab && !sal.line)
--- a/gdb/macroscope.c
+++ b/gdb/macroscope.c
@@ -26,6 +26,7 @@
#include "frame.h"
#include "inferior.h"
#include "complaints.h"
+#include "filenames.h"
/* A table of user-defined macros. Unlike the macro tables used for
symtabs, this one uses xmalloc for all its allocation, not an
@@ -77,7 +78,7 @@ sal_macro_scope (struct symtab_and_line sal)
complaint (&symfile_complaints,
_("symtab found for `%s', but that file\n"
"is not covered in the compilation unit's macro information"),
- sal.symtab->filename);
+ symtab_to_filename (sal.symtab));
}
return ms;
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -58,6 +58,7 @@
#include "gdb_stat.h"
#include "gdb_string.h"
#include "psympriv.h"
+#include "source.h"
#include "bfd.h"
@@ -4341,7 +4342,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
if (info_verbose && n_undef_symbols)
{
printf_filtered (_("File %s contains %d unresolved references:"),
- st->filename, n_undef_symbols);
+ symtab_to_filename (st), n_undef_symbols);
printf_filtered ("\n\t%4d variables\n\t%4d "
"procedures\n\t%4d labels\n",
n_undef_vars, n_undef_procs, n_undef_labels);
--- a/gdb/mi/mi-cmd-file.c
+++ b/gdb/mi/mi-cmd-file.c
@@ -50,7 +50,7 @@ mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc)
/* Print to the user the line, filename and fullname. */
ui_out_field_int (uiout, "line", st.line);
- ui_out_field_string (uiout, "file", st.symtab->filename);
+ ui_out_field_string (uiout, "file", symtab_to_filename (st.symtab));
ui_out_field_string (uiout, "fullname", symtab_to_fullname (st.symtab));
@@ -93,7 +93,7 @@ mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
{
ui_out_begin (uiout, ui_out_type_tuple, NULL);
- ui_out_field_string (uiout, "file", s->filename);
+ ui_out_field_string (uiout, "file", symtab_to_filename (s));
ui_out_field_string (uiout, "fullname", symtab_to_fullname (s));
ui_out_end (uiout, ui_out_type_tuple);
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -50,6 +50,7 @@
#include "arch-utils.h"
#include "cli/cli-utils.h"
#include "format.h"
+#include "source.h"
#ifdef TUI
#include "tui/tui.h" /* For tui_active et al. */
@@ -724,7 +725,7 @@ build_address_symbolic (struct gdbarch *gdbarch,
if (sal.symtab)
{
- *filename = xstrdup (sal.symtab->filename);
+ *filename = xstrdup (symtab_to_filename (sal.symtab));
*line = sal.line;
}
}
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -180,7 +180,8 @@ partial_map_symtabs_matching_filename (struct objfile *objfile,
if (pst->anonymous)
continue;
- if (compare_filenames_for_search (pst->filename, name))
+ if (compare_filenames_for_search (pst->filename, name)
+ || compare_filenames_for_search (psymtab_to_fullname (pst), name))
{
if (partial_map_expand_apply (objfile, name, full_path, real_path,
pst, callback, data))
@@ -1128,7 +1129,7 @@ read_psymtabs_with_fullname (struct objfile *objfile, const char *fullname)
if (p->anonymous)
continue;
- if (filename_cmp (fullname, p->filename) == 0)
+ if (filename_cmp (fullname, psymtab_to_fullname (p)) == 0)
psymtab_to_symtab (objfile, p);
}
}
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -91,7 +91,7 @@ stpy_str (PyObject *self)
STPY_REQUIRE_VALID (self, symtab);
- result = PyString_FromString (symtab->filename);
+ result = PyString_FromString (symtab_to_filename (symtab));
return result;
}
@@ -101,11 +101,12 @@ stpy_get_filename (PyObject *self, void *closure)
{
PyObject *str_obj;
struct symtab *symtab = NULL;
+ const char *filename;
STPY_REQUIRE_VALID (self, symtab);
+ filename = symtab_to_filename (symtab);
- str_obj = PyString_Decode (symtab->filename,
- strlen (symtab->filename),
+ str_obj = PyString_Decode (filename, strlen (filename),
host_charset (), NULL);
return str_obj;
}
@@ -186,7 +187,8 @@ stpy_static_block (PyObject *self, PyObject *args)
static PyObject *
salpy_str (PyObject *self)
{
- char *s, *filename;
+ char *s;
+ const char *filename;
sal_object *sal_obj;
PyObject *result;
struct symtab_and_line *sal = NULL;
@@ -195,7 +197,7 @@ salpy_str (PyObject *self)
sal_obj = (sal_object *) self;
filename = (sal_obj->symtab == (symtab_object *) Py_None)
- ? "<unknown>" : sal_obj->symtab->symtab->filename;
+ ? "<unknown>" : symtab_to_filename (sal_obj->symtab->symtab);
s = xstrprintf ("symbol and line for %s, line %d", filename,
sal->line);
--- a/gdb/skip.c
+++ b/gdb/skip.c
@@ -32,6 +32,7 @@
#include "objfiles.h"
#include "exceptions.h"
#include "breakpoint.h" /* for get_sal_arch () */
+#include "source.h"
struct skiplist_entry
{
@@ -69,7 +70,7 @@ static void
skip_file_command (char *arg, int from_tty)
{
struct skiplist_entry *e;
- const struct symtab *symtab;
+ struct symtab *symtab;
const char *filename = NULL;
/* If no argument was given, try to default to the last
@@ -79,8 +80,9 @@ skip_file_command (char *arg, int from_tty)
symtab = get_last_displayed_symtab ();
if (symtab == NULL)
error (_("No default file now."));
- else
- filename = symtab->filename;
+
+ /* It is not a typo, symtab_to_filename woule be needlessly ambiguous. */
+ filename = symtab_to_fullname (symtab);
}
else
{
@@ -91,8 +93,9 @@ skip_file_command (char *arg, int from_tty)
if (!nquery (_("\
Ignore file pending future shared library load? ")))
return;
-
}
+ /* Do not use SYMTAB's filename, later loaded shared libraries may match
+ given ARG but not SYMTAB's filename. */
filename = arg;
}
@@ -330,6 +333,8 @@ int
function_name_is_marked_for_skip (const char *function_name,
const struct symtab_and_line *function_sal)
{
+ int searched_for_fullname = 0;
+ const char *fullname = NULL;
struct skiplist_entry *e;
if (function_name == NULL)
@@ -345,11 +350,25 @@ function_name_is_marked_for_skip (const char *function_name,
&& strcmp_iw (function_name, e->function_name) == 0)
return 1;
- if (e->filename != NULL && function_sal->symtab != NULL
- && function_sal->symtab->filename != NULL
- && compare_filenames_for_search (function_sal->symtab->filename,
- e->filename))
- return 1;
+ if (e->filename != NULL)
+ {
+ if (function_sal->symtab != NULL
+ && compare_filenames_for_search (function_sal->symtab->filename,
+ e->filename))
+ return 1;
+
+ /* Get the filename corresponding to this FUNCTION_SAL, if we haven't
+ yet. */
+ if (!searched_for_fullname)
+ {
+ if (function_sal->symtab != NULL)
+ fullname = symtab_to_fullname (function_sal->symtab);
+ searched_for_fullname = 1;
+ }
+ if (fullname != NULL
+ && compare_filenames_for_search (fullname, e->filename))
+ return 1;
+ }
}
return 0;
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -1173,7 +1173,7 @@ find_source_lines (struct symtab *s, int desc)
gdb_assert (s);
line_charpos = (int *) xmalloc (lines_allocated * sizeof (int));
if (fstat (desc, &st) < 0)
- perror_with_name (s->filename);
+ perror_with_name (symtab_to_filename (s));
if (s->objfile && s->objfile->obfd)
mtime = s->objfile->mtime;
@@ -1198,7 +1198,7 @@ find_source_lines (struct symtab *s, int desc)
/* Reassign `size' to result of read for systems where \r\n -> \n. */
size = myread (desc, data, size);
if (size < 0)
- perror_with_name (s->filename);
+ perror_with_name (symtab_to_filename (s));
end = data + size;
p = data;
line_charpos[0] = 0;
@@ -1339,17 +1339,18 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
if (!(flags & PRINT_SOURCE_LINES_NOERROR))
{
- int len = strlen (s->filename) + 100;
+ const char *filename = symtab_to_filename (s);
+ int len = strlen (filename) + 100;
char *name = alloca (len);
- xsnprintf (name, len, "%d\t%s", line, s->filename);
+ xsnprintf (name, len, "%d\t%s", line, filename);
print_sys_errmsg (name, errno);
}
else
{
ui_out_field_int (uiout, "line", line);
ui_out_text (uiout, "\tin ");
- ui_out_field_string (uiout, "file", s->filename);
+ ui_out_field_string (uiout, "file", symtab_to_filename (s));
if (ui_out_is_mi_like_p (uiout))
{
const char *fullname = symtab_to_fullname (s);
@@ -1371,13 +1372,13 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
{
close (desc);
error (_("Line number %d out of range; %s has %d lines."),
- line, s->filename, s->nlines);
+ line, symtab_to_filename (s), s->nlines);
}
if (lseek (desc, s->line_charpos[line - 1], 0) < 0)
{
close (desc);
- perror_with_name (s->filename);
+ perror_with_name (symtab_to_filename (s));
}
stream = fdopen (desc, FDOPEN_MODE);
@@ -1394,7 +1395,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
last_line_listed = current_source_line;
if (flags & PRINT_SOURCE_LINES_FILENAME)
{
- ui_out_text (uiout, s->filename);
+ ui_out_text (uiout, symtab_to_filename (s));
ui_out_text (uiout, ":");
}
xsnprintf (buf, sizeof (buf), "%d\t", current_source_line++);
@@ -1508,7 +1509,7 @@ line_info (char *arg, int from_tty)
if (start_pc == end_pc)
{
printf_filtered ("Line %d of \"%s\"",
- sal.line, sal.symtab->filename);
+ sal.line, symtab_to_filename (sal.symtab));
wrap_here (" ");
printf_filtered (" is at address ");
print_address (gdbarch, start_pc, gdb_stdout);
@@ -1518,7 +1519,7 @@ line_info (char *arg, int from_tty)
else
{
printf_filtered ("Line %d of \"%s\"",
- sal.line, sal.symtab->filename);
+ sal.line, symtab_to_filename (sal.symtab));
wrap_here (" ");
printf_filtered (" starts at address ");
print_address (gdbarch, start_pc, gdb_stdout);
@@ -1544,7 +1545,7 @@ line_info (char *arg, int from_tty)
which the user would want to see? If we have debugging symbols
and no line numbers? */
printf_filtered (_("Line number %d is out of range for \"%s\".\n"),
- sal.line, sal.symtab->filename);
+ sal.line, symtab_to_filename (sal.symtab));
}
do_cleanups (cleanups);
}
@@ -1572,7 +1573,7 @@ forward_search_command (char *regex, int from_tty)
desc = open_source_file (current_source_symtab);
if (desc < 0)
- perror_with_name (current_source_symtab->filename);
+ perror_with_name (symtab_to_filename (current_source_symtab));
cleanups = make_cleanup_close (desc);
if (current_source_symtab->line_charpos == 0)
@@ -1582,7 +1583,7 @@ forward_search_command (char *regex, int from_tty)
error (_("Expression not found"));
if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0)
- perror_with_name (current_source_symtab->filename);
+ perror_with_name (symtab_to_filename (current_source_symtab));
discard_cleanups (cleanups);
stream = fdopen (desc, FDOPEN_MODE);
@@ -1661,7 +1662,7 @@ reverse_search_command (char *regex, int from_tty)
desc = open_source_file (current_source_symtab);
if (desc < 0)
- perror_with_name (current_source_symtab->filename);
+ perror_with_name (symtab_to_filename (current_source_symtab));
cleanups = make_cleanup_close (desc);
if (current_source_symtab->line_charpos == 0)
@@ -1671,7 +1672,7 @@ reverse_search_command (char *regex, int from_tty)
error (_("Expression not found"));
if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0)
- perror_with_name (current_source_symtab->filename);
+ perror_with_name (symtab_to_filename (current_source_symtab));
discard_cleanups (cleanups);
stream = fdopen (desc, FDOPEN_MODE);
@@ -1715,7 +1716,7 @@ reverse_search_command (char *regex, int from_tty)
if (fseek (stream, current_source_symtab->line_charpos[line - 1], 0) < 0)
{
do_cleanups (cleanups);
- perror_with_name (current_source_symtab->filename);
+ perror_with_name (symtab_to_filename (current_source_symtab));
}
}
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1461,7 +1461,7 @@ frame_info (char *addr_exp, int from_tty)
}
wrap_here (" ");
if (sal.symtab)
- printf_filtered (" (%s:%d)", sal.symtab->filename, sal.line);
+ printf_filtered (" (%s:%d)", symtab_to_filename (sal.symtab), sal.line);
puts_filtered ("; ");
wrap_here (" ");
printf_filtered ("saved %s ", pc_regname);
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -36,6 +36,7 @@
#include "dictionary.h"
#include "typeprint.h"
#include "gdbcmd.h"
+#include "source.h"
#include "gdb_string.h"
#include "readline/readline.h"
@@ -185,7 +186,7 @@ dump_objfile (struct objfile *objfile)
symtab != NULL;
symtab = symtab->next)
{
- printf_filtered ("%s at ", symtab->filename);
+ printf_filtered ("%s at ", symtab_to_filename (symtab));
gdb_print_host_address (symtab, gdb_stdout);
printf_filtered (", ");
if (symtab->objfile != objfile)
@@ -294,7 +295,8 @@ dump_symtab_1 (struct objfile *objfile, struct symtab *symtab,
struct block *b;
int depth;
- fprintf_filtered (outfile, "\nSymtab for file %s\n", symtab->filename);
+ fprintf_filtered (outfile, "\nSymtab for file %s\n",
+ symtab_to_filename (symtab));
if (symtab->dirname)
fprintf_filtered (outfile, "Compilation directory is %s\n",
symtab->dirname);
@@ -443,7 +445,8 @@ maintenance_print_symbols (char *args, int from_tty)
ALL_SYMTABS (objfile, s)
{
QUIT;
- if (symname == NULL || filename_cmp (symname, s->filename) == 0)
+ if (symname == NULL
+ || filename_cmp (symname, symtab_to_filename (s)) == 0)
dump_symtab (objfile, s, outfile);
}
do_cleanups (cleanups);
@@ -723,7 +726,7 @@ maintenance_info_symtabs (char *regexp, int from_tty)
QUIT;
if (! regexp
- || re_exec (symtab->filename))
+ || re_exec (symtab_to_filename (symtab)))
{
if (! printed_objfile_start)
{
@@ -734,7 +737,8 @@ maintenance_info_symtabs (char *regexp, int from_tty)
printed_objfile_start = 1;
}
- printf_filtered (" { symtab %s ", symtab->filename);
+ printf_filtered (" { symtab %s ",
+ symtab_to_filename (symtab));
wrap_here (" ");
printf_filtered ("((struct symtab *) %s)\n",
host_address_to_string (symtab));
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -203,7 +203,8 @@ iterate_over_some_symtabs (const char *name,
for (s = first; s != NULL && s != after_last; s = s->next)
{
- if (compare_filenames_for_search (s->filename, name))
+ if (compare_filenames_for_search (s->filename, name)
+ || compare_filenames_for_search (symtab_to_fullname (s), name))
{
if (callback (s, data))
return 1;
@@ -220,6 +221,7 @@ iterate_over_some_symtabs (const char *name,
if (full_path != NULL)
{
+ /* FP is here in xfullpath form. */
const char *fp = symtab_to_fullname (s);
gdb_assert (IS_ABSOLUTE_PATH (full_path));
@@ -1666,7 +1668,7 @@ Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n\
(if a template, try specifying an instantiation: %s<type>)."),
kind == GLOBAL_BLOCK ? "global" : "static",
- name, symtab->filename, name, name);
+ name, symtab_to_filename (symtab), name, name);
}
return fixup_symbol_section (sym, objfile);
}
@@ -1871,7 +1873,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile, int kind,
Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n\
(if a template, try specifying an instantiation: %s<type>)."),
- name, symtab->filename, name, name);
+ name, symtab_to_filename (symtab), name, name);
}
if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
return SYMBOL_TYPE (sym);
@@ -2525,7 +2527,7 @@ find_line_symtab (struct symtab *symtab, int line,
{
if (objfile->sf)
objfile->sf->qf->expand_symtabs_with_fullname (objfile,
- symtab->filename);
+ symtab_to_fullname (symtab));
}
ALL_SYMTABS (objfile, s)
@@ -3292,7 +3294,7 @@ file_matches (const char *file, char *files[], int nfiles)
{
for (i = 0; i < nfiles; i++)
{
- if (filename_cmp (files[i], lbasename (file)) == 0)
+ if (compare_filenames_for_search (file, files[i]))
return 1;
}
}
@@ -3605,7 +3607,7 @@ search_symbols (char *regexp, enum search_domain kind,
QUIT;
- if (file_matches (real_symtab->filename, files, nfiles)
+ if (file_matches (symtab_to_fullname (real_symtab), files, nfiles)
&& ((!datum.preg_p
|| regexec (&datum.preg, SYMBOL_NATURAL_NAME (sym), 0,
NULL, 0) == 0)
@@ -3723,12 +3725,14 @@ search_symbols (char *regexp, enum search_domain kind,
static void
print_symbol_info (enum search_domain kind,
struct symtab *s, struct symbol *sym,
- int block, char *last)
+ int block, const char *last)
{
- if (last == NULL || filename_cmp (last, s->filename) != 0)
+ const char *s_filename = symtab_to_filename (s);
+
+ if (last == NULL || filename_cmp (last, s_filename) != 0)
{
fputs_filtered ("\nFile ", gdb_stdout);
- fputs_filtered (s->filename, gdb_stdout);
+ fputs_filtered (s_filename, gdb_stdout);
fputs_filtered (":\n", gdb_stdout);
}
@@ -3786,7 +3790,7 @@ symtab_symbol_info (char *regexp, enum search_domain kind, int from_tty)
struct symbol_search *symbols;
struct symbol_search *p;
struct cleanup *old_chain;
- char *last_filename = NULL;
+ const char *last_filename = NULL;
int first = 1;
gdb_assert (kind <= TYPES_DOMAIN);
@@ -3821,7 +3825,7 @@ symtab_symbol_info (char *regexp, enum search_domain kind, int from_tty)
p->symbol,
p->block,
last_filename);
- last_filename = p->symtab->filename;
+ last_filename = symtab_to_filename (p->symtab);
}
}
@@ -3905,7 +3909,9 @@ rbreak_command (char *regexp, int from_tty)
{
if (p->msymbol == NULL)
{
- int newlen = (strlen (p->symtab->filename)
+ const char *fullname = symtab_to_fullname (p->symtab);
+
+ int newlen = (strlen (fullname)
+ strlen (SYMBOL_LINKAGE_NAME (p->symbol))
+ 4);
@@ -3914,7 +3920,7 @@ rbreak_command (char *regexp, int from_tty)
string = xrealloc (string, newlen);
len = newlen;
}
- strcpy (string, p->symtab->filename);
+ strcpy (string, fullname);
strcat (string, ":'");
strcat (string, SYMBOL_LINKAGE_NAME (p->symbol));
strcat (string, "'");
@@ -3923,7 +3929,7 @@ rbreak_command (char *regexp, int from_tty)
p->symtab,
p->symbol,
p->block,
- p->symtab->filename);
+ symtab_to_filename (p->symtab));
}
else
{
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -311,7 +311,7 @@ set_traceframe_context (struct frame_info *trace_frame)
clear_internalvar (lookup_internalvar ("trace_file"));
else
set_internalvar_string (lookup_internalvar ("trace_file"),
- traceframe_sal.symtab->filename);
+ symtab_to_filename (traceframe_sal.symtab));
}
/* Create a new trace state variable with the given name. */
@@ -2512,7 +2512,7 @@ trace_find_line_command (char *args, int from_tty)
if (start_pc == end_pc)
{
printf_filtered ("Line %d of \"%s\"",
- sal.line, sal.symtab->filename);
+ sal.line, symtab_to_filename (sal.symtab));
wrap_here (" ");
printf_filtered (" is at address ");
print_address (get_current_arch (), start_pc, gdb_stdout);
@@ -2533,7 +2533,7 @@ trace_find_line_command (char *args, int from_tty)
which the user would want to see? If we have debugging
symbols and no line numbers? */
error (_("Line number %d is out of range for \"%s\"."),
- sal.line, sal.symtab->filename);
+ sal.line, symtab_to_filename (sal.symtab));
/* Find within range of stated line. */
if (args && *args)
@@ -4860,7 +4860,7 @@ print_one_static_tracepoint_marker (int count,
if (sal.symtab != NULL)
{
- ui_out_field_string (uiout, "file", sal.symtab->filename);
+ ui_out_field_string (uiout, "file", symtab_to_filename (sal.symtab));
ui_out_text (uiout, ":");
if (ui_out_is_mi_like_p (uiout))
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -318,7 +318,7 @@ tui_show_disassem_and_update_source (struct gdbarch *gdbarch,
if (sal.symtab)
{
set_current_source_symtab_and_line (&sal);
- tui_update_locator_filename (sal.symtab->filename);
+ tui_update_locator_filename (symtab_to_filename (sal.symtab));
}
else
tui_update_locator_filename ("?");
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -63,9 +63,10 @@ tui_set_source_content (struct symtab *s,
{
if (!noerror)
{
- char *name = alloca (strlen (s->filename) + 100);
+ const char *filename = symtab_to_filename (s);
+ char *name = alloca (strlen (filename) + 100);
- sprintf (name, "%s:%d", s->filename, line_no);
+ sprintf (name, "%s:%d", filename, line_no);
print_sys_errmsg (name, errno);
}
ret = TUI_FAILURE;
@@ -78,14 +79,15 @@ tui_set_source_content (struct symtab *s,
if (line_no < 1 || line_no > s->nlines)
{
close (desc);
- printf_unfiltered (
- "Line number %d out of range; %s has %d lines.\n",
- line_no, s->filename, s->nlines);
+ printf_unfiltered ("Line number %d out of range; "
+ "%s has %d lines.\n",
+ line_no, symtab_to_filename (s),
+ s->nlines);
}
else if (lseek (desc, s->line_charpos[line_no - 1], 0) < 0)
{
close (desc);
- perror_with_name (s->filename);
+ perror_with_name (symtab_to_filename (s));
}
else
{
@@ -97,7 +99,7 @@ tui_set_source_content (struct symtab *s,
if (TUI_SRC_WIN->generic.title)
xfree (TUI_SRC_WIN->generic.title);
- TUI_SRC_WIN->generic.title = xstrdup (s->filename);
+ TUI_SRC_WIN->generic.title = xstrdup (symtab_to_filename (s));
xfree (src->fullname);
src->fullname = xstrdup (symtab_to_fullname (s));
@@ -150,7 +152,7 @@ tui_set_source_content (struct symtab *s,
element->which_element.source.is_exec_point =
(filename_cmp (((struct tui_win_element *)
locator->content[0])->which_element.locator.file_name,
- s->filename) == 0
+ symtab_to_filename (s)) == 0
&& cur_line_no == ((struct tui_win_element *)
locator->content[0])->which_element.locator.line_no);
if (c != EOF)
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -29,6 +29,7 @@
#include "top.h"
#include "gdb-demangle.h"
#include "gdb_string.h"
+#include "source.h"
#include "tui/tui.h"
#include "tui/tui-data.h"
#include "tui/tui-stack.h"
@@ -348,11 +349,12 @@ tui_show_frame_info (struct frame_info *fi)
find_frame_sal (fi, &sal);
source_already_displayed = sal.symtab != 0
- && tui_source_is_displayed (sal.symtab->filename);
+ && tui_source_is_displayed (symtab_to_filename (sal.symtab));
if (get_frame_pc_if_available (fi, &pc))
tui_set_locator_info (get_frame_arch (fi),
- sal.symtab == 0 ? "??" : sal.symtab->filename,
+ (sal.symtab == 0
+ ? "??" : symtab_to_filename (sal.symtab)),
tui_get_function_from_frame (fi),
sal.line,
pc);
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -59,7 +59,7 @@ tui_display_main (void)
tui_update_source_windows_with_addr (gdbarch, addr);
sal = find_pc_line (addr, 0);
if (sal.symtab)
- tui_update_locator_filename (sal.symtab->filename);
+ tui_update_locator_filename (symtab_to_filename (sal.symtab));
else
tui_update_locator_filename ("??");
}