aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-10-23 09:40:54 -0600
committerTom Tromey <tom@tromey.com>2020-01-26 16:40:21 -0700
commit8566b89b737eef50f67bf23329b4606cf7973de1 (patch)
tree022486e22ca850c04d2488ec9913114191a69f91 /gdb
parent077cbab270376098e90c841690f9e4439b63d3d4 (diff)
downloadgdb-8566b89b737eef50f67bf23329b4606cf7973de1.zip
gdb-8566b89b737eef50f67bf23329b4606cf7973de1.tar.gz
gdb-8566b89b737eef50f67bf23329b4606cf7973de1.tar.bz2
Introduce partial_symtab::expand_psymtab method
The symbol readers generally used two functions to expand a partial symtab: an outer function (now the "read_symtab" method), and an inner function, typically named something like "psymtab_to_symtab". This patch changes this second step to be a method on partial_symtab, and updates all the callers. For legacy_psymtab, a new function pointer member is introduced. This patch enables a subsequent cleanup. gdb/ChangeLog 2020-01-26 Tom Tromey <tom@tromey.com> * xcoffread.c (xcoff_psymtab_to_symtab_1): Change argument order. Call expand_psymtab. (xcoff_read_symtab): Call expand_psymtab. (xcoff_start_psymtab, xcoff_end_psymtab): Set legacy_expand_psymtab. * psympriv.h (struct partial_symtab) <expand_psymtab>: New method. (struct legacy_psymtab) <expand_psymtab>: Implement. <legacy_expand_psymtab>: New member. * mdebugread.c (mdebug_read_symtab): Call expand_psymtab. (parse_partial_symbols): Set legacy_expand_psymtab. (psymtab_to_symtab_1): Change argument order. Call expand_psymtab. (new_psymtab): Set legacy_expand_psymtab. * dwarf2read.h (struct dwarf2_psymtab) <expand_psymtab>: Declare. * dwarf2read.c (dwarf2_psymtab::read_symtab): Call expand_psymtab. (dwarf2_psymtab::expand_psymtab): Rename from psymtab_to_symtab_1. Call expand_psymtab. * dbxread.c (start_psymtab): Set legacy_expand_psymtab. (dbx_end_psymtab): Likewise. (dbx_psymtab_to_symtab_1): Change argument order. Call expand_psymtab. (dbx_read_symtab): Call expand_psymtab. * ctfread.c (struct ctf_psymtab) <expand_psymtab>: Declare. (ctf_psymtab::expand_psymtab): Rename from psymtab_to_symtab. (ctf_psymtab::read_symtab): Call expand_psymtab. Change-Id: Ic39a2d7aa7b424088d910b59dbd21271fa1c3430
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog30
-rw-r--r--gdb/ctfread.c15
-rw-r--r--gdb/dbxread.c11
-rw-r--r--gdb/dwarf2read.c24
-rw-r--r--gdb/dwarf2read.h1
-rw-r--r--gdb/mdebugread.c15
-rw-r--r--gdb/psympriv.h15
-rw-r--r--gdb/xcoffread.c9
8 files changed, 82 insertions, 38 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ed3b97b..c6a0251 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,35 @@
2020-01-26 Tom Tromey <tom@tromey.com>
+ * xcoffread.c (xcoff_psymtab_to_symtab_1): Change argument order.
+ Call expand_psymtab.
+ (xcoff_read_symtab): Call expand_psymtab.
+ (xcoff_start_psymtab, xcoff_end_psymtab): Set
+ legacy_expand_psymtab.
+ * psympriv.h (struct partial_symtab) <expand_psymtab>: New
+ method.
+ (struct legacy_psymtab) <expand_psymtab>: Implement.
+ <legacy_expand_psymtab>: New member.
+ * mdebugread.c (mdebug_read_symtab): Call expand_psymtab.
+ (parse_partial_symbols): Set legacy_expand_psymtab.
+ (psymtab_to_symtab_1): Change argument order. Call
+ expand_psymtab.
+ (new_psymtab): Set legacy_expand_psymtab.
+ * dwarf2read.h (struct dwarf2_psymtab) <expand_psymtab>: Declare.
+ * dwarf2read.c (dwarf2_psymtab::read_symtab): Call
+ expand_psymtab.
+ (dwarf2_psymtab::expand_psymtab): Rename from
+ psymtab_to_symtab_1. Call expand_psymtab.
+ * dbxread.c (start_psymtab): Set legacy_expand_psymtab.
+ (dbx_end_psymtab): Likewise.
+ (dbx_psymtab_to_symtab_1): Change argument order. Call
+ expand_psymtab.
+ (dbx_read_symtab): Call expand_psymtab.
+ * ctfread.c (struct ctf_psymtab) <expand_psymtab>: Declare.
+ (ctf_psymtab::expand_psymtab): Rename from psymtab_to_symtab.
+ (ctf_psymtab::read_symtab): Call expand_psymtab.
+
+2020-01-26 Tom Tromey <tom@tromey.com>
+
* xcoffread.c (xcoff_read_symtab): Remove prints. Add assert.
* psymtab.c (psymtab_to_symtab): Print verbose "Reading"
messages.
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 120c7b4..77cdcd4 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -124,6 +124,7 @@ struct ctf_psymtab : public partial_symtab
}
void read_symtab (struct objfile *) override;
+ void expand_psymtab (struct objfile *) override;
struct ctf_context *context;
};
@@ -160,8 +161,6 @@ struct ctf_field_info
/* Local function prototypes */
-static void psymtab_to_symtab (ctf_psymtab *);
-
static int ctf_add_type_cb (ctf_id_t tid, void *arg);
static struct type *read_array_type (struct ctf_context *cp, ctf_id_t tid);
@@ -1216,15 +1215,15 @@ ctf_end_symtab (ctf_psymtab *pst,
/* Read in full symbols for PST, and anything it depends on. */
-static void
-psymtab_to_symtab (ctf_psymtab *pst)
+void
+ctf_psymtab::expand_psymtab (struct objfile *objfile)
{
struct symbol *sym;
struct ctf_context *ccp;
- gdb_assert (!pst->readin);
+ gdb_assert (!readin);
- ccp = pst->context;
+ ccp = context;
/* Iterate over entries in data types section. */
if (ctf_type_iter (ccp->fp, ctf_add_type_cb, ccp) == CTF_ERR)
@@ -1254,7 +1253,7 @@ psymtab_to_symtab (ctf_psymtab *pst)
set_symbol_address (ccp->of, sym, sym->linkage_name ());
}
- pst->readin = true;
+ readin = true;
}
/* Expand partial symbol table PST into a full symbol table.
@@ -1279,7 +1278,7 @@ ctf_psymtab::read_symtab (struct objfile *objfile)
offset = get_objfile_text_range (objfile, &tsize);
ctf_start_symtab (this, objfile, offset);
- psymtab_to_symtab (this);
+ expand_psymtab (objfile);
set_text_low (offset);
set_text_high (offset + tsize);
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 9d8d938..2711ea8 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -268,7 +268,7 @@ static void read_ofile_symtab (struct objfile *, legacy_psymtab *);
static void dbx_read_symtab (legacy_psymtab *self,
struct objfile *objfile);
-static void dbx_psymtab_to_symtab_1 (struct objfile *, legacy_psymtab *);
+static void dbx_psymtab_to_symtab_1 (legacy_psymtab *, struct objfile *);
static void read_dbx_symtab (minimal_symbol_reader &, struct objfile *);
@@ -1909,6 +1909,7 @@ start_psymtab (struct objfile *objfile, const char *filename, CORE_ADDR textlow,
XOBNEW (&objfile->objfile_obstack, struct symloc);
LDSYMOFF (result) = ldsymoff;
result->legacy_read_symtab = dbx_read_symtab;
+ result->legacy_expand_psymtab = dbx_psymtab_to_symtab_1;
SYMBOL_SIZE (result) = symbol_size;
SYMBOL_OFFSET (result) = symbol_table_offset;
STRING_OFFSET (result) = string_table_offset;
@@ -2039,6 +2040,7 @@ dbx_end_psymtab (struct objfile *objfile, legacy_psymtab *pst,
subpst->number_of_dependencies = 1;
subpst->legacy_read_symtab = pst->legacy_read_symtab;
+ subpst->legacy_expand_psymtab = pst->legacy_expand_psymtab;
}
if (num_includes == 0
@@ -2064,7 +2066,7 @@ dbx_end_psymtab (struct objfile *objfile, legacy_psymtab *pst,
}
static void
-dbx_psymtab_to_symtab_1 (struct objfile *objfile, legacy_psymtab *pst)
+dbx_psymtab_to_symtab_1 (legacy_psymtab *pst, struct objfile *objfile)
{
int i;
@@ -2091,8 +2093,7 @@ dbx_psymtab_to_symtab_1 (struct objfile *objfile, legacy_psymtab *pst)
wrap_here (""); /* Flush output. */
gdb_flush (gdb_stdout);
}
- dbx_psymtab_to_symtab_1 (objfile,
- (legacy_psymtab *) pst->dependencies[i]);
+ pst->dependencies[i]->expand_psymtab (objfile);
}
if (LDSYMLEN (pst)) /* Otherwise it's a dummy. */
@@ -2135,7 +2136,7 @@ dbx_read_symtab (legacy_psymtab *self, struct objfile *objfile)
data_holder.reset (stabs_data);
}
- dbx_psymtab_to_symtab_1 (objfile, self);
+ self->expand_psymtab (objfile);
}
/* Match with global symbols. This only needs to be done once,
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 9942270..c3e0866 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1513,8 +1513,6 @@ 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 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 *,
sect_offset);
@@ -9510,7 +9508,7 @@ dwarf2_psymtab::read_symtab (struct objfile *objfile)
dwarf2_per_objfile->reading_partial_symbols = 0;
- psymtab_to_symtab_1 (this);
+ expand_psymtab (objfile);
process_cu_includes (dwarf2_per_objfile);
}
@@ -9661,18 +9659,18 @@ 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 (dwarf2_psymtab *pst)
+void
+dwarf2_psymtab::expand_psymtab (struct objfile *objfile)
{
struct dwarf2_per_cu_data *per_cu;
int i;
- if (pst->readin)
+ if (readin)
return;
- for (i = 0; i < pst->number_of_dependencies; i++)
- if (!pst->dependencies[i]->readin
- && pst->dependencies[i]->user == NULL)
+ for (i = 0; i < number_of_dependencies; i++)
+ if (!dependencies[i]->readin
+ && dependencies[i]->user == NULL)
{
/* Inform about additional files that need to be read in. */
if (info_verbose)
@@ -9682,20 +9680,20 @@ psymtab_to_symtab_1 (dwarf2_psymtab *pst)
wrap_here ("");
fputs_filtered ("and ", gdb_stdout);
wrap_here ("");
- printf_filtered ("%s...", pst->dependencies[i]->filename);
+ printf_filtered ("%s...", dependencies[i]->filename);
wrap_here (""); /* Flush output. */
gdb_flush (gdb_stdout);
}
- psymtab_to_symtab_1 ((dwarf2_psymtab *) pst->dependencies[i]);
+ dependencies[i]->expand_psymtab (objfile);
}
- per_cu = pst->per_cu_data;
+ per_cu = per_cu_data;
if (per_cu == NULL)
{
/* It's an include file, no symbols to read for it.
Everything is in the parent symtab. */
- pst->readin = true;
+ readin = true;
return;
}
diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h
index 06bd908..c5b6902 100644
--- a/gdb/dwarf2read.h
+++ b/gdb/dwarf2read.h
@@ -285,6 +285,7 @@ struct dwarf2_psymtab : public partial_symtab
}
void read_symtab (struct objfile *) override;
+ void expand_psymtab (struct objfile *) override;
struct dwarf2_per_cu_data *per_cu_data;
};
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 4b32a5a..1d0a0fc 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -253,8 +253,8 @@ static void sort_blocks (struct symtab *);
static legacy_psymtab *new_psymtab (const char *, struct objfile *);
-static void psymtab_to_symtab_1 (struct objfile *objfile,
- legacy_psymtab *, const char *);
+static void psymtab_to_symtab_1 (legacy_psymtab *pst,
+ struct objfile *objfile);
static void add_block (struct block *, struct symtab *);
@@ -279,7 +279,7 @@ mdebug_read_symtab (legacy_psymtab *self, struct objfile *objfile)
{
next_symbol_text_func = mdebug_next_symbol_text;
- psymtab_to_symtab_1 (objfile, self, self->filename);
+ self->expand_psymtab (objfile);
/* Match with global symbols. This only needs to be done once,
after all of the symtabs and dependencies have been read in. */
@@ -2613,6 +2613,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
/* The way to turn this into a symtab is to call... */
pst->legacy_read_symtab = mdebug_read_symtab;
+ pst->legacy_expand_psymtab = psymtab_to_symtab_1;
/* Set up language for the pst.
The language from the FDR is used if it is unambigious (e.g. cfront
@@ -3834,8 +3835,7 @@ mdebug_next_symbol_text (struct objfile *objfile)
The flow of control and even the memory allocation differs. FIXME. */
static void
-psymtab_to_symtab_1 (struct objfile *objfile,
- legacy_psymtab *pst, const char *filename)
+psymtab_to_symtab_1 (legacy_psymtab *pst, struct objfile *objfile)
{
bfd_size_type external_sym_size;
bfd_size_type external_pdr_size;
@@ -3872,9 +3872,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
wrap_here (""); /* Flush output */
gdb_flush (gdb_stdout);
}
- /* We only pass the filename for debug purposes. */
- psymtab_to_symtab_1 (objfile, (legacy_psymtab *) pst->dependencies[i],
- pst->dependencies[i]->filename);
+ pst->dependencies[i]->expand_psymtab (objfile);
}
/* Do nothing if this is a dummy psymtab. */
@@ -4664,6 +4662,7 @@ new_psymtab (const char *name, struct objfile *objfile)
/* The way to turn this into a symtab is to call... */
psymtab->legacy_read_symtab = mdebug_read_symtab;
+ psymtab->legacy_expand_psymtab = psymtab_to_symtab_1;
return (psymtab);
}
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 4c189aa..ae98a69 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -129,6 +129,11 @@ struct partial_symtab
table. */
virtual void read_symtab (struct objfile *) = 0;
+ /* Psymtab expansion is done in two steps. The first step is a call
+ to read_symtab; but while that is in progress, calls to
+ expand_psymtab can be made. */
+ virtual void expand_psymtab (struct objfile *) = 0;
+
/* Return the raw low text address of this partial_symtab. */
CORE_ADDR raw_text_low () const
{
@@ -311,11 +316,21 @@ struct legacy_psymtab : public partial_symtab
(*legacy_read_symtab) (this, objf);
}
+ void expand_psymtab (struct objfile *objf) override
+ {
+ (*legacy_expand_psymtab) (this, objf);
+ }
+
/* Pointer to function which will read in the symtab corresponding to
this psymtab. */
void (*legacy_read_symtab) (legacy_psymtab *, struct objfile *) = nullptr;
+ /* Pointer to function which will actually expand this psymtab into
+ a full symtab. */
+
+ void (*legacy_expand_psymtab) (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
format-dependent symbol reading routines. For further detail examine
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 66d6b9a..1c0db67 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -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, legacy_psymtab *pst)
+xcoff_psymtab_to_symtab_1 (legacy_psymtab *pst, struct objfile *objfile)
{
int i;
@@ -1847,8 +1847,7 @@ xcoff_psymtab_to_symtab_1 (struct objfile *objfile, legacy_psymtab *pst)
wrap_here (""); /* Flush output */
gdb_flush (gdb_stdout);
}
- xcoff_psymtab_to_symtab_1 (objfile,
- (legacy_psymtab *) pst->dependencies[i]);
+ pst->dependencies[i]->expand_psymtab (objfile);
}
if (((struct symloc *) pst->read_symtab_private)->numsyms != 0)
@@ -1876,7 +1875,7 @@ xcoff_read_symtab (legacy_psymtab *self, struct objfile *objfile)
{
next_symbol_text_func = xcoff_next_symbol_text;
- xcoff_psymtab_to_symtab_1 (objfile, self);
+ self->expand_psymtab (objfile);
/* Match with global symbols. This only needs to be done once,
after all of the symtabs and dependencies have been read in. */
@@ -1997,6 +1996,7 @@ xcoff_start_psymtab (struct objfile *objfile,
XOBNEW (&objfile->objfile_obstack, struct symloc);
((struct symloc *) result->read_symtab_private)->first_symnum = first_symnum;
result->legacy_read_symtab = xcoff_read_symtab;
+ result->legacy_expand_psymtab = xcoff_psymtab_to_symtab_1;
/* Deduce the source language from the filename for this psymtab. */
psymtab_language = deduce_language_from_filename (filename);
@@ -2059,6 +2059,7 @@ xcoff_end_psymtab (struct objfile *objfile, legacy_psymtab *pst,
subpst->number_of_dependencies = 1;
subpst->legacy_read_symtab = pst->legacy_read_symtab;
+ subpst->legacy_expand_psymtab = pst->legacy_expand_psymtab;
}
if (num_includes == 0