along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "arch-utils.h"
#include "symtab.h"
#include "expression.h"
#include "language.h"
static int current_source_line;
+static struct program_space *current_source_pspace;
+
/* Default number of lines to print with commands like "list".
This is based on guessing how many long (i.e. more than chars_per_line
characters) lines there will be. To be completely correct, "list"
{
struct symtab_and_line cursal = { 0 };
+ cursal.pspace = current_source_pspace;
cursal.symtab = current_source_symtab;
cursal.line = current_source_line;
cursal.pc = 0;
set_current_source_symtab_and_line (const struct symtab_and_line *sal)
{
struct symtab_and_line cursal = { 0 };
-
+
+ cursal.pspace = current_source_pspace;
cursal.symtab = current_source_symtab;
cursal.line = current_source_line;
+ cursal.pc = 0;
+ cursal.end = 0;
+ current_source_pspace = sal->pspace;
current_source_symtab = sal->symtab;
current_source_line = sal->line;
- cursal.pc = 0;
- cursal.end = 0;
-
+
return cursal;
}
{
current_source_symtab = s;
current_source_line = 1;
+ current_source_pspace = SYMTAB_PSPACE (s);
return;
}
sals = decode_line_spec (main_name (), 1);
sal = sals.sals[0];
xfree (sals.sals);
+ current_source_pspace = sal.pspace;
current_source_symtab = sal.symtab;
current_source_line = max (sal.line - (lines_to_list - 1), 1);
if (current_source_symtab)
current_source_line = 1;
- for (ofp = object_files; ofp != NULL; ofp = ofp->next)
+ ALL_OBJFILES (ofp)
{
for (s = ofp->symtabs; s; s = s->next)
{
int len = strlen (name);
if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0
|| strcmp (name, "<<C++-namespaces>>") == 0)))
- current_source_symtab = s;
+ {
+ current_source_pspace = current_program_space;
+ current_source_symtab = s;
+ }
}
}
+
if (current_source_symtab)
return;
/* How about the partial symbol tables? */
- for (ofp = object_files; ofp != NULL; ofp = ofp->next)
+ ALL_OBJFILES (ofp)
{
for (ps = ofp->psymtabs; ps != NULL; ps = ps->next)
{
}
else
{
+ current_source_pspace = current_program_space;
current_source_symtab = PSYMTAB_TO_SYMTAB (cs_pst);
}
}
void
forget_cached_source_info (void)
{
+ struct program_space *pspace;
struct symtab *s;
struct objfile *objfile;
struct partial_symtab *pst;
- for (objfile = object_files; objfile != NULL; objfile = objfile->next)
+ ALL_PSPACES (pspace)
+ ALL_PSPACE_OBJFILES (pspace, objfile)
{
for (s = objfile->symtabs; s != NULL; s = s->next)
{
}
}
}
+
+ last_source_visited = NULL;
}
void
forget_cached_source_info ();
}
-void
-init_last_source_visited (void)
-{
- last_source_visited = NULL;
-}
-
/* Add zero or more directories to the front of the source path. */
void
else
{
mod_path (dirname, &source_path);
- last_source_visited = NULL;
+ forget_cached_source_info ();
}
if (from_tty)
show_directories ((char *) 0, from_tty);
- forget_cached_source_info ();
}
/* Add a path given with the -d command line switch.
}
/* This function is capable of finding the absolute path to a
- source file, and opening it, provided you give it an
- OBJFILE and FILENAME. Both the DIRNAME and FULLNAME are only
- added suggestions on where to find the file.
+ source file, and opening it, provided you give it a FILENAME. Both the
+ DIRNAME and FULLNAME are only added suggestions on where to find the file.
- OBJFILE should be the objfile associated with a psymtab or symtab.
FILENAME should be the filename to open.
DIRNAME is the compilation directory of a particular source file.
Only some debug formats provide this info.
FULLNAME is set to NULL. */
static int
-find_and_open_source (struct objfile *objfile,
- const char *filename,
+find_and_open_source (const char *filename,
const char *dirname,
char **fullname)
{
if (!s)
return -1;
- return find_and_open_source (s->objfile, s->filename, s->dirname,
- &s->fullname);
+ return find_and_open_source (s->filename, s->dirname, &s->fullname);
}
/* Finds the fullname that a symtab represents.
/* Don't check s->fullname here, the file could have been
deleted/moved/..., look for it again */
- r = find_and_open_source (s->objfile, s->filename, s->dirname,
- &s->fullname);
+ r = find_and_open_source (s->filename, s->dirname, &s->fullname);
if (r >= 0)
{
/* Don't check ps->fullname here, the file could have been
deleted/moved/..., look for it again */
- r = find_and_open_source (ps->objfile, ps->filename, ps->dirname,
- &ps->fullname);
+ r = find_and_open_source (ps->filename, ps->dirname, &ps->fullname);
if (r >= 0)
{
/* Don't index off the end of the line_charpos array. */
return 0;
annotate_source (s->fullname, line, s->line_charpos[line - 1],
- mid_statement, pc);
+ mid_statement, get_objfile_arch (s->objfile), pc);
current_source_line = line;
first_line_listed = line;
if (sal.symtab == 0)
{
+ struct gdbarch *gdbarch = get_current_arch ();
+
printf_filtered (_("No line number information available"));
if (sal.pc != 0)
{
address. */
printf_filtered (" for address ");
wrap_here (" ");
- print_address (sal.pc, gdb_stdout);
+ print_address (gdbarch, sal.pc, gdb_stdout);
}
else
printf_filtered (".");
else if (sal.line > 0
&& find_line_pc_range (sal, &start_pc, &end_pc))
{
+ struct gdbarch *gdbarch = get_objfile_arch (sal.symtab->objfile);
+
if (start_pc == end_pc)
{
printf_filtered ("Line %d of \"%s\"",
sal.line, sal.symtab->filename);
wrap_here (" ");
printf_filtered (" is at address ");
- print_address (start_pc, gdb_stdout);
+ print_address (gdbarch, start_pc, gdb_stdout);
wrap_here (" ");
printf_filtered (" but contains no code.\n");
}
sal.line, sal.symtab->filename);
wrap_here (" ");
printf_filtered (" starts at address ");
- print_address (start_pc, gdb_stdout);
+ print_address (gdbarch, start_pc, gdb_stdout);
wrap_here (" ");
printf_filtered (" and ends at ");
- print_address (end_pc, gdb_stdout);
+ print_address (gdbarch, end_pc, gdb_stdout);
printf_filtered (".\n");
}
/* x/i should display this line's code. */
- set_next_address (current_gdbarch, start_pc);
+ set_next_address (gdbarch, start_pc);
/* Repeating "info line" should do the following line. */
last_line_listed = sal.line + 1;
if (re_exec (buf) > 0)
{
/* Match! */
- fclose (stream);
+ do_cleanups (cleanups);
print_source_lines (current_source_symtab, line, line + 1, 0);
set_internalvar_integer (lookup_internalvar ("_"), line);
current_source_line = max (line - lines_to_list / 2, 1);
if (re_exec (buf) > 0)
{
/* Match! */
- fclose (stream);
+ do_cleanups (cleanups);
print_source_lines (current_source_symtab, line, line + 1, 0);
set_internalvar_integer (lookup_internalvar ("_"), line);
current_source_line = max (line - lines_to_list / 2, 1);
line--;
if (fseek (stream, current_source_symtab->line_charpos[line - 1], 0) < 0)
{
- fclose (stream);
+ do_cleanups (cleanups);
perror_with_name (current_source_symtab->filename);
}
}
if (from != NULL && !rule_found)
error (_("No substitution rule defined for `%s'"), from);
+
+ forget_cached_source_info ();
}
/* Add a new source path substitution rule. */
/* Insert the new substitution rule. */
add_substitute_path_rule (argv[0], argv[1]);
+ forget_cached_source_info ();
}
\f