aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf-index-write.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-10-22 17:28:37 -0600
committerTom Tromey <tom@tromey.com>2020-01-26 16:40:21 -0700
commit891813beaab0029c88c9eeec9c1847d68a4d6050 (patch)
treeb8f7d6ed3f2dc760bab54a5f641c044ca104cc98 /gdb/dwarf-index-write.c
parentc3693a1d9466bc9d3abe004e66f1b56fed22ba61 (diff)
downloadgdb-891813beaab0029c88c9eeec9c1847d68a4d6050.zip
gdb-891813beaab0029c88c9eeec9c1847d68a4d6050.tar.gz
gdb-891813beaab0029c88c9eeec9c1847d68a4d6050.tar.bz2
Introduce partial_symtab::read_symtab method
This introduces a new partial_symtab::read_symtab method, and updates the symbol readers to subclass partial_symtab and implement this method. The old read_symtab and read_symtab_private members are removed. In practice, only DWARF and CTF are truly updated to take advantage of the new setup. The other symbol readers are less actively maintained, and so this patch also introduces a "legacy_psymtab", which essentially works the same way as the old partial_symtab. (Note that, without more knowledge of the interaction between these symbol readers, fixing this to remove the new (small) overhead is not trivial, because these readers copy the read_symtab pointer between partial symtabs.) gdb/ChangeLog 2020-01-26 Tom Tromey <tom@tromey.com> * xcoffread.c (this_symtab_psymtab, read_xcoff_symtab) (xcoff_psymtab_to_symtab_1, xcoff_read_symtab) (xcoff_start_psymtab, xcoff_end_psymtab, scan_xcoff_symtab): Use legacy_symtab. * stabsread.h (dbx_end_psymtab): Use legacy_symtab. * psymtab.c (psymtab_to_symtab): Call method. (dump_psymtab): Update. * psympriv.h (struct partial_symtab): Add virtual destructor. <read_symtab>: New method. (struct legacy_symtab): New. * mdebugread.c (mdebug_read_symtab): Use legacy_psymtab. (struct pst_map) <pst>: Now a legacy_psymtab. (parse_procedure, parse_partial_symbols, psymtab_to_symtab_1) (new_psymtab): Use legacy_psymtab. * dwarf2read.h (struct dwarf2_psymtab): New. (struct dwarf2_per_cu_data) <psymtab>: Use it. * dwarf2read.c (dwarf2_create_include_psymtab) (dwarf2_build_include_psymtabs, create_type_unit_group) (create_partial_symtab, process_psymtab_comp_unit_reader) (build_type_psymtabs_reader, build_type_psymtab_dependencies) (set_partial_user): Use dwarf2_psymtab. (dwarf2_psymtab::read_symtab): Rename from dwarf2_read_symtab. (psymtab_to_symtab_1, process_full_comp_unit) (process_full_type_unit, dwarf2_ranges_read) (dwarf2_get_pc_bounds, psymtab_include_file_name) (dwarf_decode_lines): Use dwarf2_psymtab. * dwarf-index-write.c (psym_index_map): Use dwarf2_psymtab. (add_address_entry_worker, write_one_signatured_type) (recursively_count_psymbols, recursively_write_psymbols) (write_one_signatured_type, psyms_seen_size, write_gdbindex) (write_debug_names): Likewise. * dbxread.c (struct header_file_location): Take a legacy_psymtab. <pst>: Now a legacy_psymtab. (find_corresponding_bincl_psymtab): Return a legacy_psymtab. (read_dbx_symtab, start_psymtab, dbx_end_psymtab) (dbx_psymtab_to_symtab_1, read_ofile_symtab): Use legacy_psymtab. * ctfread.c (struct ctf_psymtab): New. (ctf_start_symtab, ctf_end_symtab, psymtab_to_symtab): Take a ctf_psymtab. (ctf_psymtab::read_symtab): Rename from ctf_read_symtab. (create_partial_symtab): Return a ctf_psymtab. (scan_partial_symbols): Update. Change-Id: Ia57a828786867d6ad03200af8f996f48ed15285e
Diffstat (limited to 'gdb/dwarf-index-write.c')
-rw-r--r--gdb/dwarf-index-write.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c
index fd22262..9aaf6af 100644
--- a/gdb/dwarf-index-write.c
+++ b/gdb/dwarf-index-write.c
@@ -399,7 +399,7 @@ write_hash_table (mapped_symtab *symtab, data_buf &output, data_buf &cpool)
}
}
-typedef std::unordered_map<partial_symtab *, unsigned int> psym_index_map;
+typedef std::unordered_map<dwarf2_psymtab *, unsigned int> psym_index_map;
/* Helper struct for building the address table. */
struct addrmap_index_data
@@ -439,7 +439,7 @@ static int
add_address_entry_worker (void *datap, CORE_ADDR start_addr, void *obj)
{
struct addrmap_index_data *data = (struct addrmap_index_data *) datap;
- struct partial_symtab *pst = (struct partial_symtab *) obj;
+ dwarf2_psymtab *pst = (dwarf2_psymtab *) obj;
if (data->previous_valid)
add_address_entry (data->objfile, data->addr_vec,
@@ -582,7 +582,7 @@ write_one_signatured_type (void **slot, void *d)
struct signatured_type_index_data *info
= (struct signatured_type_index_data *) d;
struct signatured_type *entry = (struct signatured_type *) *slot;
- struct partial_symtab *psymtab = entry->per_cu.v.psymtab;
+ dwarf2_psymtab *psymtab = entry->per_cu.v.psymtab;
write_psymbols (info->symtab,
info->psyms_seen,
@@ -612,12 +612,12 @@ write_one_signatured_type (void **slot, void *d)
if they appeared in this psymtab. */
static void
-recursively_count_psymbols (struct partial_symtab *psymtab,
+recursively_count_psymbols (dwarf2_psymtab *psymtab,
size_t &psyms_seen)
{
for (int i = 0; i < psymtab->number_of_dependencies; ++i)
if (psymtab->dependencies[i]->user != NULL)
- recursively_count_psymbols (psymtab->dependencies[i],
+ recursively_count_psymbols ((dwarf2_psymtab *) psymtab->dependencies[i],
psyms_seen);
psyms_seen += psymtab->n_global_syms;
@@ -629,7 +629,7 @@ recursively_count_psymbols (struct partial_symtab *psymtab,
static void
recursively_write_psymbols (struct objfile *objfile,
- struct partial_symtab *psymtab,
+ dwarf2_psymtab *psymtab,
struct mapped_symtab *symtab,
std::unordered_set<partial_symbol *> &psyms_seen,
offset_type cu_index)
@@ -638,7 +638,8 @@ recursively_write_psymbols (struct objfile *objfile,
for (i = 0; i < psymtab->number_of_dependencies; ++i)
if (psymtab->dependencies[i]->user != NULL)
- recursively_write_psymbols (objfile, psymtab->dependencies[i],
+ recursively_write_psymbols (objfile,
+ (dwarf2_psymtab *) psymtab->dependencies[i],
symtab, psyms_seen, cu_index);
write_psymbols (symtab,
@@ -868,14 +869,14 @@ public:
as if they appeared in this psymtab. */
void recursively_write_psymbols
(struct objfile *objfile,
- struct partial_symtab *psymtab,
+ dwarf2_psymtab *psymtab,
std::unordered_set<partial_symbol *> &psyms_seen,
int cu_index)
{
for (int i = 0; i < psymtab->number_of_dependencies; ++i)
if (psymtab->dependencies[i]->user != NULL)
- recursively_write_psymbols (objfile, psymtab->dependencies[i],
- psyms_seen, cu_index);
+ recursively_write_psymbols
+ (objfile, (dwarf2_psymtab *) psymtab->dependencies[i], psyms_seen, cu_index);
write_psymbols (psyms_seen,
(objfile->partial_symtabs->global_psymbols.data ()
@@ -1234,7 +1235,7 @@ private:
write_one_signatured_type (struct signatured_type *entry,
struct signatured_type_index_data *info)
{
- struct partial_symtab *psymtab = entry->per_cu.v.psymtab;
+ dwarf2_psymtab *psymtab = entry->per_cu.v.psymtab;
write_psymbols (info->psyms_seen,
(info->objfile->partial_symtabs->global_psymbols.data ()
@@ -1320,7 +1321,7 @@ psyms_seen_size (struct dwarf2_per_objfile *dwarf2_per_objfile)
size_t psyms_count = 0;
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units)
{
- struct partial_symtab *psymtab = per_cu->v.psymtab;
+ dwarf2_psymtab *psymtab = per_cu->v.psymtab;
if (psymtab != NULL && psymtab->user == NULL)
recursively_count_psymbols (psymtab, psyms_count);
@@ -1423,7 +1424,7 @@ write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file,
{
struct dwarf2_per_cu_data *per_cu
= dwarf2_per_objfile->all_comp_units[i];
- struct partial_symtab *psymtab = per_cu->v.psymtab;
+ dwarf2_psymtab *psymtab = per_cu->v.psymtab;
/* CU of a shared file from 'dwz -m' may be unused by this main file.
It may be referenced from a local scope but in such case it does not
@@ -1508,7 +1509,7 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
for (int i = 0; i < dwarf2_per_objfile->all_comp_units.size (); ++i)
{
const dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->all_comp_units[i];
- partial_symtab *psymtab = per_cu->v.psymtab;
+ dwarf2_psymtab *psymtab = per_cu->v.psymtab;
/* CU of a shared file from 'dwz -m' may be unused by this main
file. It may be referenced from a local scope but in such