+2021-03-20 Tom Tromey <tom@tromey.com>
+
+ * xcoffread.c (xcoff_initial_scan): Create partial symtabs.
+ * symfile.c (syms_from_objfile_1, reread_symbols): Update.
+ * psymtab.h (make_psymbol_functions): Don't declare.
+ * psymtab.c (make_psymbol_functions): Remove.
+ (maintenance_print_psymbols): Update.
+ * psympriv.h (struct psymbol_functions): Add no-argument
+ constructor.
+ * objfiles.h (struct objfile) <reset_psymtabs>: Remove.
+ <partial_symtabs>: Remove.
+ * mdebugread.c (mdebug_build_psymtabs): Create partial symtabs.
+ * elfread.c (read_partial_symbols): Update.
+ (elf_symfile_read): Remove check for existing partial symbols.
+ Don't clear "qf".
+ * dwarf2/read.c (dwarf2_has_info): Remove check for existing
+ partial symbols.
+ (dwarf2_build_psymtabs): Add psymbol_functions parameter. Create
+ partial symtabs.
+ * dwarf2/public.h (dwarf2_build_psymtabs): Add psymbol_functions
+ parameter.
+ * dbxread.c (dbx_symfile_read): Create partial symtabs.
+ * ctfread.c (elfctf_build_psymtabs): Create partial symtabs.
+
2021-03-20 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_build_psymtabs): Update.
bfd_get_filename (abfd), ctf_errmsg (err));
ctf_dict_key.emplace (of, fp);
- psymtab_storage *partial_symtabs = of->partial_symtabs.get ();
+ psymbol_functions *psf = new psymbol_functions ();
+ psymtab_storage *partial_symtabs = psf->get_partial_symtabs ().get ();
+ of->qf.emplace_front (psf);
scan_partial_symbols (fp, partial_symtabs, of);
}
/* Read stabs data from executable file and define symbols. */
- psymtab_storage *partial_symtabs = objfile->partial_symtabs.get ();
+ psymbol_functions *psf = new psymbol_functions ();
+ psymtab_storage *partial_symtabs = psf->get_partial_symtabs ().get ();
+ objfile->qf.emplace_front (psf);
read_dbx_symtab (reader, partial_symtabs, objfile);
/* Install any minimal symbols that have been collected as the current
extern bool dwarf2_initialize_objfile (struct objfile *objfile,
dw_index_kind *index_kind);
-extern void dwarf2_build_psymtabs (struct objfile *);
+struct psymbol_functions;
+extern void dwarf2_build_psymtabs (struct objfile *,
+ psymbol_functions *psf = nullptr);
extern void dwarf2_build_frame_info (struct objfile *);
extern quick_symbol_functions_up make_dwarf_gdb_index ();
dwarf2_per_bfd *per_bfd;
/* We can share a "dwarf2_per_bfd" with other objfiles if the BFD
- doesn't require relocations and if there aren't partial symbols
- from some other reader. */
- if (!objfile->has_partial_symbols ()
- && !gdb_bfd_requires_relocations (objfile->obfd))
+ doesn't require relocations. */
+ if (!gdb_bfd_requires_relocations (objfile->obfd))
{
/* See if one has been created for this BFD yet. */
per_bfd = dwarf2_per_bfd_bfd_data_key.get (objfile->obfd);
/* Build a partial symbol table. */
void
-dwarf2_build_psymtabs (struct objfile *objfile)
+dwarf2_build_psymtabs (struct objfile *objfile, psymbol_functions *psf)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
{
/* Partial symbols were already read, so now we can simply
attach them. */
- objfile->partial_symtabs = per_bfd->partial_symtabs;
- /* This is a temporary hack to ensure that the objfile and 'qf'
- psymtabs are identical. */
- psymbol_functions *psf
- = dynamic_cast<psymbol_functions *> (objfile->qf.front ().get ());
- gdb_assert (psf != nullptr);
- psf->set_partial_symtabs (per_bfd->partial_symtabs);
+ if (psf == nullptr)
+ {
+ psf = new psymbol_functions (per_bfd->partial_symtabs);
+ objfile->qf.emplace_front (psf);
+ }
+ else
+ psf->set_partial_symtabs (per_bfd->partial_symtabs);
per_objfile->resize_symtabs ();
return;
}
+ if (psf == nullptr)
+ {
+ psf = new psymbol_functions;
+ objfile->qf.emplace_front (psf);
+ }
+ const std::shared_ptr<psymtab_storage> &partial_symtabs
+ = psf->get_partial_symtabs ();
+
/* Set the local reference to partial symtabs, so that we don't try
to read them again if reading another objfile with the same BFD.
If we can't in fact share, this won't make a difference anyway as
the dwarf2_per_bfd object won't be shared. */
- per_bfd->partial_symtabs = objfile->partial_symtabs;
+ per_bfd->partial_symtabs = partial_symtabs;
try
{
/* This isn't really ideal: all the data we allocate on the
objfile's obstack is still uselessly kept around. However,
freeing it seems unsafe. */
- psymtab_discarder psymtabs (objfile->partial_symtabs.get ());
+ psymtab_discarder psymtabs (partial_symtabs.get ());
dwarf2_build_psymtabs_hard (per_objfile);
psymtabs.keep ();
void read_partial_symbols (struct objfile *objfile) override
{
if (dwarf2_has_info (objfile, nullptr))
- dwarf2_build_psymtabs (objfile);
+ dwarf2_build_psymtabs (objfile, this);
}
};
{
dw_index_kind index_kind;
- /* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF
- debug information present in OBJFILE. If there is such debug
- info present never use an index. */
- if (!objfile->has_partial_symbols ()
- && dwarf2_initialize_objfile (objfile, &index_kind))
+ if (dwarf2_initialize_objfile (objfile, &index_kind))
{
switch (index_kind)
{
case dw_index_kind::GDB_INDEX:
- objfile->qf.clear ();
objfile->qf.push_front (make_dwarf_gdb_index ());
break;
case dw_index_kind::DEBUG_NAMES:
}
}
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->qf.clear ();
- objfile->qf.emplace_front
- (new lazy_dwarf_reader (objfile->partial_symtabs));
- }
+ objfile->qf.emplace_front (new lazy_dwarf_reader);
}
/* If the file has its own symbol tables it has no separate debug
info. `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to
(*swap->swap_fdr_in) (objfile->obfd, fdr_src, fdr_ptr);
}
- psymtab_storage *partial_symtabs = objfile->partial_symtabs.get ();
+ psymbol_functions *psf = new psymbol_functions ();
+ psymtab_storage *partial_symtabs = psf->get_partial_symtabs ().get ();
+ objfile->qf.emplace_front (psf);
parse_partial_symbols (reader, partial_symtabs, objfile);
#if 0
DISABLE_COPY_AND_ASSIGN (objfile);
- /* Reset the storage for the partial symbol tables. */
-
- void reset_psymtabs ()
- {
- partial_symtabs.reset (new psymtab_storage ());
- }
-
typedef next_adapter<struct compunit_symtab> compunits_range;
/* A range adapter that makes it possible to iterate over all
struct compunit_symtab *compunit_symtabs = nullptr;
- /* The partial symbol tables. */
-
- std::shared_ptr<psymtab_storage> partial_symtabs;
-
/* The object file's BFD. Can be null if the objfile contains only
minimal symbols, e.g. the run time common symbols for SunOS4. */
{
}
+ psymbol_functions ()
+ : m_partial_symtabs (new psymtab_storage)
+ {
+ }
+
bool has_symbols (struct objfile *objfile) override;
struct symtab *find_last_source_symtab (struct objfile *objfile) override;
return psymtab_to_symtab (objfile, iter->second);
}
-quick_symbol_functions_up
-make_psymbol_functions (const std::shared_ptr<psymtab_storage> &storage)
-{
- return quick_symbol_functions_up (new psymbol_functions (storage));
-}
-
\f
/* Partially fill a partial symtab. It will be completely filled at
gdb::optional<auto_obstack> m_obstack;
};
-
-extern quick_symbol_functions_up make_psymbol_functions
- (const std::shared_ptr<psymtab_storage> &);
-
#endif /* PSYMTAB_H */
const int mainline = add_flags & SYMFILE_MAINLINE;
objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
- objfile->reset_psymtabs ();
objfile->qf.clear ();
- objfile->qf.push_front (make_psymbol_functions (objfile->partial_symtabs));
if (objfile->sf == NULL)
{
based on whether .gdb_index is present, and we need it to
start over. PR symtab/15885 */
objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
- objfile->reset_psymtabs ();
objfile->qf.clear ();
- objfile->qf.push_front
- (make_psymbol_functions (objfile->partial_symtabs));
build_objfile_section_table (objfile);
/* Now that the symbol table data of the executable file are all in core,
process them and define symbols accordingly. */
- psymtab_storage *partial_symtabs = objfile->partial_symtabs.get ();
+ psymbol_functions *psf = new psymbol_functions ();
+ psymtab_storage *partial_symtabs = psf->get_partial_symtabs ().get ();
+ objfile->qf.emplace_front (psf);
scan_xcoff_symtab (reader, partial_symtabs, objfile);
/* Install any minimal symbols that have been collected as the current