diff options
author | Tom Tromey <tom@tromey.com> | 2021-03-20 17:23:40 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-03-20 17:23:44 -0600 |
commit | eb00e4686dd1a1530737e2de7eae971d61332da1 (patch) | |
tree | 72c57133482f5dbc22fe2d204357ab13c194bc06 /gdb/elfread.c | |
parent | b29b98cf8411ac136d17fc68236fc029447f1461 (diff) | |
download | gdb-eb00e4686dd1a1530737e2de7eae971d61332da1.zip gdb-eb00e4686dd1a1530737e2de7eae971d61332da1.tar.gz gdb-eb00e4686dd1a1530737e2de7eae971d61332da1.tar.bz2 |
Remove sym_fns::sym_read_psymbols
Partial symbols are read via the sym_fns::sym_read_psymbols function
pointer. In order to separate the partial symbols from the objfile,
this must instead be done via a virtual method on
quick_symbol_functions. This patch implements this change.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* xcoffread.c (xcoff_sym_fns): Update.
* symfile.h (struct sym_fns) <sym_read_psymbols>: Remove.
* symfile-debug.c (objfile::has_partial_symbols): Use
can_lazily_read_symbols.
(debug_sym_read_psymbols): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* quick-symbol.h (struct quick_symbol_functions)
<can_lazily_read_symbols, read_partial_symbols>: New methods.
* psymtab.c (require_partial_symbols): Use new 'qf' methods.
* mipsread.c (ecoff_sym_fns): Update.
* machoread.c (macho_sym_fns): Update.
* elfread.c (struct lazy_dwarf_reader): New.
(elf_symfile_read): Update.
(read_psyms): Now a method of lazy_dwarf_reader.
(elf_sym_fns): Update.
(elf_sym_fns_lazy_psyms): Remove.
* dbxread.c (aout_sym_fns): Update.
* coffread.c (coff_sym_fns): Update.
Diffstat (limited to 'gdb/elfread.c')
-rw-r--r-- | gdb/elfread.c | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/gdb/elfread.c b/gdb/elfread.c index 4ca1f4d..157a071 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -53,7 +53,24 @@ #include "debuginfod-support.h" #include "dwarf2/public.h" -/* Forward declarations. */ +/* A subclass of psymbol_functions that arranges to read the DWARF + partial symbols when needed. */ +struct lazy_dwarf_reader : public psymbol_functions +{ + using psymbol_functions::psymbol_functions; + + bool can_lazily_read_symbols () override + { + return true; + } + + void read_partial_symbols (struct objfile *objfile) override + { + if (dwarf2_has_info (objfile, nullptr)) + dwarf2_build_psymtabs (objfile); + } +}; + extern const struct sym_fns elf_sym_fns_lazy_psyms; /* The struct elfinfo is available only during ELF symbol table and @@ -1283,7 +1300,8 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) partial symbols, because OBJF_PSYMTABS_READ has not been set, and so our lazy reader function will still be called when needed. */ - objfile_set_sym_fns (objfile, &elf_sym_fns_lazy_psyms); + objfile->qf.reset + (new lazy_dwarf_reader (objfile->partial_symtabs)); } } /* If the file has its own symbol tables it has no separate debug @@ -1353,15 +1371,6 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) } } -/* Callback to lazily read psymtabs. */ - -static void -read_psyms (struct objfile *objfile) -{ - if (dwarf2_has_info (objfile, NULL)) - dwarf2_build_psymtabs (objfile); -} - /* Initialize anything that needs initializing when a completely new symbol file is specified (not just adding some symbols from another file, e.g. a shared library). */ @@ -1428,24 +1437,6 @@ static const struct sym_fns elf_sym_fns = elf_new_init, /* init anything gbl to entire symtab */ elf_symfile_init, /* read initial info, setup for sym_read() */ elf_symfile_read, /* read a symbol file into symtab */ - NULL, /* sym_read_psymbols */ - elf_symfile_finish, /* finished with file, cleanup */ - default_symfile_offsets, /* Translate ext. to int. relocation */ - elf_symfile_segments, /* Get segment information from a file. */ - NULL, - default_symfile_relocate, /* Relocate a debug section. */ - &elf_probe_fns, /* sym_probe_fns */ -}; - -/* The same as elf_sym_fns, but not registered and lazily reads - psymbols. */ - -const struct sym_fns elf_sym_fns_lazy_psyms = -{ - elf_new_init, /* init anything gbl to entire symtab */ - elf_symfile_init, /* read initial info, setup for sym_read() */ - elf_symfile_read, /* read a symbol file into symtab */ - read_psyms, /* sym_read_psymbols */ elf_symfile_finish, /* finished with file, cleanup */ default_symfile_offsets, /* Translate ext. to int. relocation */ elf_symfile_segments, /* Get segment information from a file. */ |