aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.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/dwarf2read.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/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c73
1 files changed, 33 insertions, 40 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index f865fa4..8bde265 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1480,7 +1480,7 @@ static const char *get_section_file_name (const struct dwarf2_section_info *);
static void dwarf2_find_base_address (struct die_info *die,
struct dwarf2_cu *cu);
-static struct partial_symtab *create_partial_symtab
+static dwarf2_psymtab *create_partial_symtab
(struct dwarf2_per_cu_data *per_cu, const char *name);
static void build_type_psymtabs_reader (const struct die_reader_specs *reader,
@@ -1513,10 +1513,7 @@ static void add_partial_subprogram (struct partial_die_info *pdi,
CORE_ADDR *lowpc, CORE_ADDR *highpc,
int need_pc, struct dwarf2_cu *cu);
-static void dwarf2_read_symtab (struct partial_symtab *,
- struct objfile *);
-
-static void psymtab_to_symtab_1 (struct partial_symtab *);
+static void psymtab_to_symtab_1 (dwarf2_psymtab *);
static abbrev_table_up abbrev_table_read_table
(struct dwarf2_per_objfile *dwarf2_per_objfile, struct dwarf2_section_info *,
@@ -1644,7 +1641,7 @@ static line_header_up dwarf_decode_line_header (sect_offset sect_off,
struct dwarf2_cu *cu);
static void dwarf_decode_lines (struct line_header *, const char *,
- struct dwarf2_cu *, struct partial_symtab *,
+ struct dwarf2_cu *, dwarf2_psymtab *,
CORE_ADDR, int decode_mapping);
static void dwarf2_start_subfile (struct dwarf2_cu *, const char *,
@@ -1703,7 +1700,7 @@ static void read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu);
static void read_variable (struct die_info *die, struct dwarf2_cu *cu);
static int dwarf2_ranges_read (unsigned, CORE_ADDR *, CORE_ADDR *,
- struct dwarf2_cu *, struct partial_symtab *);
+ struct dwarf2_cu *, dwarf2_psymtab *);
/* How dwarf2_get_pc_bounds constructed its *LOWPC and *HIGHPC return
values. Keep the items ordered with increasing constraints compliance. */
@@ -1726,7 +1723,7 @@ enum pc_bounds_kind
static enum pc_bounds_kind dwarf2_get_pc_bounds (struct die_info *,
CORE_ADDR *, CORE_ADDR *,
struct dwarf2_cu *,
- struct partial_symtab *);
+ dwarf2_psymtab *);
static void get_scope_pc_bounds (struct die_info *,
CORE_ADDR *, CORE_ADDR *,
@@ -6692,10 +6689,10 @@ read_abbrev_offset (struct dwarf2_per_objfile *dwarf2_per_objfile,
partial symtab as being an include of PST. */
static void
-dwarf2_create_include_psymtab (const char *name, struct partial_symtab *pst,
+dwarf2_create_include_psymtab (const char *name, dwarf2_psymtab *pst,
struct objfile *objfile)
{
- struct partial_symtab *subpst = new partial_symtab (name, objfile);
+ dwarf2_psymtab *subpst = new dwarf2_psymtab (name, objfile);
if (!IS_ABSOLUTE_PATH (subpst->filename))
{
@@ -6707,12 +6704,10 @@ dwarf2_create_include_psymtab (const char *name, struct partial_symtab *pst,
subpst->dependencies[0] = pst;
subpst->number_of_dependencies = 1;
- subpst->read_symtab = pst->read_symtab;
-
/* No private part is necessary for include psymtabs. This property
can be used to differentiate between such include psymtabs and
the regular ones. */
- subpst->read_symtab_private = NULL;
+ subpst->per_cu_data = nullptr;
}
/* Read the Line Number Program data and extract the list of files
@@ -6722,7 +6717,7 @@ dwarf2_create_include_psymtab (const char *name, struct partial_symtab *pst,
static void
dwarf2_build_include_psymtabs (struct dwarf2_cu *cu,
struct die_info *die,
- struct partial_symtab *pst)
+ dwarf2_psymtab *pst)
{
line_header_up lh;
struct attribute *attr;
@@ -7934,7 +7929,7 @@ create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
else
{
unsigned int line_offset = to_underlying (line_offset_struct);
- struct partial_symtab *pst;
+ dwarf2_psymtab *pst;
std::string name;
/* Give the symtab a useful name for debug purposes. */
@@ -8021,19 +8016,18 @@ get_type_unit_group (struct dwarf2_cu *cu, const struct attribute *stmt_list)
The caller must fill in the following details:
dirname, textlow, texthigh. */
-static struct partial_symtab *
+static dwarf2_psymtab *
create_partial_symtab (struct dwarf2_per_cu_data *per_cu, const char *name)
{
struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
- struct partial_symtab *pst;
+ dwarf2_psymtab *pst;
- pst = new partial_symtab (name, objfile, 0);
+ pst = new dwarf2_psymtab (name, objfile, 0);
pst->psymtabs_addrmap_supported = true;
/* This is the glue that links PST into GDB's symbol API. */
- pst->read_symtab_private = per_cu;
- pst->read_symtab = dwarf2_read_symtab;
+ pst->per_cu_data = per_cu;
per_cu->v.psymtab = pst;
return pst;
@@ -8055,7 +8049,7 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
struct dwarf2_per_cu_data *per_cu = cu->per_cu;
CORE_ADDR baseaddr;
CORE_ADDR best_lowpc = 0, best_highpc = 0;
- struct partial_symtab *pst;
+ dwarf2_psymtab *pst;
enum pc_bounds_kind cu_bounds_kind;
const char *filename;
@@ -8224,7 +8218,7 @@ build_type_psymtabs_reader (const struct die_reader_specs *reader,
struct attribute *attr;
struct partial_die_info *first_die;
CORE_ADDR lowpc, highpc;
- struct partial_symtab *pst;
+ dwarf2_psymtab *pst;
gdb_assert (per_cu->is_debug_types);
sig_type = (struct signatured_type *) per_cu;
@@ -8397,7 +8391,7 @@ build_type_psymtab_dependencies (void **slot, void *info)
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct type_unit_group *tu_group = (struct type_unit_group *) *slot;
struct dwarf2_per_cu_data *per_cu = &tu_group->per_cu;
- struct partial_symtab *pst = per_cu->v.psymtab;
+ dwarf2_psymtab *pst = per_cu->v.psymtab;
int len = (tu_group->tus == nullptr) ? 0 : tu_group->tus->size ();
int i;
@@ -8514,7 +8508,7 @@ set_partial_user (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units)
{
- struct partial_symtab *pst = per_cu->v.psymtab;
+ dwarf2_psymtab *pst = per_cu->v.psymtab;
if (pst == NULL)
continue;
@@ -9494,24 +9488,23 @@ locate_pdi_sibling (const struct die_reader_specs *reader,
/* Expand this partial symbol table into a full symbol table. SELF is
not NULL. */
-static void
-dwarf2_read_symtab (struct partial_symtab *self,
- struct objfile *objfile)
+void
+dwarf2_psymtab::read_symtab (struct objfile *objfile)
{
struct dwarf2_per_objfile *dwarf2_per_objfile
= get_dwarf2_per_objfile (objfile);
- if (self->readin)
+ if (readin)
{
warning (_("bug: psymtab for %s is already read in."),
- self->filename);
+ filename);
}
else
{
if (info_verbose)
{
printf_filtered (_("Reading in symbols for %s..."),
- self->filename);
+ filename);
gdb_flush (gdb_stdout);
}
@@ -9530,7 +9523,7 @@ dwarf2_read_symtab (struct partial_symtab *self,
dwarf2_per_objfile->reading_partial_symbols = 0;
- psymtab_to_symtab_1 (self);
+ psymtab_to_symtab_1 (this);
/* Finish up the debug error message. */
if (info_verbose)
@@ -9687,7 +9680,7 @@ process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile)
/* Read in full symbols for PST, and anything it depends on. */
static void
-psymtab_to_symtab_1 (struct partial_symtab *pst)
+psymtab_to_symtab_1 (dwarf2_psymtab *pst)
{
struct dwarf2_per_cu_data *per_cu;
int i;
@@ -9711,10 +9704,10 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
wrap_here (""); /* Flush output. */
gdb_flush (gdb_stdout);
}
- psymtab_to_symtab_1 (pst->dependencies[i]);
+ psymtab_to_symtab_1 ((dwarf2_psymtab *) pst->dependencies[i]);
}
- per_cu = (struct dwarf2_per_cu_data *) pst->read_symtab_private;
+ per_cu = pst->per_cu_data;
if (per_cu == NULL)
{
@@ -10477,7 +10470,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
per_cu->v.quick->compunit_symtab = cust;
else
{
- struct partial_symtab *pst = per_cu->v.psymtab;
+ dwarf2_psymtab *pst = per_cu->v.psymtab;
pst->compunit_symtab = cust;
pst->readin = true;
}
@@ -10557,7 +10550,7 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
per_cu->v.quick->compunit_symtab = cust;
else
{
- struct partial_symtab *pst = per_cu->v.psymtab;
+ dwarf2_psymtab *pst = per_cu->v.psymtab;
pst->compunit_symtab = cust;
pst->readin = true;
}
@@ -14596,7 +14589,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu,
static int
dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
CORE_ADDR *high_return, struct dwarf2_cu *cu,
- struct partial_symtab *ranges_pst)
+ dwarf2_psymtab *ranges_pst)
{
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
@@ -14664,7 +14657,7 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
static enum pc_bounds_kind
dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
CORE_ADDR *highpc, struct dwarf2_cu *cu,
- struct partial_symtab *pst)
+ dwarf2_psymtab *pst)
{
struct dwarf2_per_objfile *dwarf2_per_objfile
= cu->per_cu->dwarf2_per_objfile;
@@ -20944,7 +20937,7 @@ dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu)
static const char *
psymtab_include_file_name (const struct line_header *lh, const file_entry &fe,
- const struct partial_symtab *pst,
+ const dwarf2_psymtab *pst,
const char *comp_dir,
gdb::unique_xmalloc_ptr<char> *name_holder)
{
@@ -21645,7 +21638,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
static void
dwarf_decode_lines (struct line_header *lh, const char *comp_dir,
- struct dwarf2_cu *cu, struct partial_symtab *pst,
+ struct dwarf2_cu *cu, dwarf2_psymtab *pst,
CORE_ADDR lowpc, int decode_mapping)
{
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;