diff options
author | Tom Tromey <tom@tromey.com> | 2018-05-10 16:23:51 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-01-10 07:08:12 -0700 |
commit | d320c2b5e181828418224521f2acd2ff48e127f4 (patch) | |
tree | afaea8c763b84f9a59a49662366ad5fcf7c917d8 /gdb/psymtab.h | |
parent | 1d94a5a36a614cf7ebe259d7660f4fa725f38ee2 (diff) | |
download | gdb-d320c2b5e181828418224521f2acd2ff48e127f4.zip gdb-d320c2b5e181828418224521f2acd2ff48e127f4.tar.gz gdb-d320c2b5e181828418224521f2acd2ff48e127f4.tar.bz2 |
Introduce class psymtab_storage
This introduces a new psymtab_storage class, which holds all
psymbol-related objects that are independent of the objfile. (This
latter contraint explains why psymbol_map was not moved; though this
could still be done with some work.)
This patch does not yet change where psymtab allocation is done --
that comes later. This just wraps everything in a single object to
make further transformations simpler.
Note that a shared_ptr is used to link from the objfile to the
psymtab_storage object. The end goal here is to allow a given symbol
reader to simply attach to the psymtab_storage object to the BFD, then
reuse it in later invocations; shared_ptr makes this simple to reason
about.
gdb/ChangeLog
2019-01-10 Tom Tromey <tom@tromey.com>
* symmisc.c (print_symbol_bcache_statistics): Update.
(print_objfile_statistics): Update.
* symfile.c (reread_symbols): Update.
* psymtab.h (class psymtab_storage): New.
* psymtab.c (psymtab_storage): New constructor.
(~psymtab_storage): New destructor.
(require_partial_symbols): Update.
(ALL_OBJFILE_PSYMTABS_REQUIRED): Rewrite.
(find_pc_sect_psymtab, find_pc_sect_psymbol)
(match_partial_symbol, lookup_partial_symbol, dump_psymtab)
(psym_dump, recursively_search_psymtabs, psym_has_symbols)
(psym_find_compunit_symtab_by_address, sort_pst_symbols)
(start_psymtab_common, end_psymtab_common)
(add_psymbol_to_bcache, add_psymbol_to_list, init_psymbol_list)
(allocate_psymtab): Update.
(psymtab_storage::discard_psymtab): Rename from discard_psymtab.
Update.
(dump_psymtab_addrmap, maintenance_print_psymbols)
(maintenance_check_psymtabs): Update.
(class objfile_psymtabs): Move to objfiles.h.
* psympriv.h (discard_psymtab): Now inline.
(psymtab_discarder::psymtab_discarder): Update.
(psymtab_discarder::~psymtab_discarder): Update.
(ALL_OBJFILE_PSYMTABS): Rewrite.
* objfiles.h (struct objfile) <psymtabs, psymtabs_addrmap,
free_psymtabs, psymbol_cache, global_psymbols, static_psymbols>:
Remove fields.
<partial_symtabs>: New field.
(class objfile_psymtabs): Move from psymtab.h. Update.
* objfiles.c (objfile::objfile): Initialize partial_symtabs, not
psymbol_cache.
(objfile::~objfile): Don't destroy psymbol_cache.
* mdebugread.c (parse_partial_symbols): Update.
* dwarf2read.c (create_addrmap_from_index)
(create_addrmap_from_aranges, dw2_find_pc_sect_compunit_symtab)
(process_psymtab_comp_unit_reader, dwarf2_build_psymtabs_hard)
(add_partial_subprogram, dwarf2_ranges_read): Update.
* dwarf-index-write.c (write_address_map)
(write_one_signatured_type, recursively_write_psymbols)
(class debug_names, class debug_names, write_psymtabs_to_index):
Update.
Diffstat (limited to 'gdb/psymtab.h')
-rw-r--r-- | gdb/psymtab.h | 77 |
1 files changed, 64 insertions, 13 deletions
diff --git a/gdb/psymtab.h b/gdb/psymtab.h index a1cab96..895f950 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -23,37 +23,88 @@ #include "symfile.h" #include "common/next-iterator.h" +struct partial_symbol; + /* A bcache for partial symbols. */ struct psymbol_bcache; -extern struct psymbol_bcache *psymbol_bcache_init (void); -extern void psymbol_bcache_free (struct psymbol_bcache *); -extern struct bcache *psymbol_bcache_get_bcache (struct psymbol_bcache *); +/* An instance of this class manages the partial symbol tables and + partial symbols for a given objfile. */ -extern const struct quick_symbol_functions psym_functions; +class psymtab_storage +{ +public: -extern const struct quick_symbol_functions dwarf2_gdb_index_functions; -extern const struct quick_symbol_functions dwarf2_debug_names_functions; + explicit psymtab_storage (struct objfile *objfile); -/* A range adapter that makes it possible to iterate over all - psymtabs in one objfile. */ + ~psymtab_storage (); -class objfile_psymtabs : public next_adapter<struct partial_symtab> -{ -public: + DISABLE_COPY_AND_ASSIGN (psymtab_storage); + + /* Discard all partial symbol tables starting with "psymtabs" and + proceeding until "to" has been discarded. */ - explicit objfile_psymtabs (struct objfile *objfile) - : next_adapter<struct partial_symtab> (objfile->psymtabs) + void discard_psymtabs_to (struct partial_symtab *to) { + while (psymtabs != to) + discard_psymtab (psymtabs); } + + /* Discard the partial symbol table. */ + + void discard_psymtab (struct partial_symtab *pst); + + + /* Each objfile points to a linked list of partial symtabs derived from + this file, one partial symtab structure for each compilation unit + (source file). */ + + struct partial_symtab *psymtabs = nullptr; + + /* Map addresses to the entries of PSYMTABS. It would be more efficient to + have a map per the whole process but ADDRMAP cannot selectively remove + its items during FREE_OBJFILE. This mapping is already present even for + PARTIAL_SYMTABs which still have no corresponding full SYMTABs read. */ + + struct addrmap *psymtabs_addrmap = nullptr; + + /* List of freed partial symtabs, available for re-use. */ + + struct partial_symtab *free_psymtabs = nullptr; + + /* The obstack where allocations are made. */ + + struct obstack *obstack; + + /* A byte cache where we can stash arbitrary "chunks" of bytes that + will not change. */ + + struct psymbol_bcache *psymbol_cache; + + /* Vectors of all partial symbols read in from file. The actual data + is stored in the objfile_obstack. */ + + std::vector<partial_symbol *> global_psymbols; + std::vector<partial_symbol *> static_psymbols; }; + +extern struct psymbol_bcache *psymbol_bcache_init (void); +extern void psymbol_bcache_free (struct psymbol_bcache *); +extern struct bcache *psymbol_bcache_get_bcache (struct psymbol_bcache *); + +extern const struct quick_symbol_functions psym_functions; + +extern const struct quick_symbol_functions dwarf2_gdb_index_functions; +extern const struct quick_symbol_functions dwarf2_debug_names_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 returns a range adapter suitable for iterating over the psymtabs of OBJFILE. */ +class objfile_psymtabs; extern objfile_psymtabs require_partial_symbols (struct objfile *objfile, int verbose); |