aboutsummaryrefslogtreecommitdiff
path: root/gdb/ctfread.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/ctfread.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/ctfread.c')
-rw-r--r--gdb/ctfread.c64
1 files changed, 38 insertions, 26 deletions
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;