aboutsummaryrefslogtreecommitdiff
path: root/gdb/psymtab.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2011-03-07 16:17:29 +0000
committerTom Tromey <tromey@redhat.com>2011-03-07 16:17:29 +0000
commitb11896a5276900e7fda0bb6b7cd9d2b31a4945b3 (patch)
tree733433e09eb05de160b4549265cf1134e1b2dce3 /gdb/psymtab.c
parentfda326dd1d341f03a75a36c8331b8cc8d1f637fa (diff)
downloadgdb-b11896a5276900e7fda0bb6b7cd9d2b31a4945b3.zip
gdb-b11896a5276900e7fda0bb6b7cd9d2b31a4945b3.tar.gz
gdb-b11896a5276900e7fda0bb6b7cd9d2b31a4945b3.tar.bz2
* xcoffread.c (xcoff_sym_fns): Update.
* symfile.h (struct sym_fns) <sym_read_psymbols>: New field. (enum symfile_add_flags) <SYMFILE_NO_READ>: New constant. * symfile.c (syms_from_objfile): Handle SYMFILE_NO_READ. (symbol_file_add_with_addrs_or_offsets): Likewise. (reread_symbols): Handle OBJF_PSYMTABS_READ. * somread.c (som_sym_fns): Update. * psymtab.h (require_partial_symbols): Declare. * psymtab.c (require_partial_symbols): New function. (ALL_OBJFILE_PSYMTABS_REQUIRED): New macro. (ALL_OBJFILE_PSYMTABS): Undef. (ALL_PSYMTABS): Move from psympriv.h. (lookup_partial_symtab, find_pc_sect_psymtab) (lookup_symbol_aux_psymtabs, relocate_psymtabs) (find_last_source_symtab_from_partial) (forget_cached_source_info_partial) (print_psymtab_stats_for_objfile, read_symtabs_for_function) (expand_partial_symbol_tables, read_psymtabs_with_filename) (map_symbol_names_psymtab, map_symbol_filenames_psymtab) (find_symbol_file_from_partial, map_matching_symbols_psymtab) (expand_symtabs_matching_via_partial, maintenance_info_psymtabs): Use ALL_OBJFILE_PSYMTABS_REQUIRED. * psympriv.h (ALL_PSYMTABS): Move to psymtab.c. * objfiles.h (OBJF_PSYMTABS_READ): New macro. * objfiles.c (objfile_has_partial_symbols): Handle lazily-read psymtabs. * mipsread.c (ecoff_sym_fns): Update. * machoread.c (macho_sym_fns): Update. * elfread.c (elf_symfile_read): Set up for lazy psymtab reading. (read_psyms): New function. (elf_sym_fns, elf_sym_fns_gdb_index): Update. (elf_sym_fns_lazy_psyms): New global. * dwarf2read.c (dwarf2_initialize_objfile): Don't call dwarf2_build_psymtabs. * dbxread.c (aout_sym_fns): Update. * coffread.c (coff_sym_fns): Update.
Diffstat (limited to 'gdb/psymtab.c')
-rw-r--r--gdb/psymtab.c88
1 files changed, 71 insertions, 17 deletions
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 6a0c563..eeae03b 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -69,6 +69,60 @@ static struct partial_symbol *fixup_psymbol_section (struct partial_symbol
static struct symtab *psymtab_to_symtab (struct partial_symtab *pst);
+/* Ensure that the partial symbols for OBJFILE have been loaded. This
+ function always returns its argument, as a convenience. */
+
+struct objfile *
+require_partial_symbols (struct objfile *objfile, int verbose)
+{
+ if ((objfile->flags & OBJF_PSYMTABS_READ) == 0)
+ {
+ objfile->flags |= OBJF_PSYMTABS_READ;
+
+ if (objfile->sf->sym_read_psymbols)
+ {
+ if (verbose)
+ {
+ printf_unfiltered (_("Reading symbols from %s..."),
+ objfile->name);
+ gdb_flush (gdb_stdout);
+ }
+ (*objfile->sf->sym_read_psymbols) (objfile);
+ if (verbose)
+ {
+ if (!objfile_has_symbols (objfile))
+ {
+ wrap_here ("");
+ printf_unfiltered (_("(no debugging symbols found)..."));
+ wrap_here ("");
+ }
+
+ printf_unfiltered (_("done.\n"));
+ }
+ }
+ }
+
+ return objfile;
+}
+
+/* Traverse all psymtabs in one objfile, requiring that the psymtabs
+ be read in. */
+
+#define ALL_OBJFILE_PSYMTABS_REQUIRED(objfile, p) \
+ for ((p) = require_partial_symbols (objfile, 1)->psymtabs; \
+ (p) != NULL; \
+ (p) = (p)->next)
+
+/* We want to make sure this file always requires psymtabs. */
+
+#undef ALL_OBJFILE_PSYMTABS
+
+/* Traverse all psymtabs in all objfiles. */
+
+#define ALL_PSYMTABS(objfile, p) \
+ ALL_OBJFILES (objfile) \
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p)
+
/* Lookup the partial symbol table of a source file named NAME.
*If* there is no '/' in the name, a match after a '/'
in the psymtab filename will also work. */
@@ -79,7 +133,7 @@ lookup_partial_symtab (struct objfile *objfile, const char *name,
{
struct partial_symtab *pst;
- ALL_OBJFILE_PSYMTABS (objfile, pst)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
{
if (FILENAME_CMP (name, pst->filename) == 0)
{
@@ -117,7 +171,7 @@ lookup_partial_symtab (struct objfile *objfile, const char *name,
/* Now, search for a matching tail (only if name doesn't have any dirs). */
if (lbasename (name) == name)
- ALL_OBJFILE_PSYMTABS (objfile, pst)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
{
if (FILENAME_CMP (lbasename (pst->filename), name) == 0)
return (pst);
@@ -280,7 +334,7 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
its CUs may be missing in PSYMTABS_ADDRMAP as they may be varying
debug info type in single OBJFILE. */
- ALL_OBJFILE_PSYMTABS (objfile, pst)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
if (pc >= pst->textlow && pc < pst->texthigh)
{
struct partial_symtab *best_pst;
@@ -423,7 +477,7 @@ lookup_symbol_aux_psymtabs (struct objfile *objfile,
struct partial_symtab *ps;
const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0);
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
if (!ps->readin && lookup_partial_symbol (ps, name, psymtab_index, domain))
return PSYMTAB_TO_SYMTAB (ps);
@@ -635,7 +689,7 @@ relocate_psymtabs (struct objfile *objfile,
struct partial_symbol **psym;
struct partial_symtab *p;
- ALL_OBJFILE_PSYMTABS (objfile, p)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p)
{
p->textlow += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
@@ -667,7 +721,7 @@ find_last_source_symtab_from_partial (struct objfile *ofp)
struct partial_symtab *ps;
struct partial_symtab *cs_pst = 0;
- ALL_OBJFILE_PSYMTABS (ofp, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (ofp, ps)
{
const char *name = ps->filename;
int len = strlen (name);
@@ -696,7 +750,7 @@ forget_cached_source_info_partial (struct objfile *objfile)
{
struct partial_symtab *pst;
- ALL_OBJFILE_PSYMTABS (objfile, pst)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
{
if (pst->fullname != NULL)
{
@@ -873,7 +927,7 @@ print_psymtab_stats_for_objfile (struct objfile *objfile)
struct partial_symtab *ps;
i = 0;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
if (ps->readin == 0)
i++;
@@ -915,7 +969,7 @@ read_symtabs_for_function (struct objfile *objfile, const char *func_name)
{
struct partial_symtab *ps;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
if (ps->readin)
continue;
@@ -933,7 +987,7 @@ expand_partial_symbol_tables (struct objfile *objfile)
{
struct partial_symtab *psymtab;
- ALL_OBJFILE_PSYMTABS (objfile, psymtab)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, psymtab)
{
psymtab_to_symtab (psymtab);
}
@@ -944,7 +998,7 @@ read_psymtabs_with_filename (struct objfile *objfile, const char *filename)
{
struct partial_symtab *p;
- ALL_OBJFILE_PSYMTABS (objfile, p)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p)
{
if (strcmp (filename, p->filename) == 0)
PSYMTAB_TO_SYMTAB (p);
@@ -957,7 +1011,7 @@ map_symbol_names_psymtab (struct objfile *objfile,
{
struct partial_symtab *ps;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
struct partial_symbol **psym;
@@ -995,7 +1049,7 @@ map_symbol_filenames_psymtab (struct objfile *objfile,
{
struct partial_symtab *ps;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
const char *fullname;
@@ -1044,7 +1098,7 @@ find_symbol_file_from_partial (struct objfile *objfile, const char *name)
{
struct partial_symtab *pst;
- ALL_OBJFILE_PSYMTABS (objfile, pst)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
{
if (lookup_partial_symbol (pst, name, 1, VAR_DOMAIN))
return pst->filename;
@@ -1095,7 +1149,7 @@ map_matching_symbols_psymtab (const char *name, domain_enum namespace,
const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
struct partial_symtab *ps;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
QUIT;
if (ps->readin
@@ -1128,7 +1182,7 @@ expand_symtabs_matching_via_partial (struct objfile *objfile,
{
struct partial_symtab *ps;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
struct partial_symbol **psym;
struct partial_symbol **bound, **gbound, **sbound;
@@ -1640,7 +1694,7 @@ maintenance_info_psymtabs (char *regexp, int from_tty)
actually find a symtab whose name matches. */
int printed_objfile_start = 0;
- ALL_OBJFILE_PSYMTABS (objfile, psymtab)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, psymtab)
{
QUIT;