+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
};
/* 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)
{
}
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)
{
}
/* 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
{
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. */
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. */
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)
{
}
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
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. */
(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;
}
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);
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 ();
printf_filtered (_("done.\n"));
}
- return pst->compunit_symtab;
+ return pst->get_compunit_symtab ();
}
/* Psymtab version of find_last_source_symtab. See its definition in
if (cs_pst)
{
- if (cs_pst->readin)
+ if (cs_pst->readin_p ())
{
internal_error (__FILE__, __LINE__,
_("select_source_symtab: "
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");
}
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);
{
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)
{
const char *fullname;
- if (ps->readin)
+ if (ps->readin_p ())
continue;
/* We can skip shared psymtabs here, because any file name will be
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))
{
{
QUIT;
- if (ps->readin)
+ if (ps->readin_p ())
continue;
/* We skip shared psymtabs because file-matching doesn't apply
filename
= ((const char *) objfile->per_bfd->filename_cache.insert
(filename_, strlen (filename_) + 1));
- compunit_symtab = NULL;
if (symtab_create_debug)
{
{
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)
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)");
/* 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))