From: Tom de Vries Date: Mon, 21 Jun 2021 13:50:51 +0000 (+0200) Subject: [gdb/symtab] Handle interesting_symbols in read_file_scope X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e8165209545eb07a7c2e5d96e31aa5b37e913c3b;p=thirdparty%2Fbinutils-gdb.git [gdb/symtab] Handle interesting_symbols in read_file_scope Use the interesting_symbols vector to filter the DIEs that we process when doing read_file_scope. At this point we start to get the benefit of lazy expansion: ... $ time gdb -q -iex "maint set lazy-expand-symtab 0" -batch \ lto/cc1 -ex "b do_rpo_vn" Breakpoint 1 at 0xd40e30: do_rpo_vn. (2 locations) real: 5.69 user: 5.47 system: 0.20 ... and with: ... $ time gdb -q -iex "maint set lazy-expand-symtab 1" -batch \ lto/cc1 -ex "b do_rpo_vn" Breakpoint 1 at 0xd40e30: do_rpo_vn. (2 locations) real: 2.75 user: 2.71 system: 0.10 ... --- diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index dc59ead86bc..6c0dc604ad5 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -10549,9 +10549,32 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu) handle_DW_AT_stmt_list (die, cu, fnd.comp_dir, lowpc); /* Process all dies in compilation unit. */ - for (child_die = die->child; child_die != nullptr && child_die->tag != 0; - child_die = child_die->sibling) - process_die (child_die, cu); + if (lazy_expand_symtab_p && cu->per_cu->interesting_symbols + && cu->per_cu->interesting_symbols->size () > 0) + { + auto interesting_symbol_it = cu->per_cu->interesting_symbols->cbegin (); + + for (child_die = die->child; child_die != nullptr && child_die->tag != 0; + child_die = child_die->sibling) + { + if (interesting_symbol_it == cu->per_cu->interesting_symbols->cend ()) + break; + + sect_offset interesting_symbol = *interesting_symbol_it; + + if (interesting_symbol > child_die->sect_off) + continue; + + gdb_assert (interesting_symbol == child_die->sect_off); + std::advance (interesting_symbol_it, 1); + + process_die (child_die, cu); + } + } + else + for (child_die = die->child; child_die != nullptr && child_die->tag != 0; + child_die = child_die->sibling) + process_die (child_die, cu); per_objfile->sym_cu = nullptr;