From efd7398ee26dc8f810243fc893590df4a8cd3238 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 20 Mar 2021 17:23:40 -0600 Subject: Change how DWARF indices use addrmap Currently the DWARF index readers reuse the objfile's partial symbol table in order to store an addrmap. We're going to be remove the partial symbol object, so this patch changes the DWARF reader to store this addrmap in the per_bfd object. This object is chosen, rather than the quick_symbol_functions subclass, because the addrmap can be shared across objfiles. gdb/ChangeLog 2021-03-20 Tom Tromey * dwarf2/read.h (struct dwarf2_per_bfd) : New member. * dwarf2/read.c (create_addrmap_from_index) (create_addrmap_from_aranges): Set per_bfd addrmap. (dwarf2_read_gdb_index): Don't set partial_symtabs. (dwarf2_base_index_functions::find_pc_sect_compunit_symtab): Use per_bfd addrmap. (dwarf2_read_debug_names): Don't set partial_symtabs. (dwarf2_initialize_objfile): Likewise. --- gdb/ChangeLog | 12 ++++++++++++ gdb/dwarf2/read.c | 43 +++++++++++++++++-------------------------- gdb/dwarf2/read.h | 3 +++ 3 files changed, 32 insertions(+), 26 deletions(-) (limited to 'gdb') diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6123270..fcc8f2a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,17 @@ 2021-03-20 Tom Tromey + * dwarf2/read.h (struct dwarf2_per_bfd) : New + member. + * dwarf2/read.c (create_addrmap_from_index) + (create_addrmap_from_aranges): Set per_bfd addrmap. + (dwarf2_read_gdb_index): Don't set partial_symtabs. + (dwarf2_base_index_functions::find_pc_sect_compunit_symtab): Use + per_bfd addrmap. + (dwarf2_read_debug_names): Don't set partial_symtabs. + (dwarf2_initialize_objfile): Likewise. + +2021-03-20 Tom Tromey + * dwarf2/read.c (dwarf2_build_psymtabs): Set partial_symtabs earlier. diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 9de9e48..483c6fb 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2700,13 +2700,14 @@ create_signatured_type_table_from_debug_names } /* Read the address map data from the mapped index, and use it to - populate the objfile's psymtabs_addrmap. */ + populate the psymtabs_addrmap. */ static void create_addrmap_from_index (dwarf2_per_objfile *per_objfile, struct mapped_index *index) { struct objfile *objfile = per_objfile->objfile; + dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; struct gdbarch *gdbarch = objfile->arch (); const gdb_byte *iter, *end; struct addrmap *mutable_map; @@ -2738,7 +2739,7 @@ create_addrmap_from_index (dwarf2_per_objfile *per_objfile, continue; } - if (cu_index >= per_objfile->per_bfd->all_comp_units.size ()) + if (cu_index >= per_bfd->all_comp_units.size ()) { complaint (_(".gdb_index address table has invalid CU number %u"), (unsigned) cu_index); @@ -2748,15 +2749,15 @@ create_addrmap_from_index (dwarf2_per_objfile *per_objfile, lo = gdbarch_adjust_dwarf2_addr (gdbarch, lo + baseaddr) - baseaddr; hi = gdbarch_adjust_dwarf2_addr (gdbarch, hi + baseaddr) - baseaddr; addrmap_set_empty (mutable_map, lo, hi - 1, - per_objfile->per_bfd->get_cu (cu_index)); + per_bfd->get_cu (cu_index)); } - objfile->partial_symtabs->psymtabs_addrmap - = addrmap_create_fixed (mutable_map, objfile->partial_symtabs->obstack ()); + per_bfd->index_addrmap = addrmap_create_fixed (mutable_map, + &per_bfd->obstack); } /* Read the address map data from DWARF-5 .debug_aranges, and use it to - populate the objfile's psymtabs_addrmap. */ + populate the psymtabs_addrmap. */ static void create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, @@ -2766,6 +2767,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, bfd *abfd = objfile->obfd; struct gdbarch *gdbarch = objfile->arch (); const CORE_ADDR baseaddr = objfile->text_section_offset (); + dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; auto_obstack temp_obstack; addrmap *mutable_map = addrmap_create_mutable (&temp_obstack); @@ -2902,7 +2904,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, addr += address_size; if (start == 0 && length == 0) break; - if (start == 0 && !per_objfile->per_bfd->has_section_at_zero) + if (start == 0 && !per_bfd->has_section_at_zero) { /* Symbol was eliminated due to a COMDAT group. */ continue; @@ -2916,8 +2918,8 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, } } - objfile->partial_symtabs->psymtabs_addrmap - = addrmap_create_fixed (mutable_map, objfile->partial_symtabs->obstack ()); + per_bfd->index_addrmap = addrmap_create_fixed (mutable_map, + &per_bfd->obstack); } /* Find a slot in the mapped index INDEX for the object named NAME. @@ -3184,11 +3186,6 @@ dwarf2_read_gdb_index per_bfd->quick_file_names_table = create_quick_file_names_table (per_bfd->all_comp_units.size ()); - /* Save partial symtabs in the per_bfd object, for the benefit of subsequent - objfiles using the same BFD. */ - gdb_assert (per_bfd->partial_symtabs == nullptr); - per_bfd->partial_symtabs = objfile->partial_symtabs; - return 1; } @@ -4925,16 +4922,17 @@ dwarf2_base_index_functions::find_pc_sect_compunit_symtab struct dwarf2_per_cu_data *data; struct compunit_symtab *result; - if (!objfile->partial_symtabs->psymtabs_addrmap) + dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); + if (per_objfile->per_bfd->index_addrmap == nullptr) return NULL; CORE_ADDR baseaddr = objfile->text_section_offset (); - data = (struct dwarf2_per_cu_data *) addrmap_find - (objfile->partial_symtabs->psymtabs_addrmap, pc - baseaddr); + data = ((struct dwarf2_per_cu_data *) + addrmap_find (per_objfile->per_bfd->index_addrmap, + pc - baseaddr)); if (!data) return NULL; - dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); if (warn_if_readin && per_objfile->symtab_set_p (data)) warning (_("(Internal error: pc %s in read in CU, but not in symtab.)"), paddress (objfile->arch (), pc)); @@ -5345,11 +5343,6 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile) per_bfd->quick_file_names_table = create_quick_file_names_table (per_objfile->per_bfd->all_comp_units.size ()); - /* Save partial symtabs in the per_bfd object, for the benefit of subsequent - objfiles using the same BFD. */ - gdb_assert (per_bfd->partial_symtabs == nullptr); - per_bfd->partial_symtabs = objfile->partial_symtabs; - return true; } @@ -6057,7 +6050,6 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind) { dwarf_read_debug_printf ("re-using shared debug names table"); *index_kind = dw_index_kind::DEBUG_NAMES; - per_objfile->objfile->partial_symtabs = per_bfd->partial_symtabs; per_objfile->resize_symtabs (); return true; } @@ -6068,7 +6060,6 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind) { dwarf_read_debug_printf ("re-using shared index table"); *index_kind = dw_index_kind::GDB_INDEX; - per_objfile->objfile->partial_symtabs = per_bfd->partial_symtabs; per_objfile->resize_symtabs (); return true; } @@ -14504,7 +14495,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag, /* Get low and high pc attributes from DW_AT_ranges attribute value OFFSET. Return 1 if the attributes are present and valid, otherwise, return 0. - If RANGES_PST is not NULL we should setup `objfile->psymtabs_addrmap'. */ + If RANGES_PST is not NULL we should set up the `psymtabs_addrmap'. */ static int dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return, diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 8932341..6cfbee9 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -257,6 +257,9 @@ public: partial symbols have been read the first time. */ std::shared_ptr partial_symtabs; + /* The address map that is used by the DWARF index code. */ + struct addrmap *index_addrmap = nullptr; + private: /* The total number of per_cu and signatured_type objects that have -- cgit v1.1