]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/symtab] Handle interesting_symbols in read_file_scope
authorTom de Vries <tdevries@suse.de>
Mon, 21 Jun 2021 13:50:51 +0000 (15:50 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 24 Jun 2021 15:44:36 +0000 (17:44 +0200)
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
...

gdb/dwarf2/read.c

index dc59ead86bc58ee8a4f9bb14a6c06abb50489e64..6c0dc604ad56286560c6115dc2e522ddc00f488c 100644 (file)
@@ -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;