aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--gdb/ChangeLog45
-rw-r--r--gdb/ctfread.c64
-rw-r--r--gdb/dbxread.c74
-rw-r--r--gdb/dwarf-index-write.c29
-rw-r--r--gdb/dwarf2read.c73
-rw-r--r--gdb/dwarf2read.h24
-rw-r--r--gdb/mdebugread.c54
-rw-r--r--gdb/psympriv.h34
-rw-r--r--gdb/psymtab.c4
-rw-r--r--gdb/stabsread.h7
-rw-r--r--gdb/xcoffread.c43
11 files changed, 277 insertions, 174 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6353a00..8fcb24e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,50 @@
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.
+
+2020-01-26 Tom Tromey <tom@tromey.com>
+
* xcoffread.c (xcoff_start_psymtab): Use new.
* psymtab.c (partial_symtab::partial_symtab): New constructor,
renamed from start_psymtab_common.
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index e3931fb..120c7b4 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -115,6 +115,19 @@ struct ctf_context
struct buildsym_compunit *builder;
};
+/* A partial symtab, specialized for this module. */
+struct ctf_psymtab : public partial_symtab
+{
+ ctf_psymtab (const char *filename, struct objfile *objfile, CORE_ADDR addr)
+ : partial_symtab (filename, objfile, addr)
+ {
+ }
+
+ void read_symtab (struct objfile *) override;
+
+ struct ctf_context *context;
+};
+
/* The routines that read and process fields/members of a C struct, union,
or enumeration, pass lists of data member fields in an instance of a
ctf_field_info structure. It is derived from dwarf2read.c. */
@@ -147,7 +160,7 @@ struct ctf_field_info
/* Local function prototypes */
-static void psymtab_to_symtab (struct partial_symtab *);
+static void psymtab_to_symtab (ctf_psymtab *);
static int ctf_add_type_cb (ctf_id_t tid, void *arg);
@@ -1171,12 +1184,12 @@ get_objfile_text_range (struct objfile *of, int *tsize)
/* Start a symtab for OBJFILE in CTF format. */
static void
-ctf_start_symtab (struct partial_symtab *pst,
+ctf_start_symtab (ctf_psymtab *pst,
struct objfile *of, CORE_ADDR text_offset)
{
struct ctf_context *ccp;
- ccp = (struct ctf_context *) pst->read_symtab_private;
+ ccp = pst->context;
ccp->builder = new buildsym_compunit
(of, of->original_name, NULL,
language_c, text_offset);
@@ -1188,12 +1201,12 @@ ctf_start_symtab (struct partial_symtab *pst,
the .text section number. */
static struct compunit_symtab *
-ctf_end_symtab (struct partial_symtab *pst,
+ctf_end_symtab (ctf_psymtab *pst,
CORE_ADDR end_addr, int section)
{
struct ctf_context *ccp;
- ccp = (struct ctf_context *) pst->read_symtab_private;
+ ccp = pst->context;
struct compunit_symtab *result
= ccp->builder->end_symtab (end_addr, section);
delete ccp->builder;
@@ -1204,14 +1217,14 @@ ctf_end_symtab (struct partial_symtab *pst,
/* Read in full symbols for PST, and anything it depends on. */
static void
-psymtab_to_symtab (struct partial_symtab *pst)
+psymtab_to_symtab (ctf_psymtab *pst)
{
struct symbol *sym;
struct ctf_context *ccp;
gdb_assert (!pst->readin);
- ccp = (struct ctf_context *) pst->read_symtab_private;
+ ccp = pst->context;
/* Iterate over entries in data types section. */
if (ctf_type_iter (ccp->fp, ctf_add_type_cb, ccp) == CTF_ERR)
@@ -1247,31 +1260,31 @@ psymtab_to_symtab (struct partial_symtab *pst)
/* Expand partial symbol table PST into a full symbol table.
PST is not NULL. */
-static void
-ctf_read_symtab (struct partial_symtab *pst, struct objfile *objfile)
+void
+ctf_psymtab::read_symtab (struct objfile *objfile)
{
- if (pst->readin)
- warning (_("bug: psymtab for %s is already read in."), pst->filename);
+ if (readin)
+ warning (_("bug: psymtab for %s is already read in."), filename);
else
{
if (info_verbose)
{
- printf_filtered (_("Reading in CTF data for %s..."), pst->filename);
+ printf_filtered (_("Reading in CTF data for %s..."), filename);
gdb_flush (gdb_stdout);
}
/* Start a symtab. */
- CORE_ADDR text_offset; /* Start of text segment. */
+ CORE_ADDR offset; /* Start of text segment. */
int tsize;
- text_offset = get_objfile_text_range (objfile, &tsize);
- ctf_start_symtab (pst, objfile, text_offset);
- psymtab_to_symtab (pst);
+ offset = get_objfile_text_range (objfile, &tsize);
+ ctf_start_symtab (this, objfile, offset);
+ psymtab_to_symtab (this);
- pst->set_text_low (text_offset);
- pst->set_text_high (text_offset + tsize);
- pst->compunit_symtab = ctf_end_symtab (pst, text_offset + tsize,
- SECT_OFF_TEXT (objfile));
+ set_text_low (offset);
+ set_text_high (offset + tsize);
+ compunit_symtab = ctf_end_symtab (this, offset + tsize,
+ SECT_OFF_TEXT (objfile));
/* Finish up the debug error message. */
if (info_verbose)
@@ -1291,21 +1304,20 @@ ctf_read_symtab (struct partial_symtab *pst, struct objfile *objfile)
partial_symtab remains around. They are allocated on an obstack,
objfile_obstack. */
-static struct partial_symtab *
+static ctf_psymtab *
create_partial_symtab (const char *name,
ctf_file_t *cfp,
struct objfile *objfile)
{
- struct partial_symtab *pst;
+ ctf_psymtab *pst;
struct ctf_context *ccx;
- pst = new partial_symtab (name, objfile, 0);
+ pst = new ctf_psymtab (name, objfile, 0);
ccx = XOBNEW (&objfile->objfile_obstack, struct ctf_context);
ccx->fp = cfp;
ccx->of = objfile;
- pst->read_symtab_private = (void *) ccx;
- pst->read_symtab = ctf_read_symtab;
+ pst->context = ccx;
return pst;
}
@@ -1393,7 +1405,7 @@ scan_partial_symbols (ctf_file_t *cfp, struct objfile *of)
struct ctf_context ccx;
bfd *abfd = of->obfd;
const char *name = bfd_get_filename (abfd);
- struct partial_symtab *pst = create_partial_symtab (name, cfp, of);
+ ctf_psymtab *pst = create_partial_symtab (name, cfp, of);
ccx.fp = cfp;
ccx.of = of;
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 4e388fae..64387c6 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -245,7 +245,7 @@ find_text_range (bfd * sym_bfd, struct objfile *objfile)
struct header_file_location
{
header_file_location (const char *name_, int instance_,
- struct partial_symtab *pst_)
+ legacy_psymtab *pst_)
: name (name_),
instance (instance_),
pst (pst_)
@@ -254,7 +254,7 @@ struct header_file_location
const char *name; /* Name of header file */
int instance; /* See above */
- struct partial_symtab *pst; /* Partial symtab that has the
+ legacy_psymtab *pst; /* Partial symtab that has the
BINCL/EINCL defs for this file. */
};
@@ -263,16 +263,16 @@ static std::vector<struct header_file_location> *bincl_list;
/* Local function prototypes. */
-static void read_ofile_symtab (struct objfile *, struct partial_symtab *);
+static void read_ofile_symtab (struct objfile *, legacy_psymtab *);
-static void dbx_read_symtab (struct partial_symtab *self,
+static void dbx_read_symtab (legacy_psymtab *self,
struct objfile *objfile);
-static void dbx_psymtab_to_symtab_1 (struct objfile *, struct partial_symtab *);
+static void dbx_psymtab_to_symtab_1 (struct objfile *, legacy_psymtab *);
static void read_dbx_symtab (minimal_symbol_reader &, struct objfile *);
-static struct partial_symtab *find_corresponding_bincl_psymtab (const char *,
+static legacy_psymtab *find_corresponding_bincl_psymtab (const char *,
int);
static const char *dbx_next_symbol_text (struct objfile *);
@@ -297,7 +297,7 @@ static void add_old_header_file (const char *, int);
static void add_this_object_header_file (int);
-static struct partial_symtab *start_psymtab (struct objfile *, const char *,
+static legacy_psymtab *start_psymtab (struct objfile *, const char *,
CORE_ADDR, int);
/* Free up old header file tables. */
@@ -857,7 +857,7 @@ dbx_next_symbol_text (struct objfile *objfile)
bincl in the list. Return the partial symtab associated
with that header_file_location. */
-static struct partial_symtab *
+static legacy_psymtab *
find_corresponding_bincl_psymtab (const char *name, int instance)
{
for (const header_file_location &bincl : *bincl_list)
@@ -866,7 +866,7 @@ find_corresponding_bincl_psymtab (const char *name, int instance)
return bincl.pst;
repeated_header_complaint (name, symnum);
- return (struct partial_symtab *) 0;
+ return (legacy_psymtab *) 0;
}
/* Set namestring based on nlist. If the string table index is invalid,
@@ -968,7 +968,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
int data_sect_index;
/* Current partial symtab. */
- struct partial_symtab *pst;
+ legacy_psymtab *pst;
/* List of current psymtab's include files. */
const char **psymtab_include_list;
@@ -976,7 +976,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
int includes_used;
/* Index within current psymtab dependency list. */
- struct partial_symtab **dependency_list;
+ legacy_psymtab **dependency_list;
int dependencies_used, dependencies_allocated;
text_addr = DBX_TEXT_ADDR (objfile);
@@ -989,7 +989,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
stringtab_global = DBX_STRINGTAB (objfile);
- pst = (struct partial_symtab *) 0;
+ pst = (legacy_psymtab *) 0;
includes_allocated = 30;
includes_used = 0;
@@ -999,8 +999,8 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
dependencies_allocated = 30;
dependencies_used = 0;
dependency_list =
- (struct partial_symtab **) alloca (dependencies_allocated *
- sizeof (struct partial_symtab *));
+ (legacy_psymtab **) alloca (dependencies_allocated *
+ sizeof (legacy_psymtab *));
/* Init bincl list */
std::vector<struct header_file_location> bincl_storage;
@@ -1136,7 +1136,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
? nlist.n_value : pst->raw_text_high (),
dependency_list, dependencies_used,
textlow_not_set);
- pst = (struct partial_symtab *) 0;
+ pst = (legacy_psymtab *) 0;
includes_used = 0;
dependencies_used = 0;
has_line_numbers = 0;
@@ -1251,7 +1251,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
? valu : pst->raw_text_high ()),
dependency_list, dependencies_used,
prev_textlow_not_set);
- pst = (struct partial_symtab *) 0;
+ pst = (legacy_psymtab *) 0;
includes_used = 0;
dependencies_used = 0;
has_line_numbers = 0;
@@ -1762,7 +1762,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
/* Find the corresponding bincl and mark that psymtab on the
psymtab dependency list. */
{
- struct partial_symtab *needed_pst =
+ legacy_psymtab *needed_pst =
find_corresponding_bincl_psymtab (namestring, nlist.n_value);
/* If this include file was defined earlier in this file,
@@ -1789,15 +1789,15 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
dependency_list[dependencies_used++] = needed_pst;
if (dependencies_used >= dependencies_allocated)
{
- struct partial_symtab **orig = dependency_list;
+ legacy_psymtab **orig = dependency_list;
dependency_list =
- (struct partial_symtab **)
+ (legacy_psymtab **)
alloca ((dependencies_allocated *= 2)
- * sizeof (struct partial_symtab *));
+ * sizeof (legacy_psymtab *));
memcpy (dependency_list, orig,
(dependencies_used
- * sizeof (struct partial_symtab *)));
+ * sizeof (legacy_psymtab *)));
#ifdef DEBUG_INFO
fprintf_unfiltered (gdb_stderr,
"Had to reallocate "
@@ -1823,7 +1823,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
symnum * symbol_size,
(CORE_ADDR) 0, dependency_list,
dependencies_used, textlow_not_set);
- pst = (struct partial_symtab *) 0;
+ pst = (legacy_psymtab *) 0;
includes_used = 0;
dependencies_used = 0;
has_line_numbers = 0;
@@ -1899,17 +1899,16 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
is the address relative to which its symbols are (incremental) or 0
(normal). */
-static struct partial_symtab *
+static legacy_psymtab *
start_psymtab (struct objfile *objfile, const char *filename, CORE_ADDR textlow,
int ldsymoff)
{
- struct partial_symtab *result = new partial_symtab (filename, objfile,
- textlow);
+ legacy_psymtab *result = new legacy_psymtab (filename, objfile, textlow);
result->read_symtab_private =
XOBNEW (&objfile->objfile_obstack, struct symloc);
LDSYMOFF (result) = ldsymoff;
- result->read_symtab = dbx_read_symtab;
+ result->legacy_read_symtab = dbx_read_symtab;
SYMBOL_SIZE (result) = symbol_size;
SYMBOL_OFFSET (result) = symbol_table_offset;
STRING_OFFSET (result) = string_table_offset;
@@ -1927,11 +1926,11 @@ start_psymtab (struct objfile *objfile, const char *filename, CORE_ADDR textlow,
FIXME: List variables and peculiarities of same. */
-struct partial_symtab *
-dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
+legacy_psymtab *
+dbx_end_psymtab (struct objfile *objfile, legacy_psymtab *pst,
const char **include_list, int num_includes,
int capping_symbol_offset, CORE_ADDR capping_text,
- struct partial_symtab **dependency_list,
+ legacy_psymtab **dependency_list,
int number_dependencies,
int textlow_not_set)
{
@@ -2017,15 +2016,15 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
pst->dependencies
= objfile->partial_symtabs->allocate_dependencies (number_dependencies);
memcpy (pst->dependencies, dependency_list,
- number_dependencies * sizeof (struct partial_symtab *));
+ number_dependencies * sizeof (legacy_psymtab *));
}
else
pst->dependencies = 0;
for (i = 0; i < num_includes; i++)
{
- struct partial_symtab *subpst =
- new partial_symtab (include_list[i], objfile);
+ legacy_psymtab *subpst =
+ new legacy_psymtab (include_list[i], objfile);
subpst->read_symtab_private =
XOBNEW (&objfile->objfile_obstack, struct symloc);
@@ -2039,7 +2038,7 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
subpst->dependencies[0] = pst;
subpst->number_of_dependencies = 1;
- subpst->read_symtab = pst->read_symtab;
+ subpst->legacy_read_symtab = pst->legacy_read_symtab;
}
if (num_includes == 0
@@ -2065,7 +2064,7 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
}
static void
-dbx_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
+dbx_psymtab_to_symtab_1 (struct objfile *objfile, legacy_psymtab *pst)
{
int i;
@@ -2092,7 +2091,8 @@ dbx_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
wrap_here (""); /* Flush output. */
gdb_flush (gdb_stdout);
}
- dbx_psymtab_to_symtab_1 (objfile, pst->dependencies[i]);
+ dbx_psymtab_to_symtab_1 (objfile,
+ (legacy_psymtab *) pst->dependencies[i]);
}
if (LDSYMLEN (pst)) /* Otherwise it's a dummy. */
@@ -2115,7 +2115,7 @@ dbx_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
Be verbose about it if the user wants that. SELF is not NULL. */
static void
-dbx_read_symtab (struct partial_symtab *self, struct objfile *objfile)
+dbx_read_symtab (legacy_psymtab *self, struct objfile *objfile)
{
if (self->readin)
{
@@ -2165,7 +2165,7 @@ dbx_read_symtab (struct partial_symtab *self, struct objfile *objfile)
/* Read in a defined section of a specific object file's symbols. */
static void
-read_ofile_symtab (struct objfile *objfile, struct partial_symtab *pst)
+read_ofile_symtab (struct objfile *objfile, legacy_psymtab *pst)
{
const char *namestring;
struct external_nlist *bufp;
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
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;
diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h
index bc8087b..06bd908 100644
--- a/gdb/dwarf2read.h
+++ b/gdb/dwarf2read.h
@@ -25,6 +25,7 @@
#include "filename-seen-cache.h"
#include "gdb_obstack.h"
#include "gdbsupport/hash_enum.h"
+#include "psympriv.h"
/* Hold 'maintenance (set|show) dwarf' commands. */
extern struct cmd_list_element *set_dwarf_cmdlist;
@@ -269,9 +270,28 @@ public:
dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile);
+/* A partial symtab specialized for DWARF. */
+struct dwarf2_psymtab : public partial_symtab
+{
+ dwarf2_psymtab (const char *filename, struct objfile *objfile)
+ : partial_symtab (filename, objfile)
+ {
+ }
+
+ dwarf2_psymtab (const char *filename, struct objfile *objfile,
+ CORE_ADDR addr)
+ : partial_symtab (filename, objfile, addr)
+ {
+ }
+
+ void read_symtab (struct objfile *) override;
+
+ struct dwarf2_per_cu_data *per_cu_data;
+};
+
/* Persistent data held for a compilation unit, even when not
processing it. We put a pointer to this structure in the
- read_symtab_private field of the psymtab. */
+ psymtab. */
struct dwarf2_per_cu_data
{
@@ -339,7 +359,7 @@ struct dwarf2_per_cu_data
{
/* The partial symbol table associated with this compilation unit,
or NULL for unread partial units. */
- struct partial_symtab *psymtab;
+ dwarf2_psymtab *psymtab;
/* Data needed by the "quick" functions. */
struct dwarf2_per_cu_quick_data *quick;
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index dafc7f4..621b314 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -251,10 +251,10 @@ static struct symbol *mylookup_symbol (const char *, const struct block *,
static void sort_blocks (struct symtab *);
-static struct partial_symtab *new_psymtab (const char *, struct objfile *);
+static legacy_psymtab *new_psymtab (const char *, struct objfile *);
static void psymtab_to_symtab_1 (struct objfile *objfile,
- struct partial_symtab *, const char *);
+ legacy_psymtab *, const char *);
static void add_block (struct block *, struct symtab *);
@@ -275,7 +275,7 @@ static const char *mdebug_next_symbol_text (struct objfile *);
and reorders the symtab list at the end. SELF is not NULL. */
static void
-mdebug_read_symtab (struct partial_symtab *self, struct objfile *objfile)
+mdebug_read_symtab (legacy_psymtab *self, struct objfile *objfile)
{
if (info_verbose)
{
@@ -389,7 +389,7 @@ mdebug_build_psymtabs (minimal_symbol_reader &reader,
struct pst_map
{
- struct partial_symtab *pst; /* the psymtab proper */
+ legacy_psymtab *pst; /* the psymtab proper */
long n_globals; /* exported globals (external symbols) */
long globals_offset; /* cumulative */
};
@@ -1910,7 +1910,7 @@ upgrade_type (int fd, struct type **tpp, int tq, union aux_ext *ax, int bigend,
static void
parse_procedure (PDR *pr, struct compunit_symtab *search_symtab,
- struct partial_symtab *pst)
+ legacy_psymtab *pst)
{
struct symbol *s, *i;
const struct block *b;
@@ -2310,7 +2310,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
EXTR *ext_in;
EXTR *ext_in_end;
SYMR sh;
- struct partial_symtab *pst;
+ legacy_psymtab *pst;
int textlow_not_set = 1;
/* List of current psymtab's include files. */
@@ -2320,7 +2320,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
EXTR *extern_tab;
struct pst_map *fdr_to_pst;
/* Index within current psymtab dependency list. */
- struct partial_symtab **dependency_list;
+ legacy_psymtab **dependency_list;
int dependencies_used, dependencies_allocated;
char *name;
enum language prev_language;
@@ -2349,8 +2349,8 @@ parse_partial_symbols (minimal_symbol_reader &reader,
dependencies_allocated = 30;
dependencies_used = 0;
dependency_list =
- (struct partial_symtab **) alloca (dependencies_allocated *
- sizeof (struct partial_symtab *));
+ (legacy_psymtab **) alloca (dependencies_allocated *
+ sizeof (legacy_psymtab *));
set_last_source_file (NULL);
@@ -2373,7 +2373,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
fdr_to_pst = fdr_to_pst_holder.data ();
fdr_to_pst++;
{
- struct partial_symtab *new_pst = new_psymtab ("", objfile);
+ legacy_psymtab *new_pst = new_psymtab ("", objfile);
fdr_to_pst[-1].pst = new_pst;
FDR_IDX (new_pst) = -1;
@@ -2591,7 +2591,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
/* Pass 3 over files, over local syms: fill in static symbols. */
for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++)
{
- struct partial_symtab *save_pst;
+ legacy_psymtab *save_pst;
EXTR *ext_ptr;
CORE_ADDR textlow;
@@ -2609,7 +2609,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
textlow = fh->adr;
else
textlow = 0;
- pst = new partial_symtab (fdr_name (fh), objfile, textlow);
+ pst = new legacy_psymtab (fdr_name (fh), objfile, textlow);
pst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, symloc);
memset (pst->read_symtab_private, 0, sizeof (struct symloc));
@@ -2621,7 +2621,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
PENDING_LIST (pst) = pending_list;
/* The way to turn this into a symtab is to call... */
- pst->read_symtab = mdebug_read_symtab;
+ pst->legacy_read_symtab = mdebug_read_symtab;
/* Set up language for the pst.
The language from the FDR is used if it is unambigious (e.g. cfront
@@ -2895,7 +2895,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
{ /* Here if prev stab wasn't N_SO. */
if (pst)
{
- pst = (struct partial_symtab *) 0;
+ pst = (legacy_psymtab *) 0;
includes_used = 0;
dependencies_used = 0;
}
@@ -3285,7 +3285,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
if (pst
&& gdbarch_sofun_address_maybe_missing (gdbarch))
{
- pst = (struct partial_symtab *) 0;
+ pst = (legacy_psymtab *) 0;
includes_used = 0;
dependencies_used = 0;
}
@@ -3740,12 +3740,12 @@ parse_partial_symbols (minimal_symbol_reader &reader,
/* Remove the dummy psymtab created for -O3 images above, if it is
still empty, to enable the detection of stripped executables. */
- pst = objfile->partial_symtabs->psymtabs;
- if (pst->next == NULL
- && pst->number_of_dependencies == 0
- && pst->n_global_syms == 0
- && pst->n_static_syms == 0)
- objfile->partial_symtabs->discard_psymtab (pst);
+ partial_symtab *pst_del = objfile->partial_symtabs->psymtabs;
+ if (pst_del->next == NULL
+ && pst_del->number_of_dependencies == 0
+ && pst_del->n_global_syms == 0
+ && pst_del->n_static_syms == 0)
+ objfile->partial_symtabs->discard_psymtab (pst_del);
}
/* If the current psymbol has an enumerated type, we need to add
@@ -3844,7 +3844,7 @@ mdebug_next_symbol_text (struct objfile *objfile)
static void
psymtab_to_symtab_1 (struct objfile *objfile,
- struct partial_symtab *pst, const char *filename)
+ legacy_psymtab *pst, const char *filename)
{
bfd_size_type external_sym_size;
bfd_size_type external_pdr_size;
@@ -3882,7 +3882,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
gdb_flush (gdb_stdout);
}
/* We only pass the filename for debug purposes. */
- psymtab_to_symtab_1 (objfile, pst->dependencies[i],
+ psymtab_to_symtab_1 (objfile, (legacy_psymtab *) pst->dependencies[i],
pst->dependencies[i]->filename);
}
@@ -4655,12 +4655,12 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile)
/* Allocate a new partial_symtab NAME. */
-static struct partial_symtab *
+static legacy_psymtab *
new_psymtab (const char *name, struct objfile *objfile)
{
- struct partial_symtab *psymtab;
+ legacy_psymtab *psymtab;
- psymtab = new partial_symtab (name, objfile);
+ psymtab = new legacy_psymtab (name, objfile);
/* Keep a backpointer to the file's symbols. */
@@ -4672,7 +4672,7 @@ new_psymtab (const char *name, struct objfile *objfile)
PENDING_LIST (psymtab) = pending_list;
/* The way to turn this into a symtab is to call... */
- psymtab->read_symtab = mdebug_read_symtab;
+ psymtab->legacy_read_symtab = mdebug_read_symtab;
return (psymtab);
}
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 82ae1b5..4c189aa 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -121,6 +121,14 @@ struct partial_symtab
CORE_ADDR addr)
ATTRIBUTE_NONNULL (2) ATTRIBUTE_NONNULL (3);
+ virtual ~partial_symtab ()
+ {
+ }
+
+ /* Read the full symbol table corresponding to this partial symbol
+ table. */
+ virtual void read_symtab (struct objfile *) = 0;
+
/* Return the raw low text address of this partial_symtab. */
CORE_ADDR raw_text_low () const
{
@@ -278,11 +286,35 @@ struct partial_symtab
!readin or if we haven't looked for the symtab after it was readin. */
struct compunit_symtab *compunit_symtab = nullptr;
+};
+
+/* A partial_symtab that works in the historical db way. This should
+ not be used in new code, but exists to transition the somewhat
+ unmaintained "legacy" debug formats. */
+
+struct legacy_psymtab : public partial_symtab
+{
+ legacy_psymtab (const char *filename, struct objfile *objfile)
+ : partial_symtab (filename, objfile)
+ {
+ }
+
+ legacy_psymtab (const char *filename, struct objfile *objfile,
+ CORE_ADDR addr)
+ : partial_symtab (filename, objfile, addr)
+ {
+ }
+
+ void read_symtab (struct objfile *objf) override
+ {
+ if (legacy_read_symtab)
+ (*legacy_read_symtab) (this, objf);
+ }
/* Pointer to function which will read in the symtab corresponding to
this psymtab. */
- void (*read_symtab) (struct partial_symtab *, struct objfile *) = nullptr;
+ void (*legacy_read_symtab) (legacy_psymtab *, struct objfile *) = nullptr;
/* Information that lets read_symtab() locate the part of the symbol table
that this psymtab corresponds to. This information is private to the
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index b31461c..6a2f7f7 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -758,7 +758,7 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
{
scoped_restore decrementer = increment_reading_symtab ();
- (*pst->read_symtab) (pst, objfile);
+ pst->read_symtab (objfile);
}
return pst->compunit_symtab;
@@ -946,8 +946,6 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
fprintf_filtered (outfile,
" Full symtab was read (at ");
gdb_print_host_address (psymtab->compunit_symtab, outfile);
- fprintf_filtered (outfile, " by function at ");
- gdb_print_host_address (psymtab->read_symtab, outfile);
fprintf_filtered (outfile, ")\n");
}
diff --git a/gdb/stabsread.h b/gdb/stabsread.h
index aa52a98..b3d6ef4 100644
--- a/gdb/stabsread.h
+++ b/gdb/stabsread.h
@@ -20,6 +20,7 @@
#define STABSREAD_H
struct objfile;
+struct legacy_psymtab;
enum language;
/* Definitions, prototypes, etc for stabs debugging format support
@@ -170,11 +171,11 @@ extern void finish_global_stabs (struct objfile *objfile);
/* Functions exported by dbxread.c. These are not in stabsread.c because
they are only used by some stabs readers. */
-extern struct partial_symtab *dbx_end_psymtab
- (struct objfile *objfile, struct partial_symtab *pst,
+extern legacy_psymtab *dbx_end_psymtab
+ (struct objfile *objfile, legacy_psymtab *pst,
const char **include_list, int num_includes,
int capping_symbol_offset, CORE_ADDR capping_text,
- struct partial_symtab **dependency_list, int number_dependencies,
+ legacy_psymtab **dependency_list, int number_dependencies,
int textlow_not_set);
extern void process_one_symbol (int, int, CORE_ADDR, const char *,
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 901c134..69731a4 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -230,7 +230,7 @@ static CORE_ADDR read_symbol_nvalue (int);
static struct symbol *process_xcoff_symbol (struct coff_symbol *,
struct objfile *);
-static void read_xcoff_symtab (struct objfile *, struct partial_symtab *);
+static void read_xcoff_symtab (struct objfile *, legacy_psymtab *);
#if 0
static void add_stab_to_list (char *, struct pending_stabs **);
@@ -592,7 +592,7 @@ allocate_include_entry (void)
/* Global variable to pass the psymtab down to all the routines involved
in psymtab to symtab processing. */
-static struct partial_symtab *this_symtab_psymtab;
+static legacy_psymtab *this_symtab_psymtab;
/* Objfile related to this_symtab_psymtab; set at the same time. */
static struct objfile *this_symtab_objfile;
@@ -990,7 +990,7 @@ xcoff_next_symbol_text (struct objfile *objfile)
/* Read symbols for a given partial symbol table. */
static void
-read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
+read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst)
{
bfd *abfd = objfile->obfd;
char *raw_auxptr; /* Pointer to first raw aux entry for sym. */
@@ -1817,7 +1817,7 @@ find_linenos (struct bfd *abfd, struct bfd_section *asect, void *vpinfo)
}
static void
-xcoff_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
+xcoff_psymtab_to_symtab_1 (struct objfile *objfile, legacy_psymtab *pst)
{
int i;
@@ -1847,7 +1847,8 @@ xcoff_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
wrap_here (""); /* Flush output */
gdb_flush (gdb_stdout);
}
- xcoff_psymtab_to_symtab_1 (objfile, pst->dependencies[i]);
+ xcoff_psymtab_to_symtab_1 (objfile,
+ (legacy_psymtab *) pst->dependencies[i]);
}
if (((struct symloc *) pst->read_symtab_private)->numsyms != 0)
@@ -1866,7 +1867,7 @@ xcoff_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
Be verbose about it if the user wants that. SELF is not NULL. */
static void
-xcoff_read_symtab (struct partial_symtab *self, struct objfile *objfile)
+xcoff_read_symtab (legacy_psymtab *self, struct objfile *objfile)
{
if (self->readin)
{
@@ -2003,17 +2004,17 @@ static unsigned int first_fun_line_offset;
is the address relative to which its symbols are (incremental) or 0
(normal). */
-static struct partial_symtab *
+static legacy_psymtab *
xcoff_start_psymtab (struct objfile *objfile,
const char *filename, int first_symnum)
{
/* We fill in textlow later. */
- struct partial_symtab *result = new partial_symtab (filename, objfile, 0);
+ legacy_psymtab *result = new legacy_psymtab (filename, objfile, 0);
result->read_symtab_private =
XOBNEW (&objfile->objfile_obstack, struct symloc);
((struct symloc *) result->read_symtab_private)->first_symnum = first_symnum;
- result->read_symtab = xcoff_read_symtab;
+ result->legacy_read_symtab = xcoff_read_symtab;
/* Deduce the source language from the filename for this psymtab. */
psymtab_language = deduce_language_from_filename (filename);
@@ -2029,11 +2030,11 @@ xcoff_start_psymtab (struct objfile *objfile,
INCLUDE_LIST, NUM_INCLUDES, DEPENDENCY_LIST, and NUMBER_DEPENDENCIES
are the information for includes and dependencies. */
-static struct partial_symtab *
-xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
+static legacy_psymtab *
+xcoff_end_psymtab (struct objfile *objfile, legacy_psymtab *pst,
const char **include_list, int num_includes,
int capping_symbol_number,
- struct partial_symtab **dependency_list,
+ legacy_psymtab **dependency_list,
int number_dependencies, int textlow_not_set)
{
int i;
@@ -2054,15 +2055,15 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
pst->dependencies
= objfile->partial_symtabs->allocate_dependencies (number_dependencies);
memcpy (pst->dependencies, dependency_list,
- number_dependencies * sizeof (struct partial_symtab *));
+ number_dependencies * sizeof (legacy_psymtab *));
}
else
pst->dependencies = 0;
for (i = 0; i < num_includes; i++)
{
- struct partial_symtab *subpst =
- new partial_symtab (include_list[i], objfile);
+ legacy_psymtab *subpst =
+ new legacy_psymtab (include_list[i], objfile);
subpst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, symloc);
((struct symloc *) subpst->read_symtab_private)->first_symnum = 0;
@@ -2075,7 +2076,7 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
subpst->dependencies[0] = pst;
subpst->number_of_dependencies = 1;
- subpst->read_symtab = pst->read_symtab;
+ subpst->legacy_read_symtab = pst->legacy_read_symtab;
}
if (num_includes == 0
@@ -2169,7 +2170,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
unsigned int nsyms;
/* Current partial symtab */
- struct partial_symtab *pst;
+ legacy_psymtab *pst;
/* List of current psymtab's include files. */
const char **psymtab_include_list;
@@ -2177,7 +2178,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
int includes_used;
/* Index within current psymtab dependency list. */
- struct partial_symtab **dependency_list;
+ legacy_psymtab **dependency_list;
int dependencies_used, dependencies_allocated;
char *sraw_symbol;
@@ -2191,7 +2192,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
int misc_func_recorded = 0; /* true if any misc. function. */
int textlow_not_set = 1;
- pst = (struct partial_symtab *) 0;
+ pst = (legacy_psymtab *) 0;
includes_allocated = 30;
includes_used = 0;
@@ -2201,8 +2202,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
dependencies_allocated = 30;
dependencies_used = 0;
dependency_list =
- (struct partial_symtab **) alloca (dependencies_allocated *
- sizeof (struct partial_symtab *));
+ (legacy_psymtab **) alloca (dependencies_allocated *
+ sizeof (legacy_psymtab *));
set_last_source_file (NULL);