Remove last objfile partial_symtab references from psymtab.c

This removes the last references to the partial_symtab via the objfile
from psymtab.c.  require_partial_symbols is now a method on
psymbol_functions, and maintenance_print_psymbols is changed to use
dynamic_cast to verify that it is examining partial symbols.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* psymtab.c (psymbol_functions::require_partial_symbols): Rename.
	(psymbol_functions::find_pc_sect_psymtab): Rename.
	(psymbol_functions::find_pc_sect_compunit_symtab)
	(maintenance_print_psymbols, maintenance_check_psymtabs): Update.
	* psympriv.h (struct psymbol_functions) <require_partial_symbols>:
	Declare new method.
	<get_partial_symtabs, find_pc_sect_psymtab>: Likewise.
This commit is contained in:
Tom Tromey
2021-03-20 17:23:40 -06:00
parent 7b249e470a
commit 3aa31ce788
3 changed files with 143 additions and 100 deletions

View File

@ -1,3 +1,13 @@
2021-03-20 Tom Tromey <tom@tromey.com>
* psymtab.c (psymbol_functions::require_partial_symbols): Rename.
(psymbol_functions::find_pc_sect_psymtab): Rename.
(psymbol_functions::find_pc_sect_compunit_symtab)
(maintenance_print_psymbols, maintenance_check_psymtabs): Update.
* psympriv.h (struct psymbol_functions) <require_partial_symbols>:
Declare new method.
<get_partial_symtabs, find_pc_sect_psymtab>: Likewise.
2021-03-20 Tom Tromey <tom@tromey.com> 2021-03-20 Tom Tromey <tom@tromey.com>
* xcoffread.c (xcoff_start_psymtab): Add partial_symtabs parameter. * xcoffread.c (xcoff_start_psymtab): Add partial_symtabs parameter.

View File

