aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-10-23 09:50:58 -0600
committerTom Tromey <tom@tromey.com>2020-01-26 16:40:21 -0700
commit128a391fe45a234587dc585e03a7726cd6ee0255 (patch)
tree138e6a68a6da90b5aefea011f0e7c113b721fe56
parent0494dbecdfa0b0b9065393755a1ac64431997da1 (diff)
downloadgdb-128a391fe45a234587dc585e03a7726cd6ee0255.zip
gdb-128a391fe45a234587dc585e03a7726cd6ee0255.tar.gz
gdb-128a391fe45a234587dc585e03a7726cd6ee0255.tar.bz2
Virtualize "readin" and "compunit_symtab"
This patch removes the "readin" and "compunit_symtab" members from partial_symtab, replacing them with methods. Then it introduces a new "standard_psymtab" class, which restores these members; and changes the symbol readers to use this intermediate class as the base class of their partial symtab subclasses. The reason for this is to make it possible for a symbol reader to implement an alternate mapping between partial and full symbol tables. This is important in order to be able to share psymtabs across objfiles -- whether a psymtab has been "readin" is objfile-dependent, as are the pointers to the full symbol tables. gdb/ChangeLog 2020-01-26 Tom Tromey <tom@tromey.com> * psymtab.c (partial_map_expand_apply) (psym_find_pc_sect_compunit_symtab, psym_lookup_symbol) (psymtab_to_symtab, psym_find_last_source_symtab, dump_psymtab) (psym_print_stats, psym_expand_symtabs_for_function) (psym_map_symbol_filenames, psym_map_matching_symbols) (psym_expand_symtabs_matching) (partial_symtab::read_dependencies, maintenance_info_psymtabs) (maintenance_check_psymtabs): Use new methods. * psympriv.h (struct partial_symtab) <readin_p, get_compunit_symtab>: New methods. <readin, compunit_symtab>: Remove members. (struct standard_psymtab): New. (struct legacy_psymtab): Derive from standard_psymtab. * dwarf2read.h (struct dwarf2_psymtab): Derive from standard_psymtab. * ctfread.c (struct ctf_psymtab): Derive from standard_psymtab. Change-Id: Idb923f196d7e03bf7cb9cfc8134ed06dd3f211ce
-rw-r--r--gdb/ChangeLog19
-rw-r--r--gdb/ctfread.c4
-rw-r--r--gdb/dwarf2read.h6
-rw-r--r--gdb/psympriv.h55
-rw-r--r--gdb/psymtab.c41
5 files changed, 90 insertions, 35 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 69f2689..77e52f3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,24 @@
2020-01-26 Tom Tromey <tom@tromey.com>
+ * psymtab.c (partial_map_expand_apply)
+ (psym_find_pc_sect_compunit_symtab, psym_lookup_symbol)
+ (psymtab_to_symtab, psym_find_last_source_symtab, dump_psymtab)
+ (psym_print_stats, psym_expand_symtabs_for_function)
+ (psym_map_symbol_filenames, psym_map_matching_symbols)
+ (psym_expand_symtabs_matching)
+ (partial_symtab::read_dependencies, maintenance_info_psymtabs)
+ (maintenance_check_psymtabs): Use new methods.
+ * psympriv.h (struct partial_symtab) <readin_p,
+ get_compunit_symtab>: New methods.
+ <readin, compunit_symtab>: Remove members.
+ (struct standard_psymtab): New.
+ (struct legacy_psymtab): Derive from standard_psymtab.
+ * dwarf2read.h (struct dwarf2_psymtab): Derive from
+ standard_psymtab.
+ * ctfread.c (struct ctf_psymtab): Derive from standard_psymtab.
+
+2020-01-26 Tom Tromey <tom@tromey.com>
+
* xcoffread.c (xcoff_psymtab_to_symtab_1): Call
read_dependencies. Add assert.
* psymtab.c (partial_symtab::read_dependencies): New method.
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 77cdcd4..d363ce6 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -116,10 +116,10 @@ struct ctf_context
};
/* A partial symtab, specialized for this module. */
-struct ctf_psymtab : public partial_symtab
+struct ctf_psymtab : public standard_psymtab
{
ctf_psymtab (const char *filename, struct objfile *objfile, CORE_ADDR addr)
- : partial_symtab (filename, objfile, addr)
+ : standard_psymtab (filename, objfile, addr)
{
}
diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h
index c5b6902..3f9731f 100644
--- a/gdb/dwarf2read.h
+++ b/gdb/dwarf2read.h
@@ -271,16 +271,16 @@ public:
dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile);
/* A partial symtab specialized for DWARF. */
-struct dwarf2_psymtab : public partial_symtab
+struct dwarf2_psymtab : public standard_psymtab
{
dwarf2_psymtab (const char *filename, struct objfile *objfile)
- : partial_symtab (filename, objfile)
+ : standard_psymtab (filename, objfile)
{
}
dwarf2_psymtab (const char *filename, struct objfile *objfile,
CORE_ADDR addr)
- : partial_symtab (filename, objfile, addr)
+ : standard_psymtab (filename, objfile, addr)
{
}
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index e4b2330..1b1f57c 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -137,6 +137,15 @@ struct partial_symtab
/* Ensure that all the dependencies are read in. */
void read_dependencies (struct objfile *);
+ /* Return true if the symtab corresponding to this psymtab has been
+ readin. */
+ virtual bool readin_p () const = 0;
+
+ /* Return a pointer to the compunit allocated for this source file.
+ Return nullptr if !readin or if there was no symtab. */
+ virtual struct compunit_symtab *get_compunit_symtab () const = 0;
+
+
/* Return the raw low text address of this partial_symtab. */
CORE_ADDR raw_text_low () const
{
@@ -265,12 +274,6 @@ struct partial_symtab
int statics_offset = 0;
int n_static_syms = 0;
- /* True if the symtab corresponding to this psymtab has been readin.
- This is located here so that this structure packs better on
- 64-bit systems. */
-
- bool readin = false;
-
/* True iff objfile->psymtabs_addrmap is properly populated for this
partial_symtab. For discontiguous overlapping psymtabs is the only usable
info in PSYMTABS_ADDRMAP. */
@@ -289,6 +292,40 @@ struct partial_symtab
unsigned int text_low_valid : 1;
unsigned int text_high_valid : 1;
+};
+
+/* A partial symtab that tracks the "readin" and "compunit_symtab"
+ information in the ordinary way -- by storing it directly in this
+ object. */
+struct standard_psymtab : public partial_symtab
+{
+ standard_psymtab (const char *filename, struct objfile *objfile)
+ : partial_symtab (filename, objfile)
+ {
+ }
+
+ standard_psymtab (const char *filename, struct objfile *objfile,
+ CORE_ADDR addr)
+ : partial_symtab (filename, objfile, addr)
+ {
+ }
+
+ bool readin_p () const override
+ {
+ return readin;
+ }
+
+ /* Return a pointer to the compunit allocated for this source file.
+ Return nullptr if !readin or if there was no symtab. */
+ struct compunit_symtab *get_compunit_symtab () const override
+ {
+ return compunit_symtab;
+ }
+
+ /* True if the symtab corresponding to this psymtab has been
+ readin. */
+
+ bool readin = false;
/* Pointer to compunit eventually allocated for this source file, 0 if
!readin or if we haven't looked for the symtab after it was readin. */
@@ -300,16 +337,16 @@ struct partial_symtab
not be used in new code, but exists to transition the somewhat
unmaintained "legacy" debug formats. */
-struct legacy_psymtab : public partial_symtab
+struct legacy_psymtab : public standard_psymtab
{
legacy_psymtab (const char *filename, struct objfile *objfile)
- : partial_symtab (filename, objfile)
+ : standard_psymtab (filename, objfile)
{
}
legacy_psymtab (const char *filename, struct objfile *objfile,
CORE_ADDR addr)
- : partial_symtab (filename, objfile, addr)
+ : standard_psymtab (filename, objfile, addr)
{
}
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index c020d15..56576b3 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -131,7 +131,7 @@ partial_map_expand_apply (struct objfile *objfile,
gdb_assert (pst->user == NULL);
/* Don't visit already-expanded psymtabs. */
- if (pst->readin)
+ if (pst->readin_p ())
return 0;
/* This may expand more than one symtab, and we want to iterate over
@@ -385,7 +385,7 @@ psym_find_pc_sect_compunit_symtab (struct objfile *objfile,
msymbol);
if (ps != NULL)
{
- if (warn_if_readin && ps->readin)
+ if (warn_if_readin && ps->readin_p ())
/* Might want to error() here (in case symtab is corrupt and
will cause a core dump), but maybe we can successfully
continue, so let's not. */
@@ -393,7 +393,7 @@ psym_find_pc_sect_compunit_symtab (struct objfile *objfile,
(Internal error: pc %s in read in psymtab, but not in symtab.)\n"),
paddress (get_objfile_arch (objfile), pc));
psymtab_to_symtab (objfile, ps);
- return ps->compunit_symtab;
+ return ps->get_compunit_symtab ();
}
return NULL;
}
@@ -484,8 +484,8 @@ psym_lookup_symbol (struct objfile *objfile,
for (partial_symtab *ps : require_partial_symbols (objfile, true))
{
- if (!ps->readin && lookup_partial_symbol (objfile, ps, name,
- psymtab_index, domain))
+ if (!ps->readin_p () && lookup_partial_symbol (objfile, ps, name,
+ psymtab_index, domain))
{
struct symbol *sym, *with_opaque = NULL;
struct compunit_symtab *stab = psymtab_to_symtab (objfile, ps);
@@ -750,11 +750,11 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
pst = pst->user;
/* If it's been looked up before, return it. */
- if (pst->compunit_symtab)
- return pst->compunit_symtab;
+ if (pst->get_compunit_symtab ())
+ return pst->get_compunit_symtab ();
/* If it has not yet been read in, read it. */
- if (!pst->readin)
+ if (!pst->readin_p ())
{
scoped_restore decrementer = increment_reading_symtab ();
@@ -772,7 +772,7 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
printf_filtered (_("done.\n"));
}
- return pst->compunit_symtab;
+ return pst->get_compunit_symtab ();
}
/* Psymtab version of find_last_source_symtab. See its definition in
@@ -795,7 +795,7 @@ psym_find_last_source_symtab (struct objfile *ofp)
if (cs_pst)
{
- if (cs_pst->readin)
+ if (cs_pst->readin_p ())
{
internal_error (__FILE__, __LINE__,
_("select_source_symtab: "
@@ -952,11 +952,11 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
gdb_print_host_address (objfile, outfile);
fprintf_filtered (outfile, ")\n");
- if (psymtab->readin)
+ if (psymtab->readin_p ())
{
fprintf_filtered (outfile,
" Full symtab was read (at ");
- gdb_print_host_address (psymtab->compunit_symtab, outfile);
+ gdb_print_host_address (psymtab->get_compunit_symtab (), outfile);
fprintf_filtered (outfile, ")\n");
}
@@ -1010,7 +1010,7 @@ psym_print_stats (struct objfile *objfile)
i = 0;
for (partial_symtab *ps : require_partial_symbols (objfile, true))
{
- if (!ps->readin)
+ if (!ps->readin_p ())
i++;
}
printf_filtered (_(" Number of psym tables (not yet expanded): %d\n"), i);
@@ -1050,7 +1050,7 @@ psym_expand_symtabs_for_function (struct objfile *objfile,
{
for (partial_symtab *ps : require_partial_symbols (objfile, true))
{
- if (ps->readin)
+ if (ps->readin_p ())
continue;
if ((lookup_partial_symbol (objfile, ps, func_name, 1, VAR_DOMAIN)
@@ -1105,7 +1105,7 @@ psym_map_symbol_filenames (struct objfile *objfile,
{
const char *fullname;
- if (ps->readin)
+ if (ps->readin_p ())
continue;
/* We can skip shared psymtabs here, because any file name will be
@@ -1185,7 +1185,7 @@ psym_map_matching_symbols
for (partial_symtab *ps : require_partial_symbols (objfile, true))
{
QUIT;
- if (ps->readin
+ if (ps->readin_p ()
|| match_partial_symbol (objfile, ps, global, name, domain,
ordered_compare))
{
@@ -1320,7 +1320,7 @@ psym_expand_symtabs_matching
{
QUIT;
- if (ps->readin)
+ if (ps->readin_p ())
continue;
/* We skip shared psymtabs because file-matching doesn't apply
@@ -1659,7 +1659,6 @@ partial_symtab::partial_symtab (const char *filename_, struct objfile *objfile)
filename
= ((const char *) objfile->per_bfd->filename_cache.insert
(filename_, strlen (filename_) + 1));
- compunit_symtab = NULL;
if (symtab_create_debug)
{
@@ -1689,7 +1688,7 @@ partial_symtab::read_dependencies (struct objfile *objfile)
{
for (int i = 0; i < number_of_dependencies; ++i)
{
- if (!dependencies[i]->readin)
+ if (!dependencies[i]->readin_p ())
{
/* Inform about additional files to be read in. */
if (info_verbose)
@@ -2001,7 +2000,7 @@ maintenance_info_psymtabs (const char *regexp, int from_tty)
host_address_to_string (psymtab));
printf_filtered (" readin %s\n",
- psymtab->readin ? "yes" : "no");
+ psymtab->readin_p () ? "yes" : "no");
printf_filtered (" fullname %s\n",
psymtab->fullname
? psymtab->fullname : "(null)");
@@ -2092,7 +2091,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
/* We don't call psymtab_to_symtab here because that may cause symtab
expansion. When debugging a problem it helps if checkers leave
things unchanged. */
- cust = ps->compunit_symtab;
+ cust = ps->get_compunit_symtab ();
/* First do some checks that don't require the associated symtab. */
if (ps->text_high (objfile) < ps->text_low (objfile))