diff options
author | Tom Tromey <tromey@redhat.com> | 2013-10-15 11:50:58 -0600 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2014-02-26 12:11:18 -0700 |
commit | 5f6cac4085c95c5339b9549dc06d4f9184184fa6 (patch) | |
tree | e37ad03a89a177fcc90dca01ec5a38e73840a926 /gdb/elfread.c | |
parent | 2750ef27997b6114da090a25a314396eaf85a87a (diff) | |
download | gdb-5f6cac4085c95c5339b9549dc06d4f9184184fa6.zip gdb-5f6cac4085c95c5339b9549dc06d4f9184184fa6.tar.gz gdb-5f6cac4085c95c5339b9549dc06d4f9184184fa6.tar.bz2 |
add short-circuit logic to elfread.c
If minimal symbols have already been read into a per-BFD object, then
a symbol reader can skip re-reading them. This changes the ELF reader
to do so.
We only skip the work if the file is ELF+DWARF. If it has stabs or
mdebug sections, then I think extra information is computed during the
minsym creation pass; and so we must still repeat it. Eventually even
this will go away, once all symbol types have switched to being
progspace-independent. In the meantime this has no negative effect --
it is just a missing optimization for a small set of users.
This change also required a somewhat non-obvious change to the OBJSTAT
accounting code. If a symbol reader skips re-reading minimal symbols,
then the corresponding OBJSTAT will not be updated. This leads to a
test failure in gdb.base/maint.exp.
To fix this, I've moved the needed stat field out of objfile and into
the per-BFD object.
2014-02-26 Tom Tromey <tromey@redhat.com>
* elfread.c (elf_read_minimal_symbols): Return early if
minimal symbols have already been read. Add "ei" parameter.
(elf_symfile_read): Call elf_read_minimal_symbols earlier.
* minsyms.c (prim_record_minimal_symbol_full): Update.
* objfiles.h (struct objstats) <n_minsyms>: Move...
(struct objfile_per_bfd_storage) <n_minsyms>: ... here.
* symmisc.c (print_objfile_statistics): Update.
Diffstat (limited to 'gdb/elfread.c')
-rw-r--r-- | gdb/elfread.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/gdb/elfread.c b/gdb/elfread.c index 3aec352..88fb018 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1084,7 +1084,8 @@ elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b) symbols. */ static void -elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags) +elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, + const struct elfinfo *ei) { bfd *synth_abfd, *abfd = objfile->obfd; struct cleanup *back_to; @@ -1100,6 +1101,21 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags) objfile_name (objfile)); } + /* If we already have minsyms, then we can skip some work here. + However, if there were stabs or mdebug sections, we go ahead and + redo all the work anyway, because the psym readers for those + kinds of debuginfo need extra information found here. This can + go away once all types of symbols are in the per-BFD object. */ + if (objfile->per_bfd->minsyms_read + && ei->stabsect == NULL + && ei->mdebugsect == NULL) + { + if (symtab_create_debug) + fprintf_unfiltered (gdb_stdlog, + "... minimal symbols previously read\n"); + return; + } + init_minimal_symbol_collection (); back_to = make_cleanup_discard_minimal_symbols (); @@ -1242,16 +1258,11 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags) bfd *abfd = objfile->obfd; struct elfinfo ei; - elf_read_minimal_symbols (objfile, symfile_flags); - memset ((char *) &ei, 0, sizeof (ei)); - - /* Now process debugging information, which is contained in - special ELF sections. */ - - /* We first have to find them... */ bfd_map_over_sections (abfd, elf_locate_sections, (void *) & ei); + elf_read_minimal_symbols (objfile, symfile_flags, &ei); + /* ELF debugging information is inserted into the psymtab in the order of least informative first - most informative last. Since the psymtab table is searched `most recent insertion first' this |