Allow multiple partial symbol readers per objfile

This patch finally changes gdb so that an objfile can have multiple
sources of partial symbols (or mixed partial symbols and other kinds
of indices).

This is done by having each symbol reader create its own
psymbol_functions object and add it to the 'qf' list in the objfile.

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

	* xcoffread.c (xcoff_initial_scan): Create partial symtabs.
	* symfile.c (syms_from_objfile_1, reread_symbols): Update.
	* psymtab.h (make_psymbol_functions): Don't declare.
	* psymtab.c (make_psymbol_functions): Remove.
	(maintenance_print_psymbols): Update.
	* psympriv.h (struct psymbol_functions): Add no-argument
	constructor.
	* objfiles.h (struct objfile) <reset_psymtabs>: Remove.
	<partial_symtabs>: Remove.
	* mdebugread.c (mdebug_build_psymtabs): Create partial symtabs.
	* elfread.c (read_partial_symbols): Update.
	(elf_symfile_read): Remove check for existing partial symbols.
	Don't clear "qf".
	* dwarf2/read.c (dwarf2_has_info): Remove check for existing
	partial symbols.
	(dwarf2_build_psymtabs): Add psymbol_functions parameter.  Create
	partial symtabs.
	* dwarf2/public.h (dwarf2_build_psymtabs): Add psymbol_functions
	parameter.
	* dbxread.c (dbx_symfile_read): Create partial symtabs.
	* ctfread.c (elfctf_build_psymtabs): Create partial symtabs.
This commit is contained in:
Tom Tromey
2021-03-20 17:23:40 -06:00
parent e11145903f
commit eb36a3eb2f
13 changed files with 67 additions and 61 deletions

View File

@@ -67,7 +67,7 @@ struct lazy_dwarf_reader : public psymbol_functions
void read_partial_symbols (struct objfile *objfile) override
{
if (dwarf2_has_info (objfile, nullptr))
dwarf2_build_psymtabs (objfile);
dwarf2_build_psymtabs (objfile, this);
}
};
@@ -1278,16 +1278,11 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
dw_index_kind index_kind;
/* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF
debug information present in OBJFILE. If there is such debug
info present never use an index. */
if (!objfile->has_partial_symbols ()
&& dwarf2_initialize_objfile (objfile, &index_kind))
if (dwarf2_initialize_objfile (objfile, &index_kind))
{
switch (index_kind)
{
case dw_index_kind::GDB_INDEX:
objfile->qf.clear ();
objfile->qf.push_front (make_dwarf_gdb_index ());
break;
case dw_index_kind::DEBUG_NAMES:
@@ -1297,15 +1292,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
}
}
else
{
/* It is ok to do this even if the stabs reader made some
partial symbols, because OBJF_PSYMTABS_READ has not been
set, and so our lazy reader function will still be called
when needed. */
objfile->qf.clear ();
objfile->qf.emplace_front
(new lazy_dwarf_reader (objfile->partial_symtabs));
}
objfile->qf.emplace_front (new lazy_dwarf_reader);
}
/* If the file has its own symbol tables it has no separate debug
info. `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to