@ -559,6 +559,18 @@ struct psymbol_functions : public quick_symbol_functions
m_psymbol_map.clear (); m_psymbol_map.clear ();
} }
/* Ensure the partial symbols for OBJFILE have been loaded. Return
a range adapter for the psymtabs. */
psymtab_storage::partial_symtab_range require_partial_symbols
(struct objfile *objfile);
/* Return the partial symbol storage associated with this
object. */
const std::shared_ptr<psymtab_storage> &get_partial_symtabs () const
{
return m_partial_symtabs;
}
/* Replace the partial symbol table storage in this object with /* Replace the partial symbol table storage in this object with
SYMS. */ SYMS. */
void set_partial_symtabs (const std::shared_ptr<psymtab_storage> &syms) void set_partial_symtabs (const std::shared_ptr<psymtab_storage> &syms)
@ -566,6 +578,17 @@ struct psymbol_functions : public quick_symbol_functions
m_partial_symtabs = syms; m_partial_symtabs = syms;
} }
/* Find which partial symtab contains PC and SECTION. Return NULL if
none. We return the psymtab that contains a symbol whose address
exactly matches PC, or, if we cannot find an exact match, the
psymtab that contains a symbol whose address is closest to PC. */
struct partial_symtab *find_pc_sect_psymtab
(struct objfile *objfile,
CORE_ADDR pc,
struct obj_section *section,
struct bound_minimal_symbol msymbol);
private: private:
void fill_psymbol_map (struct objfile *objfile, void fill_psymbol_map (struct objfile *objfile,

View File

@ -80,11 +80,11 @@ psymtab_storage::install_psymtab (partial_symtab *pst)
returns a range adapter suitable for iterating over the psymtabs of returns a range adapter suitable for iterating over the psymtabs of
OBJFILE. */ OBJFILE. */
static psymtab_storage::partial_symtab_range psymtab_storage::partial_symtab_range
require_partial_symbols (struct objfile *objfile) psymbol_functions::require_partial_symbols (struct objfile *objfile)
{ {
objfile->require_partial_symbols (true); objfile->require_partial_symbols (true);
return objfile->psymtabs (); return m_partial_symtabs->range ();
} }
/* Helper function for psym_map_symtabs_matching_filename that /* Helper function for psym_map_symtabs_matching_filename that
@ -255,17 +255,13 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
return best_pst; return best_pst;
} }
/* Find which partial symtab contains PC and SECTION. Return NULL if /* See psympriv.h. */
none. We return the psymtab that contains a symbol whose address
exactly matches PC, or, if we cannot find an exact match, the
psymtab that contains a symbol whose address is closest to PC. */
static struct partial_symtab * struct partial_symtab *
find_pc_sect_psymtab (struct objfile *objfile, psymbol_functions::find_pc_sect_psymtab (struct objfile *objfile,
psymtab_storage *partial_symtabs, CORE_ADDR pc,
CORE_ADDR pc, struct obj_section *section,
struct obj_section *section, struct bound_minimal_symbol msymbol)
struct bound_minimal_symbol msymbol)
{ {
/* Try just the PSYMTABS_ADDRMAP mapping first as it has better /* Try just the PSYMTABS_ADDRMAP mapping first as it has better
granularity than the later used TEXTLOW/TEXTHIGH one. However, we need granularity than the later used TEXTLOW/TEXTHIGH one. However, we need
@ -279,14 +275,14 @@ find_pc_sect_psymtab (struct objfile *objfile,
partial symtabs then we will end up returning a pointer to an object partial symtabs then we will end up returning a pointer to an object
that is not a partial_symtab, which doesn't end well. */ that is not a partial_symtab, which doesn't end well. */
if (partial_symtabs->psymtabs != NULL if (m_partial_symtabs->psymtabs != NULL
&& partial_symtabs->psymtabs_addrmap != NULL) && m_partial_symtabs->psymtabs_addrmap != NULL)
{ {
CORE_ADDR baseaddr = objfile->text_section_offset (); CORE_ADDR baseaddr = objfile->text_section_offset ();
struct partial_symtab *pst struct partial_symtab *pst
= ((struct partial_symtab *) = ((struct partial_symtab *)
addrmap_find (partial_symtabs->psymtabs_addrmap, addrmap_find (m_partial_symtabs->psymtabs_addrmap,
pc - baseaddr)); pc - baseaddr));
if (pst != NULL) if (pst != NULL)
{ {
@ -356,7 +352,6 @@ psymbol_functions::find_pc_sect_compunit_symtab
int warn_if_readin) int warn_if_readin)
{ {
struct partial_symtab *ps = find_pc_sect_psymtab (objfile, struct partial_symtab *ps = find_pc_sect_psymtab (objfile,
m_partial_symtabs.get (),
pc, section, pc, section,
msymbol); msymbol);
if (ps != NULL) if (ps != NULL)
@ -1815,7 +1810,12 @@ maintenance_print_psymbols (const char *args, int from_tty)
if (!print_for_objfile) if (!print_for_objfile)
continue; continue;
psymtab_storage *partial_symtabs = objfile->partial_symtabs.get (); psymbol_functions *psf
= dynamic_cast<psymbol_functions *> (objfile->qf.get ());
if (psf == nullptr)
continue;
psymtab_storage *partial_symtabs = psf->get_partial_symtabs ().get ();
if (address_arg != NULL) if (address_arg != NULL)
{ {
@ -1824,8 +1824,7 @@ maintenance_print_psymbols (const char *args, int from_tty)
/* We don't assume each pc has a unique objfile (this is for /* We don't assume each pc has a unique objfile (this is for
debugging). */ debugging). */
struct partial_symtab *ps struct partial_symtab *ps
= find_pc_sect_psymtab (objfile, partial_symtabs, pc, = psf->find_pc_sect_psymtab (objfile, pc, section, msymbol);
section, msymbol);
if (ps != NULL) if (ps != NULL)
{ {
if (!printed_objfile_header) if (!printed_objfile_header)
@ -1841,7 +1840,7 @@ maintenance_print_psymbols (const char *args, int from_tty)
} }
else else
{ {
for (partial_symtab *ps : require_partial_symbols (objfile)) for (partial_symtab *ps : psf->require_partial_symbols (objfile))
{ {
int print_for_source = 0; int print_for_source = 0;
@ -1905,7 +1904,11 @@ maintenance_info_psymtabs (const char *regexp, int from_tty)
actually find a symtab whose name matches. */ actually find a symtab whose name matches. */
int printed_objfile_start = 0; int printed_objfile_start = 0;
for (partial_symtab *psymtab : require_partial_symbols (objfile)) psymbol_functions *psf
= dynamic_cast<psymbol_functions *> (objfile->qf.get ());
if (psf == nullptr)
continue;
for (partial_symtab *psymtab : psf->require_partial_symbols (objfile))
{ {
QUIT; QUIT;
@ -2005,89 +2008,96 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
const struct block *b; const struct block *b;
for (objfile *objfile : current_program_space->objfiles ()) for (objfile *objfile : current_program_space->objfiles ())
for (partial_symtab *ps : require_partial_symbols (objfile)) {
{ psymbol_functions *psf
struct gdbarch *gdbarch = objfile->arch (); = dynamic_cast<psymbol_functions *> (objfile->qf.get ());
if (psf == nullptr)
continue;
/* We don't call psymtab_to_symtab here because that may cause symtab for (partial_symtab *ps : psf->require_partial_symbols (objfile))
expansion. When debugging a problem it helps if checkers leave {
things unchanged. */ struct gdbarch *gdbarch = objfile->arch ();
cust = ps->get_compunit_symtab (objfile);
/* First do some checks that don't require the associated symtab. */ /* We don't call psymtab_to_symtab here because that may cause symtab
if (ps->text_high (objfile) < ps->text_low (objfile)) expansion. When debugging a problem it helps if checkers leave
{ things unchanged. */
printf_filtered ("Psymtab "); cust = ps->get_compunit_symtab (objfile);
puts_filtered (ps->filename);
printf_filtered (" covers bad range ");
fputs_filtered (paddress (gdbarch, ps->text_low (objfile)),
gdb_stdout);
printf_filtered (" - ");
fputs_filtered (paddress (gdbarch, ps->text_high (objfile)),
gdb_stdout);
printf_filtered ("\n");
continue;
}
/* Now do checks requiring the associated symtab. */ /* First do some checks that don't require the associated symtab. */
if (cust == NULL) if (ps->text_high (objfile) < ps->text_low (objfile))
continue; {
bv = COMPUNIT_BLOCKVECTOR (cust); printf_filtered ("Psymtab ");
b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); puts_filtered (ps->filename);
for (partial_symbol *psym : ps->static_psymbols) printf_filtered (" covers bad range ");
{ fputs_filtered (paddress (gdbarch, ps->text_low (objfile)),
/* Skip symbols for inlined functions without address. These may gdb_stdout);
or may not have a match in the full symtab. */ printf_filtered (" - ");
if (psym->aclass == LOC_BLOCK fputs_filtered (paddress (gdbarch, ps->text_high (objfile)),
&& psym->ginfo.value.address == 0) gdb_stdout);
printf_filtered ("\n");
continue; continue;
}
sym = block_lookup_symbol (b, psym->ginfo.search_name (), /* Now do checks requiring the associated symtab. */
symbol_name_match_type::SEARCH_NAME, if (cust == NULL)
psym->domain); continue;
if (!sym) bv = COMPUNIT_BLOCKVECTOR (cust);
{ b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
printf_filtered ("Static symbol `"); for (partial_symbol *psym : ps->static_psymbols)
puts_filtered (psym->ginfo.linkage_name ()); {
printf_filtered ("' only found in "); /* Skip symbols for inlined functions without address. These may
puts_filtered (ps->filename); or may not have a match in the full symtab. */
printf_filtered (" psymtab\n"); if (psym->aclass == LOC_BLOCK
} && psym->ginfo.value.address == 0)
} continue;
b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
for (partial_symbol *psym : ps->global_psymbols) sym = block_lookup_symbol (b, psym->ginfo.search_name (),
{ symbol_name_match_type::SEARCH_NAME,
sym = block_lookup_symbol (b, psym->ginfo.search_name (), psym->domain);
symbol_name_match_type::SEARCH_NAME, if (!sym)
psym->domain); {
if (!sym) printf_filtered ("Static symbol `");
{ puts_filtered (psym->ginfo.linkage_name ());
printf_filtered ("Global symbol `"); printf_filtered ("' only found in ");
puts_filtered (psym->ginfo.linkage_name ()); puts_filtered (ps->filename);
printf_filtered ("' only found in "); printf_filtered (" psymtab\n");
puts_filtered (ps->filename); }
printf_filtered (" psymtab\n"); }
} b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
} for (partial_symbol *psym : ps->global_psymbols)
if (ps->raw_text_high () != 0 {
&& (ps->text_low (objfile) < BLOCK_START (b) sym = block_lookup_symbol (b, psym->ginfo.search_name (),
|| ps->text_high (objfile) > BLOCK_END (b))) symbol_name_match_type::SEARCH_NAME,
{ psym->domain);
printf_filtered ("Psymtab "); if (!sym)
puts_filtered (ps->filename); {
printf_filtered (" covers "); printf_filtered ("Global symbol `");
fputs_filtered (paddress (gdbarch, ps->text_low (objfile)), puts_filtered (psym->ginfo.linkage_name ());
gdb_stdout); printf_filtered ("' only found in ");
printf_filtered (" - "); puts_filtered (ps->filename);
fputs_filtered (paddress (gdbarch, ps->text_high (objfile)), printf_filtered (" psymtab\n");
gdb_stdout); }
printf_filtered (" but symtab covers only "); }
fputs_filtered (paddress (gdbarch, BLOCK_START (b)), gdb_stdout); if (ps->raw_text_high () != 0
printf_filtered (" - "); && (ps->text_low (objfile) < BLOCK_START (b)
fputs_filtered (paddress (gdbarch, BLOCK_END (b)), gdb_stdout); || ps->text_high (objfile) > BLOCK_END (b)))
printf_filtered ("\n"); {
} printf_filtered ("Psymtab ");
} puts_filtered (ps->filename);
printf_filtered (" covers ");
fputs_filtered (paddress (gdbarch, ps->text_low (objfile)),
gdb_stdout);
printf_filtered (" - ");
fputs_filtered (paddress (gdbarch, ps->text_high (objfile)),
gdb_stdout);
printf_filtered (" but symtab covers only ");
fputs_filtered (paddress (gdbarch, BLOCK_START (b)), gdb_stdout);
printf_filtered (" - ");
fputs_filtered (paddress (gdbarch, BLOCK_END (b)), gdb_stdout);
printf_filtered ("\n");
}
}
}
} }
void _initialize_psymtab (); void _initialize_psymtab ();