aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf-index-write.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-05-10 16:23:51 -0600
committerTom Tromey <tom@tromey.com>2019-01-10 07:08:12 -0700
commitd320c2b5e181828418224521f2acd2ff48e127f4 (patch)
treeafaea8c763b84f9a59a49662366ad5fcf7c917d8 /gdb/dwarf-index-write.c
parent1d94a5a36a614cf7ebe259d7660f4fa725f38ee2 (diff)
downloadgdb-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/dwarf-index-write.c')
-rw-r--r--gdb/dwarf-index-write.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c
index f1118f7..b11927d3 100644
--- a/gdb/dwarf-index-write.c
+++ b/gdb/dwarf-index-write.c
@@ -474,8 +474,8 @@ write_address_map (struct objfile *objfile, data_buf &addr_vec,
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.
@@ -582,13 +582,13 @@ write_one_signatured_type (void **slot, void *d)
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);
@@ -639,12 +639,14 @@ recursively_write_psymbols (struct objfile *objfile,
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);
}
@@ -835,10 +837,12 @@ public:
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);
}
@@ -1195,12 +1199,12 @@ private:
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);
@@ -1554,7 +1558,8 @@ write_psymtabs_to_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
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;