/* List lines of source files for GDB, the GNU debugger.
- Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
- 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
- 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1986-2005, 2007-2012 Free Software Foundation, Inc.
This file is part of GDB.
if one exists. */
if (lookup_symbol (main_name (), 0, VAR_DOMAIN, 0))
{
- sals = decode_line_spec (main_name (), 1);
+ sals = decode_line_spec (main_name (), DECODE_LINE_FUNFIRSTLINE);
sal = sals.sals[0];
xfree (sals.sals);
current_source_pspace = sal.pspace;
xfree (s->fullname);
s->fullname = NULL;
}
-
- if (objfile->sf)
- objfile->sf->qf->forget_cached_source_info (objfile);
}
+
+ if (objfile->sf)
+ objfile->sf->qf->forget_cached_source_info (objfile);
}
/* Forget what we learned about line positions in source files, and
forget_cached_source_info (void)
{
struct program_space *pspace;
- struct symtab *s;
struct objfile *objfile;
ALL_PSPACES (pspace)
If this function fails to find the file that this symtab represents,
NULL will be returned and s->fullname will be set to NULL. */
+
char *
symtab_to_fullname (struct symtab *s)
{
if (!s)
return NULL;
- /* Don't check s->fullname here, the file could have been
- deleted/moved/..., look for it again. */
+ /* Use cached copy if we have it.
+ We rely on forget_cached_source_info being called appropriately
+ to handle cases like the file being moved. */
+ if (s->fullname)
+ return s->fullname;
+
r = find_and_open_source (s->filename, s->dirname, &s->fullname);
if (r >= 0)
FILE *stream;
int nlines = stopline - line;
struct cleanup *cleanup;
+ struct ui_out *uiout = current_uiout;
/* Regardless of whether we can open the file, set current_source_symtab. */
current_source_symtab = s;
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_text (uiout, "\n");
+ {
+ ui_out_field_int (uiout, "line", line);
+ ui_out_text (uiout, "\tin ");
+ ui_out_field_string (uiout, "file", s->filename);
+ ui_out_text (uiout, "\n");
+ }
return;
}
struct symtab_and_line sal;
CORE_ADDR start_pc, end_pc;
int i;
+ struct cleanup *cleanups;
init_sal (&sal); /* initialize to zeroes */
if (arg == 0)
{
sal.symtab = current_source_symtab;
+ sal.pspace = current_program_space;
sal.line = last_line_listed;
sals.nelts = 1;
sals.sals = (struct symtab_and_line *)
}
else
{
- sals = decode_line_spec_1 (arg, 0);
+ sals = decode_line_spec_1 (arg, DECODE_LINE_LIST_MODE);
dont_repeat ();
}
+ cleanups = make_cleanup (xfree, sals.sals);
+
/* C++ More than one line may have been specified, as when the user
specifies an overloaded function name. Print info on them all. */
for (i = 0; i < sals.nelts; i++)
{
sal = sals.sals[i];
+ if (sal.pspace != current_program_space)
+ continue;
if (sal.symtab == 0)
{
printf_filtered (_("Line number %d is out of range for \"%s\".\n"),
sal.line, sal.symtab->filename);
}
- xfree (sals.sals);
+ do_cleanups (cleanups);
}
\f
/* Commands to search the source file for a regexp. */