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:46 -0600 |
commit | eb36a3eb2f846b8d4b16c1bb114136961d0ce5bf (patch) | |
tree | 66db807b35c33f6ba4ab2406e19308ecd2ac4a29 /gdb/dwarf2 | |
parent | e11145903f25b7ac91dd12e6330df3faec0a3f1b (diff) | |
download | gdb-eb36a3eb2f846b8d4b16c1bb114136961d0ce5bf.zip gdb-eb36a3eb2f846b8d4b16c1bb114136961d0ce5bf.tar.gz gdb-eb36a3eb2f846b8d4b16c1bb114136961d0ce5bf.tar.bz2 |
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.
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r-- | gdb/dwarf2/public.h | 4 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 34 |
2 files changed, 23 insertions, 15 deletions
diff --git a/gdb/dwarf2/public.h b/gdb/dwarf2/public.h index 6b0fe08..e6653f4 100644 --- a/gdb/dwarf2/public.h +++ b/gdb/dwarf2/public.h @@ -40,7 +40,9 @@ enum class dw_index_kind extern bool dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind); -extern void dwarf2_build_psymtabs (struct objfile *); +struct psymbol_functions; +extern void dwarf2_build_psymtabs (struct objfile *, + psymbol_functions *psf = nullptr); extern void dwarf2_build_frame_info (struct objfile *); extern quick_symbol_functions_up make_dwarf_gdb_index (); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 9453848..acbc5fa 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1952,10 +1952,8 @@ dwarf2_has_info (struct objfile *objfile, dwarf2_per_bfd *per_bfd; /* We can share a "dwarf2_per_bfd" with other objfiles if the BFD - doesn't require relocations and if there aren't partial symbols - from some other reader. */ - if (!objfile->has_partial_symbols () - && !gdb_bfd_requires_relocations (objfile->obfd)) + doesn't require relocations. */ + if (!gdb_bfd_requires_relocations (objfile->obfd)) { /* See if one has been created for this BFD yet. */ per_bfd = dwarf2_per_bfd_bfd_data_key.get (objfile->obfd); @@ -6118,7 +6116,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind) /* Build a partial symbol table. */ void -dwarf2_build_psymtabs (struct objfile *objfile) +dwarf2_build_psymtabs (struct objfile *objfile, psymbol_functions *psf) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; @@ -6127,29 +6125,37 @@ dwarf2_build_psymtabs (struct objfile *objfile) { /* Partial symbols were already read, so now we can simply attach them. */ - objfile->partial_symtabs = per_bfd->partial_symtabs; - /* This is a temporary hack to ensure that the objfile and 'qf' - psymtabs are identical. */ - psymbol_functions *psf - = dynamic_cast<psymbol_functions *> (objfile->qf.front ().get ()); - gdb_assert (psf != nullptr); - psf->set_partial_symtabs (per_bfd->partial_symtabs); + if (psf == nullptr) + { + psf = new psymbol_functions (per_bfd->partial_symtabs); + objfile->qf.emplace_front (psf); + } + else + psf->set_partial_symtabs (per_bfd->partial_symtabs); per_objfile->resize_symtabs (); return; } + if (psf == nullptr) + { + psf = new psymbol_functions; + objfile->qf.emplace_front (psf); + } + const std::shared_ptr<psymtab_storage> &partial_symtabs + = psf->get_partial_symtabs (); + /* Set the local reference to partial symtabs, so that we don't try to read them again if reading another objfile with the same BFD. If we can't in fact share, this won't make a difference anyway as the dwarf2_per_bfd object won't be shared. */ - per_bfd->partial_symtabs = objfile->partial_symtabs; + per_bfd->partial_symtabs = partial_symtabs; try { /* This isn't really ideal: all the data we allocate on the objfile's obstack is still uselessly kept around. However, freeing it seems unsafe. */ - psymtab_discarder psymtabs (objfile->partial_symtabs.get ()); + psymtab_discarder psymtabs (partial_symtabs.get ()); dwarf2_build_psymtabs_hard (per_objfile); psymtabs.keep (); |