+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.
+
2019-01-10 Tom Tromey <tom@tromey.com>
* symtab.h (SYMBOL_SET_NAMES): Update.
addrmap_index_data.objfile = objfile;
addrmap_index_data.previous_valid = 0;
- addrmap_foreach (objfile->psymtabs_addrmap, add_address_entry_worker,
- &addrmap_index_data);
+ addrmap_foreach (objfile->partial_symtabs->psymtabs_addrmap,
+ add_address_entry_worker, &addrmap_index_data);
/* It's highly unlikely the last entry (end address = 0xff...ff)
is valid, but we should still handle it.
write_psymbols (info->symtab,
info->psyms_seen,
- (info->objfile->global_psymbols.data ()
+ (info->objfile->partial_symtabs->global_psymbols.data ()
+ psymtab->globals_offset),
psymtab->n_global_syms, info->cu_index,
0);
write_psymbols (info->symtab,
info->psyms_seen,
- (info->objfile->static_psymbols.data ()
+ (info->objfile->partial_symtabs->static_psymbols.data ()
+ psymtab->statics_offset),
psymtab->n_static_syms, info->cu_index,
1);
write_psymbols (symtab,
psyms_seen,
- objfile->global_psymbols.data () + psymtab->globals_offset,
+ (objfile->partial_symtabs->global_psymbols.data ()
+ + psymtab->globals_offset),
psymtab->n_global_syms, cu_index,
0);
write_psymbols (symtab,
psyms_seen,
- objfile->static_psymbols.data () + psymtab->statics_offset,
+ (objfile->partial_symtabs->static_psymbols.data ()
+ + psymtab->statics_offset),
psymtab->n_static_syms, cu_index,
1);
}
psyms_seen, cu_index);
write_psymbols (psyms_seen,
- objfile->global_psymbols.data () + psymtab->globals_offset,
+ (objfile->partial_symtabs->global_psymbols.data ()
+ + psymtab->globals_offset),
psymtab->n_global_syms, cu_index, false, unit_kind::cu);
write_psymbols (psyms_seen,
- objfile->static_psymbols.data () + psymtab->statics_offset,
+ (objfile->partial_symtabs->static_psymbols.data ()
+ + psymtab->statics_offset),
psymtab->n_static_syms, cu_index, true, unit_kind::cu);
}
struct partial_symtab *psymtab = entry->per_cu.v.psymtab;
write_psymbols (info->psyms_seen,
- (info->objfile->global_psymbols.data ()
+ (info->objfile->partial_symtabs->global_psymbols.data ()
+ psymtab->globals_offset),
psymtab->n_global_syms, info->cu_index, false,
unit_kind::tu);
write_psymbols (info->psyms_seen,
- (info->objfile->static_psymbols.data ()
+ (info->objfile->partial_symtabs->static_psymbols.data ()
+ psymtab->statics_offset),
psymtab->n_static_syms, info->cu_index, true,
unit_kind::tu);
if (VEC_length (dwarf2_section_info_def, dwarf2_per_objfile->types) > 1)
error (_("Cannot make an index when the file has multiple .debug_types sections"));
- if (!objfile->psymtabs || !objfile->psymtabs_addrmap)
+ if (!objfile->partial_symtabs->psymtabs
+ || !objfile->partial_symtabs->psymtabs_addrmap)
return;
struct stat st;
dwarf2_per_objfile->get_cu (cu_index));
}
- objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
- &objfile->objfile_obstack);
+ objfile->partial_symtabs->psymtabs_addrmap
+ = addrmap_create_fixed (mutable_map, &objfile->objfile_obstack);
}
/* Read the address map data from DWARF-5 .debug_aranges, and use it to
}
}
- objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
- &objfile->objfile_obstack);
+ objfile->partial_symtabs->psymtabs_addrmap
+ = addrmap_create_fixed (mutable_map, &objfile->objfile_obstack);
}
/* Find a slot in the mapped index INDEX for the object named NAME.
struct dwarf2_per_cu_data *data;
struct compunit_symtab *result;
- if (!objfile->psymtabs_addrmap)
+ if (!objfile->partial_symtabs->psymtabs_addrmap)
return NULL;
CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
SECT_OFF_TEXT (objfile));
- data = (struct dwarf2_per_cu_data *) addrmap_find (objfile->psymtabs_addrmap,
- pc - baseaddr);
+ data = (struct dwarf2_per_cu_data *) addrmap_find
+ (objfile->partial_symtabs->psymtabs_addrmap, pc - baseaddr);
if (!data)
return NULL;
- baseaddr - 1);
/* Store the contiguous range if it is not empty; it can be
empty for CUs with no code. */
- addrmap_set_empty (objfile->psymtabs_addrmap, low, high, pst);
+ addrmap_set_empty (objfile->partial_symtabs->psymtabs_addrmap,
+ low, high, pst);
}
/* Check if comp unit has_children.
auto_obstack temp_obstack;
scoped_restore save_psymtabs_addrmap
- = make_scoped_restore (&objfile->psymtabs_addrmap,
+ = make_scoped_restore (&objfile->partial_symtabs->psymtabs_addrmap,
addrmap_create_mutable (&temp_obstack));
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units)
set_partial_user (dwarf2_per_objfile);
- objfile->psymtabs_addrmap = addrmap_create_fixed (objfile->psymtabs_addrmap,
- &objfile->objfile_obstack);
+ objfile->partial_symtabs->psymtabs_addrmap
+ = addrmap_create_fixed (objfile->partial_symtabs->psymtabs_addrmap,
+ &objfile->objfile_obstack);
/* At this point we want to keep the address map. */
save_psymtabs_addrmap.release ();
= (gdbarch_adjust_dwarf2_addr (gdbarch,
pdi->highpc + baseaddr)
- baseaddr);
- addrmap_set_empty (objfile->psymtabs_addrmap,
+ addrmap_set_empty (objfile->partial_symtabs->psymtabs_addrmap,
this_lowpc, this_highpc - 1,
cu->per_cu->v.psymtab);
}
highpc = (gdbarch_adjust_dwarf2_addr (gdbarch,
range_end + baseaddr)
- baseaddr);
- addrmap_set_empty (objfile->psymtabs_addrmap, lowpc, highpc - 1,
- ranges_pst);
+ addrmap_set_empty (objfile->partial_symtabs->psymtabs_addrmap,
+ lowpc, highpc - 1, ranges_pst);
}
/* FIXME: This is recording everything as a low-high
/* Remove the dummy psymtab created for -O3 images above, if it is
still empty, to enable the detection of stripped executables. */
- if (objfile->psymtabs->next == NULL
- && objfile->psymtabs->number_of_dependencies == 0
- && objfile->psymtabs->n_global_syms == 0
- && objfile->psymtabs->n_static_syms == 0)
- objfile->psymtabs = NULL;
+ pst = objfile->partial_symtabs->psymtabs;
+ if (pst->next == NULL
+ && pst->number_of_dependencies == 0
+ && pst->n_global_syms == 0
+ && pst->n_static_syms == 0)
+ objfile->partial_symtabs->psymtabs = NULL;
}
/* If the current psymbol has an enumerated type, we need to add
objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_)
: flags (flags_),
pspace (current_program_space),
- obfd (abfd),
- psymbol_cache (psymbol_bcache_init ())
+ partial_symtabs (new psymtab_storage (this)),
+ obfd (abfd)
{
const char *expanded_name;
}
/* Free the obstacks for non-reusable objfiles. */
- psymbol_bcache_free (psymbol_cache);
obstack_free (&objfile_obstack, 0);
/* Rebuild section map next time we need it. */
#include "progspace.h"
#include "registry.h"
#include "gdb_bfd.h"
+#include "psymtab.h"
#include <vector>
#include "common/next-iterator.h"
#include "common/safe-iterator.h"
struct compunit_symtab *compunit_symtabs = nullptr;
- /* Each objfile points to a linked list of partial symtabs derived from
- this file, one partial symtab structure for each compilation unit
- (source file). */
+ /* The partial symbol tables. */
- 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;
+ 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. */
struct obstack objfile_obstack {};
- /* A byte cache where we can stash arbitrary "chunks" of bytes that
- will not change. */
-
- struct psymbol_bcache *psymbol_cache;
-
/* Map symbol addresses to the partial symtab that defines the
object at that address. */
std::vector<std::pair<CORE_ADDR, partial_symtab *>> psymbol_map;
- /* 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;
-
/* Structure which keeps track of functions that manipulate objfile's
of the same type as this objfile. I.e. the function to read partial
symbols for example. Note that this structure is in statically
struct objfile *m_objfile;
};
+/* A range adapter that makes it possible to iterate over all
+ psymtabs in one objfile. */
+
+class objfile_psymtabs : public next_adapter<struct partial_symtab>
+{
+public:
+
+ explicit objfile_psymtabs (struct objfile *objfile)
+ : next_adapter<struct partial_symtab> (objfile->partial_symtabs->psymtabs)
+ {
+ }
+};
+
#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
if (osect->the_bfd_section == NULL) \
struct objfile *objfile)
ATTRIBUTE_NONNULL (1);
-extern void discard_psymtab (struct objfile *, struct partial_symtab *);
+static inline void
+discard_psymtab (struct objfile *objfile, struct partial_symtab *pst)
+{
+ objfile->partial_symtabs->discard_psymtab (pst);
+}
/* Used when recording partial symbol tables. On destruction,
discards any partial symbol tables that have been built. However,
psymtab_discarder (struct objfile *objfile)
: m_objfile (objfile),
- m_psymtab (objfile->psymtabs)
+ m_psymtab (objfile->partial_symtabs->psymtabs)
{
}
~psymtab_discarder ()
{
if (m_objfile != NULL)
- while (m_objfile->psymtabs != m_psymtab)
- discard_psymtab (m_objfile, m_objfile->psymtabs);
+ m_objfile->partial_symtabs->discard_psymtabs_to (m_psymtab);
}
/* Keep any partial symbol tables that were built. */
static struct compunit_symtab *psymtab_to_symtab (struct objfile *objfile,
struct partial_symtab *pst);
+\f
+
+psymtab_storage::psymtab_storage (struct objfile *objfile)
+ : obstack (&objfile->objfile_obstack),
+ psymbol_cache (psymbol_bcache_init ())
+{
+}
+
+psymtab_storage::~psymtab_storage ()
+{
+ psymbol_bcache_free (psymbol_cache);
+}
+
+\f
+
/* See psymtab.h. */
objfile_psymtabs
/* Partial symbols list are not expected to changed after this
point. */
- objfile->global_psymbols.shrink_to_fit ();
- objfile->static_psymbols.shrink_to_fit ();
+ objfile->partial_symtabs->global_psymbols.shrink_to_fit ();
+ objfile->partial_symtabs->static_psymbols.shrink_to_fit ();
if (verbose && !objfile_has_symbols (objfile))
printf_filtered (_("(No debugging symbols found in %s)\n"),
/* Try just the PSYMTABS_ADDRMAP mapping first as it has better granularity
than the later used TEXTLOW/TEXTHIGH one. */
- if (objfile->psymtabs_addrmap != NULL)
+ if (objfile->partial_symtabs->psymtabs_addrmap != NULL)
{
struct partial_symtab *pst
= ((struct partial_symtab *)
- addrmap_find (objfile->psymtabs_addrmap, pc - baseaddr));
+ addrmap_find (objfile->partial_symtabs->psymtabs_addrmap,
+ pc - baseaddr));
if (pst != NULL)
{
/* FIXME: addrmaps currently do not handle overlayed sections,
cache a bad endaddr. */
for (int i = 0; i < psymtab->n_global_syms; i++)
{
- partial_symbol *p = objfile->global_psymbols[psymtab->globals_offset + i];
+ partial_symbol *p
+ = objfile->partial_symtabs->global_psymbols[psymtab->globals_offset
+ + i];
if (p->domain == VAR_DOMAIN
&& p->aclass == LOC_BLOCK
for (int i = 0; i < psymtab->n_static_syms; i++)
{
- partial_symbol *p = objfile->static_psymbols[psymtab->statics_offset + i];
+ partial_symbol *p
+ = objfile->partial_symtabs->static_psymbols[psymtab->statics_offset
+ + i];
if (p->domain == VAR_DOMAIN
&& p->aclass == LOC_BLOCK
lookup_name_info lookup_name (name, match_type);
start = (global ?
- &objfile->global_psymbols[pst->globals_offset] :
- &objfile->static_psymbols[pst->statics_offset]);
+ &objfile->partial_symtabs->global_psymbols[pst->globals_offset] :
+ &objfile->partial_symtabs->static_psymbols[pst->statics_offset]);
if (global && ordered_compare) /* Can use a binary search. */
{
lookup_name_info lookup_name (search_name.get (), symbol_name_match_type::FULL);
start = (global ?
- &objfile->global_psymbols[pst->globals_offset] :
- &objfile->static_psymbols[pst->statics_offset]);
+ &objfile->partial_symtabs->global_psymbols[pst->globals_offset] :
+ &objfile->partial_symtabs->static_psymbols[pst->statics_offset]);
if (global) /* This means we can use a binary search. */
{
}
if (psymtab->n_global_syms > 0)
{
- print_partial_symbols (gdbarch, objfile,
- &objfile->global_psymbols[psymtab->globals_offset],
- psymtab->n_global_syms, "Global", outfile);
+ print_partial_symbols
+ (gdbarch, objfile,
+ &objfile->partial_symtabs->global_psymbols[psymtab->globals_offset],
+ psymtab->n_global_syms, "Global", outfile);
}
if (psymtab->n_static_syms > 0)
{
- print_partial_symbols (gdbarch, objfile,
- &objfile->static_psymbols[psymtab->statics_offset],
- psymtab->n_static_syms, "Static", outfile);
+ print_partial_symbols
+ (gdbarch, objfile,
+ &objfile->partial_symtabs->static_psymbols[psymtab->statics_offset],
+ psymtab->n_static_syms, "Static", outfile);
}
fprintf_filtered (outfile, "\n");
}
{
struct partial_symtab *psymtab;
- if (objfile->psymtabs)
+ if (objfile->partial_symtabs->psymtabs)
{
printf_filtered ("Psymtabs:\n");
- for (psymtab = objfile->psymtabs;
+ for (psymtab = objfile->partial_symtabs->psymtabs;
psymtab != NULL;
psymtab = psymtab->next)
{
}
partial_symbol **gbound
- = objfile->global_psymbols.data () + ps->globals_offset + ps->n_global_syms;
+ = (objfile->partial_symtabs->global_psymbols.data ()
+ + ps->globals_offset + ps->n_global_syms);
partial_symbol **sbound
- = objfile->static_psymbols.data () + ps->statics_offset + ps->n_static_syms;
+ = (objfile->partial_symtabs->static_psymbols.data ()
+ + ps->statics_offset + ps->n_static_syms);
partial_symbol **bound = gbound;
/* Go through all of the symbols stored in a partial
symtab in one loop. */
- partial_symbol **psym = objfile->global_psymbols.data () + ps->globals_offset;
+ partial_symbol **psym = (objfile->partial_symtabs->global_psymbols.data ()
+ + ps->globals_offset);
while (keep_going)
{
if (psym >= bound)
{
if (bound == gbound && ps->n_static_syms != 0)
{
- psym = objfile->static_psymbols.data () + ps->statics_offset;
+ psym = (objfile->partial_symtabs->static_psymbols.data ()
+ + ps->statics_offset);
bound = sbound;
}
else
static int
psym_has_symbols (struct objfile *objfile)
{
- return objfile->psymtabs != NULL;
+ return objfile->partial_symtabs->psymtabs != NULL;
}
/* Helper function for psym_find_compunit_symtab_by_address that fills
{
psym_fill_psymbol_map (objfile, pst,
&seen_addrs,
- objfile->global_psymbols,
+ objfile->partial_symtabs->global_psymbols,
pst->globals_offset,
pst->n_global_syms);
psym_fill_psymbol_map (objfile, pst,
&seen_addrs,
- objfile->static_psymbols,
+ objfile->partial_symtabs->static_psymbols,
pst->statics_offset,
pst->n_static_syms);
}
sort_pst_symbols (struct objfile *objfile, struct partial_symtab *pst)
{
/* Sort the global list; don't sort the static list. */
- auto begin = objfile->global_psymbols.begin ();
+ auto begin = objfile->partial_symtabs->global_psymbols.begin ();
std::advance (begin, pst->globals_offset);
/* The psymbols for this partial_symtab are currently at the end of the
vector. */
- auto end = objfile->global_psymbols.end ();
+ auto end = objfile->partial_symtabs->global_psymbols.end ();
std::sort (begin, end, [] (partial_symbol *s1, partial_symbol *s2)
{
psymtab = allocate_psymtab (filename, objfile);
psymtab->set_text_low (textlow);
psymtab->set_text_high (psymtab->raw_text_low ()); /* default */
- psymtab->globals_offset = objfile->global_psymbols.size ();
- psymtab->statics_offset = objfile->static_psymbols.size ();
+ psymtab->globals_offset = objfile->partial_symtabs->global_psymbols.size ();
+ psymtab->statics_offset = objfile->partial_symtabs->static_psymbols.size ();
return psymtab;
}
void
end_psymtab_common (struct objfile *objfile, struct partial_symtab *pst)
{
- pst->n_global_syms = objfile->global_psymbols.size () - pst->globals_offset;
- pst->n_static_syms = objfile->static_psymbols.size () - pst->statics_offset;
+ pst->n_global_syms = (objfile->partial_symtabs->global_psymbols.size ()
+ - pst->globals_offset);
+ pst->n_static_syms = (objfile->partial_symtabs->static_psymbols.size ()
+ - pst->statics_offset);
sort_pst_symbols (objfile, pst);
}
symbol_set_names (&psymbol, name, namelength, copy_name, objfile->per_bfd);
/* Stash the partial symbol away in the cache. */
- return psymbol_bcache_full (&psymbol, objfile->psymbol_cache, added);
+ return psymbol_bcache_full (&psymbol,
+ objfile->partial_symtabs->psymbol_cache,
+ added);
}
/* Helper function, adds partial symbol to the given partial symbol list. */
/* Save pointer to partial symbol in psymtab, growing symtab if needed. */
std::vector<partial_symbol *> *list
= (where == psymbol_placement::STATIC
- ? &objfile->static_psymbols
- : &objfile->global_psymbols);
+ ? &objfile->partial_symtabs->static_psymbols
+ : &objfile->partial_symtabs->global_psymbols);
append_psymbol_to_list (list, psym, objfile);
}
void
init_psymbol_list (struct objfile *objfile, int total_symbols)
{
- if (objfile->global_psymbols.capacity () == 0
- && objfile->static_psymbols.capacity () == 0)
+ if (objfile->partial_symtabs->global_psymbols.capacity () == 0
+ && objfile->partial_symtabs->static_psymbols.capacity () == 0)
{
/* Current best guess is that approximately a twentieth of the
total symbols (in a debugging file) are global or static
oriented symbols, then multiply that by slop factor of
two. */
- objfile->global_psymbols.reserve (total_symbols / 10);
- objfile->static_psymbols.reserve (total_symbols / 10);
+ objfile->partial_symtabs->global_psymbols.reserve (total_symbols / 10);
+ objfile->partial_symtabs->static_psymbols.reserve (total_symbols / 10);
}
}
{
struct partial_symtab *psymtab;
- if (objfile->free_psymtabs)
+ if (objfile->partial_symtabs->free_psymtabs)
{
- psymtab = objfile->free_psymtabs;
- objfile->free_psymtabs = psymtab->next;
+ psymtab = objfile->partial_symtabs->free_psymtabs;
+ objfile->partial_symtabs->free_psymtabs = psymtab->next;
}
else
psymtab = XOBNEW (&objfile->objfile_obstack, partial_symtab);
Psymtabs are searched in most recent inserted -> least recent
inserted order. */
- psymtab->next = objfile->psymtabs;
- objfile->psymtabs = psymtab;
+ psymtab->next = objfile->partial_symtabs->psymtabs;
+ objfile->partial_symtabs->psymtabs = psymtab;
if (symtab_create_debug)
{
}
void
-discard_psymtab (struct objfile *objfile, struct partial_symtab *pst)
+psymtab_storage::discard_psymtab (struct partial_symtab *pst)
{
struct partial_symtab **prev_pst;
/* First, snip it out of the psymtab chain. */
- prev_pst = &(objfile->psymtabs);
+ prev_pst = &psymtabs;
while ((*prev_pst) != pst)
prev_pst = &((*prev_pst)->next);
(*prev_pst) = pst->next;
/* Next, put it on a free list for recycling. */
- pst->next = objfile->free_psymtabs;
- objfile->free_psymtabs = pst;
+ pst->next = free_psymtabs;
+ free_psymtabs = pst;
}
\f
if ((psymtab == NULL
|| psymtab->psymtabs_addrmap_supported)
- && objfile->psymtabs_addrmap != NULL)
+ && objfile->partial_symtabs->psymtabs_addrmap != NULL)
{
addrmap_dump_data.objfile = objfile;
addrmap_dump_data.psymtab = psymtab;
addrmap_dump_data.previous_matched = 0;
fprintf_filtered (outfile, "%sddress map:\n",
psymtab == NULL ? "Entire a" : " A");
- addrmap_foreach (objfile->psymtabs_addrmap, dump_psymtab_addrmap_1,
- &addrmap_dump_data);
+ addrmap_foreach (objfile->partial_symtabs->psymtabs_addrmap,
+ dump_psymtab_addrmap_1, &addrmap_dump_data);
}
}
if (address_arg == NULL
&& source_arg == NULL
- && objfile->psymtabs_addrmap != NULL)
+ && objfile->partial_symtabs->psymtabs_addrmap != NULL)
{
outfile->puts ("\n");
dump_psymtab_addrmap (objfile, NULL, outfile);
printf_filtered (" globals ");
if (psymtab->n_global_syms)
{
- auto p
- = &objfile->global_psymbols[psymtab->globals_offset];
+ auto p = &(objfile->partial_symtabs
+ ->global_psymbols[psymtab->globals_offset]);
printf_filtered
("(* (struct partial_symbol **) %s @ %d)\n",
printf_filtered (" statics ");
if (psymtab->n_static_syms)
{
- auto p
- = &objfile->static_psymbols[psymtab->statics_offset];
+ auto p = &(objfile->partial_symtabs
+ ->static_psymbols[psymtab->statics_offset]);
printf_filtered
("(* (struct partial_symbol **) %s @ %d)\n",
continue;
bv = COMPUNIT_BLOCKVECTOR (cust);
b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- partial_symbol **psym = &objfile->static_psymbols[ps->statics_offset];
+ partial_symbol **psym
+ = &objfile->partial_symtabs->static_psymbols[ps->statics_offset];
length = ps->n_static_syms;
while (length--)
{
psym++;
}
b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- psym = &objfile->global_psymbols[ps->globals_offset];
+ psym = &objfile->partial_symtabs->global_psymbols[ps->globals_offset];
length = ps->n_global_syms;
while (length--)
{
#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);
/* FIXME: Do we have to free a whole linked list, or is this
enough? */
- objfile->global_psymbols.clear ();
- objfile->static_psymbols.clear ();
+ objfile->partial_symtabs->global_psymbols.clear ();
+ objfile->partial_symtabs->static_psymbols.clear ();
/* Free the obstacks for non-reusable objfiles. */
- psymbol_bcache_free (objfile->psymbol_cache);
- objfile->psymbol_cache = psymbol_bcache_init ();
+ psymbol_bcache_free (objfile->partial_symtabs->psymbol_cache);
+ objfile->partial_symtabs->psymbol_cache = psymbol_bcache_init ();
/* NB: after this call to obstack_free, objfiles_changed
will need to be called (see discussion below). */
obstack_free (&objfile->objfile_obstack, 0);
objfile->sections = NULL;
objfile->compunit_symtabs = NULL;
- objfile->psymtabs = NULL;
- objfile->psymtabs_addrmap = NULL;
- objfile->free_psymtabs = NULL;
+ objfile->partial_symtabs->psymtabs = NULL;
+ objfile->partial_symtabs->psymtabs_addrmap = NULL;
+ objfile->partial_symtabs->free_psymtabs = NULL;
objfile->template_symbols = NULL;
objfile->static_links = NULL;
QUIT;
printf_filtered (_("Byte cache statistics for '%s':\n"),
objfile_name (objfile));
- print_bcache_statistics (psymbol_bcache_get_bcache (objfile->psymbol_cache),
- "partial symbol cache");
+ print_bcache_statistics
+ (psymbol_bcache_get_bcache (objfile->partial_symtabs->psymbol_cache),
+ "partial symbol cache");
print_bcache_statistics (objfile->per_bfd->macro_cache,
"preprocessor macro cache");
print_bcache_statistics (objfile->per_bfd->filename_cache,
printf_filtered (_(" Total memory used for BFD obstack: %s\n"),
pulongest (obstack_memory_used (&objfile->per_bfd
->storage_obstack)));
- printf_filtered (_(" Total memory used for psymbol cache: %d\n"),
- bcache_memory_used (psymbol_bcache_get_bcache
- (objfile->psymbol_cache)));
+ printf_filtered
+ (_(" Total memory used for psymbol cache: %d\n"),
+ bcache_memory_used (psymbol_bcache_get_bcache
+ (objfile->partial_symtabs->psymbol_cache)));
printf_filtered (_(" Total memory used for macro cache: %d\n"),
bcache_memory_used (objfile->per_bfd->macro_cache));
printf_filtered (_(" Total memory used for file name cache: %d\n"),