* 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.
+2011-03-07 Tom Tromey <tromey@redhat.com>
+
+ * 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.
+
2011-03-07 Tom Tromey <tromey@redhat.com>
* infrun.c (print_exited_reason): Include inferior id and pid in
for sym_read() */
coff_symfile_read, /* sym_read: read a symbol file into
symtab */
+ NULL, /* sym_read_psymbols */
coff_symfile_finish, /* sym_finish: finished with file,
cleanup */
default_symfile_offsets, /* sym_offsets: xlate external to
dbx_new_init, /* init anything gbl to entire symtab */
dbx_symfile_init, /* read initial info, setup for sym_read() */
dbx_symfile_read, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
dbx_symfile_finish, /* finished with file, cleanup */
default_symfile_offsets, /* parse user's offsets to internal form */
default_symfile_segments, /* Get segment information from a file. */
if (dwarf2_read_index (objfile))
return 1;
- dwarf2_build_psymtabs (objfile);
return 0;
}
extern void _initialize_elfread (void);
-/* Forward declaration. */
+/* Forward declarations. */
static const struct sym_fns elf_sym_fns_gdb_index;
+static const struct sym_fns elf_sym_fns_lazy_psyms;
/* The struct elfinfo is available only during ELF symbol table and
psymtab reading. It is destroyed at the completion of psymtab-reading.
bfd_section_size (abfd, str_sect));
}
- if (dwarf2_has_info (objfile) && dwarf2_initialize_objfile (objfile))
- objfile->sf = &elf_sym_fns_gdb_index;
-
+ if (dwarf2_has_info (objfile))
+ {
+ if (dwarf2_initialize_objfile (objfile))
+ objfile->sf = &elf_sym_fns_gdb_index;
+ else
+ {
+ /* It is ok to do this even if the stabs reader made some
+ partial symbols, because OBJF_PSYMTABS_READ has not been
+ set, and so our lazy reader function will still be called
+ when needed. */
+ objfile->sf = &elf_sym_fns_lazy_psyms;
+ }
+ }
/* If the file has its own symbol tables it has no separate debug
info. `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to
SYMTABS/PSYMTABS. `.gnu_debuglink' may no longer be present with
`.note.gnu.build-id'. */
- if (!objfile_has_partial_symbols (objfile))
+ else if (!objfile_has_partial_symbols (objfile))
{
char *debugfile;
}
}
+/* Callback to lazily read psymtabs. */
+
+static void
+read_psyms (struct objfile *objfile)
+{
+ if (dwarf2_has_info (objfile))
+ dwarf2_build_psymtabs (objfile);
+}
+
/* This cleans up the objfile's deprecated_sym_stab_info pointer, and
the chain of stab_section_info's, that might be dangling from
it. */
elf_new_init, /* init anything gbl to entire symtab */
elf_symfile_init, /* read initial info, setup for sym_read() */
elf_symfile_read, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
+ elf_symfile_finish, /* finished with file, cleanup */
+ default_symfile_offsets, /* Translate ext. to int. relocation */
+ elf_symfile_segments, /* Get segment information from a file. */
+ NULL,
+ default_symfile_relocate, /* Relocate a debug section. */
+ &psym_functions
+};
+
+/* The same as elf_sym_fns, but not registered and lazily reads
+ psymbols. */
+
+static const struct sym_fns elf_sym_fns_lazy_psyms =
+{
+ bfd_target_elf_flavour,
+ elf_new_init, /* init anything gbl to entire symtab */
+ elf_symfile_init, /* read initial info, setup for sym_read() */
+ elf_symfile_read, /* read a symbol file into symtab */
+ read_psyms, /* sym_read_psymbols */
elf_symfile_finish, /* finished with file, cleanup */
default_symfile_offsets, /* Translate ext. to int. relocation */
elf_symfile_segments, /* Get segment information from a file. */
elf_new_init, /* init anything gbl to entire symab */
elf_symfile_init, /* read initial info, setup for sym_red() */
elf_symfile_read, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
elf_symfile_finish, /* finished with file, cleanup */
default_symfile_offsets, /* Translate ext. to int. relocatin */
elf_symfile_segments, /* Get segment information from a file. */
macho_new_init, /* init anything gbl to entire symtab */
macho_symfile_init, /* read initial info, setup for sym_read() */
macho_symfile_read, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
macho_symfile_finish, /* finished with file, cleanup */
macho_symfile_offsets, /* xlate external to internal form */
default_symfile_segments, /* Get segment information from a file. */
mipscoff_new_init, /* init anything gbl to entire symtab */
mipscoff_symfile_init, /* read initial info, setup for sym_read() */
mipscoff_symfile_read, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
mipscoff_symfile_finish, /* finished with file, cleanup */
default_symfile_offsets, /* dummy FIXME til implem sym reloc */
default_symfile_segments, /* Get segment information from a file. */
int
objfile_has_partial_symbols (struct objfile *objfile)
{
- return objfile->sf ? objfile->sf->qf->has_symbols (objfile) : 0;
+ if (!objfile->sf)
+ return 0;
+ /* If we have not read psymbols, but we have a function capable of
+ reading them, then that is an indication that they are in fact
+ available. */
+ if ((objfile->flags & OBJF_PSYMTABS_READ) == 0)
+ return objfile->sf->sym_read_psymbols != NULL;
+ return objfile->sf->qf->has_symbols (objfile);
}
/* Return non-zero if OBJFILE has full symbols. */
#define OBJF_USERLOADED (1 << 3) /* User loaded */
+/* Set if we have tried to read partial symtabs for this objfile.
+ This is used to allow lazy reading of partial symtabs. */
+
+#define OBJF_PSYMTABS_READ (1 << 4)
+
/* The object file that contains the runtime common minimal symbols
for SunOS4. Note that this objfile has no associated BFD. */
#define ALL_OBJFILE_PSYMTABS(objfile, p) \
for ((p) = (objfile) -> psymtabs; (p) != NULL; (p) = (p) -> next)
-/* Traverse all psymtabs in all objfiles. */
-
-#define ALL_PSYMTABS(objfile, p) \
- ALL_OBJFILES (objfile) \
- ALL_OBJFILE_PSYMTABS (objfile, p)
-
#endif /* PSYMPRIV_H */
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. */
{
struct partial_symtab *pst;
- ALL_OBJFILE_PSYMTABS (objfile, pst)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
{
if (FILENAME_CMP (name, pst->filename) == 0)
{
/* 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);
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;
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);
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));
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);
{
struct partial_symtab *pst;
- ALL_OBJFILE_PSYMTABS (objfile, pst)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
{
if (pst->fullname != NULL)
{
struct partial_symtab *ps;
i = 0;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
if (ps->readin == 0)
i++;
{
struct partial_symtab *ps;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
if (ps->readin)
continue;
{
struct partial_symtab *psymtab;
- ALL_OBJFILE_PSYMTABS (objfile, psymtab)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, psymtab)
{
psymtab_to_symtab (psymtab);
}
{
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);
{
struct partial_symtab *ps;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
struct partial_symbol **psym;
{
struct partial_symtab *ps;
- ALL_OBJFILE_PSYMTABS (objfile, ps)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
const char *fullname;
{
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;
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
{
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;
actually find a symtab whose name matches. */
int printed_objfile_start = 0;
- ALL_OBJFILE_PSYMTABS (objfile, psymtab)
+ ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, psymtab)
{
QUIT;
extern const struct quick_symbol_functions dwarf2_gdb_index_functions;
+/* Ensure that the partial symbols for OBJFILE have been loaded. If
+ VERBOSE is non-zero, then this will print a message when symbols
+ are loaded. This function always returns its argument, as a
+ convenience. */
+
+extern struct objfile *require_partial_symbols (struct objfile *objfile,
+ int verbose);
+
#endif /* PSYMTAB_H */
som_new_init, /* init anything gbl to entire symtab */
som_symfile_init, /* read initial info, setup for sym_read() */
som_symfile_read, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
som_symfile_finish, /* finished with file, cleanup */
som_symfile_offsets, /* Translate ext. to int. relocation */
default_symfile_segments, /* Get segment information from a file. */
(*objfile->sf->sym_read) (objfile, add_flags);
+ if ((add_flags & SYMFILE_NO_READ) == 0)
+ require_partial_symbols (objfile, 0);
+
/* Discard cleanups as symbol reading was successful. */
discard_cleanups (old_chain);
struct cleanup *my_cleanups;
const char *name = bfd_get_filename (abfd);
const int from_tty = add_flags & SYMFILE_VERBOSE;
+ const int should_print = ((from_tty || info_verbose)
+ && (readnow_symbol_files
+ || (add_flags & SYMFILE_NO_READ) == 0));
if (readnow_symbol_files)
- flags |= OBJF_READNOW;
+ {
+ flags |= OBJF_READNOW;
+ add_flags &= ~SYMFILE_NO_READ;
+ }
my_cleanups = make_cleanup_bfd_close (abfd);
/* We either created a new mapped symbol table, mapped an existing
symbol table file which has not had initial symbol reading
performed, or need to read an unmapped symbol table. */
- if (from_tty || info_verbose)
+ if (should_print)
{
if (deprecated_pre_add_symbol_hook)
deprecated_pre_add_symbol_hook (name);
if ((flags & OBJF_READNOW))
{
- if (from_tty || info_verbose)
+ if (should_print)
{
printf_unfiltered (_("expanding to full symbols..."));
wrap_here ("");
objfile->sf->qf->expand_all_symtabs (objfile);
}
- if ((from_tty || info_verbose)
- && !objfile_has_symbols (objfile))
+ if (should_print && !objfile_has_symbols (objfile))
{
wrap_here ("");
printf_unfiltered (_("(no debugging symbols found)..."));
wrap_here ("");
}
- if (from_tty || info_verbose)
+ if (should_print)
{
if (deprecated_post_add_symbol_hook)
deprecated_post_add_symbol_hook ();
/* Do not set flags as this is safe and we don't want to be
verbose. */
(*objfile->sf->sym_read) (objfile, 0);
+ if ((objfile->flags & OBJF_PSYMTABS_READ) != 0)
+ {
+ objfile->flags &= ~OBJF_PSYMTABS_READ;
+ require_partial_symbols (objfile, 0);
+ }
+
if (!objfile_has_symbols (objfile))
{
wrap_here ("");
void (*sym_read) (struct objfile *, int);
+ /* Read the partial symbols for an objfile. This may be NULL, in
+ which case gdb assumes that sym_read already read the partial
+ symbols. This may only be non-NULL if the objfile actually does
+ have debuginfo available. */
+
+ void (*sym_read_psymbols) (struct objfile *);
+
/* Called when we are finished with an objfile. Should do all
cleanup that is specific to the object file format for the
particular objfile. */
SYMFILE_MAINLINE = 1 << 2,
/* Do not call breakpoint_re_set when adding this symbol file. */
- SYMFILE_DEFER_BP_RESET = 1 << 3
+ SYMFILE_DEFER_BP_RESET = 1 << 3,
+
+ /* Do not immediately read symbols for this file. By default,
+ symbols are read when the objfile is created. */
+ SYMFILE_NO_READ = 1 << 4
};
extern void syms_from_objfile (struct objfile *,
xcoff_new_init, /* init anything gbl to entire symtab */
xcoff_symfile_init, /* read initial info, setup for sym_read() */
xcoff_initial_scan, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
xcoff_symfile_finish, /* finished with file, cleanup */
xcoff_symfile_offsets, /* xlate offsets ext->int form */
default_symfile_segments, /* Get segment information from a file. */