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.
This commit is contained in:
Tom Tromey 2018-05-10 16:23:51 -06:00
parent 1d94a5a36a
commit d320c2b5e1
11 changed files with 273 additions and 145 deletions

View file

@ -3190,8 +3190,8 @@ create_addrmap_from_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
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
@ -3351,8 +3351,8 @@ create_addrmap_from_aranges (struct dwarf2_per_objfile *dwarf2_per_objfile,
}
}
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.
@ -5245,13 +5245,13 @@ dw2_find_pc_sect_compunit_symtab (struct objfile *objfile,
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;
@ -8010,7 +8010,8 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
- 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.
@ -8467,7 +8468,7 @@ dwarf2_build_psymtabs_hard (struct dwarf2_per_objfile *dwarf2_per_objfile)
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)
@ -8488,8 +8489,9 @@ dwarf2_build_psymtabs_hard (struct dwarf2_per_objfile *dwarf2_per_objfile)
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 ();
@ -9113,7 +9115,7 @@ add_partial_subprogram (struct partial_die_info *pdi,
= (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);
}
@ -14603,8 +14605,8 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
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