aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2024-12-07 16:26:06 -0700
committerTom Tromey <tom@tromey.com>2025-09-10 16:05:28 -0600
commitf88f9f42db8ff782758435214678ad87d3fc3a18 (patch)
tree26ba29f129c2e500b73cef8c0b802c6746c3e4e1 /gdb
parent29fa4279c2f1bc2e0ac7cf77a95cbc0d83dd3c4a (diff)
downloadbinutils-f88f9f42db8ff782758435214678ad87d3fc3a18.zip
binutils-f88f9f42db8ff782758435214678ad87d3fc3a18.tar.gz
binutils-f88f9f42db8ff782758435214678ad87d3fc3a18.tar.bz2
Have expand_symtabs_matching work for already-expanded CUs
Currently, gdb will search the already-expanded symtabs in one loop, and then also expand matching symtabs in another loop. However, this is somewhat inefficient -- when searching the already-expanded symtabs, all such symtabs are examined. However, the various "quick" implementations already know which subset of symtabs might have a match. This changes the contract of expand_symtabs_matching to also call the callback for an already-expanded symtab. With this change, and some subsequent enabling changes, the number of searched symtabs should sometimes be reduced. This also cuts down on the amount of redundant code. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30736 Acked-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/dwarf2/read.c44
-rw-r--r--gdb/psymtab.c3
2 files changed, 30 insertions, 17 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 2487aca..2bc9676 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1535,6 +1535,31 @@ struct readnow_functions : public dwarf2_base_index_functions
domain_search_flags domain,
expand_symtabs_lang_matcher lang_matcher) override
{
+ dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+ auto_bool_vector cus_to_skip;
+ dw_expand_symtabs_matching_file_matcher (per_objfile, cus_to_skip,
+ file_matcher);
+
+ for (const auto &per_cu : per_objfile->per_bfd->all_units)
+ {
+ QUIT;
+
+ /* Skip various types of unit that should not be searched
+ directly: partial units and dummy units. */
+ if (/* Note that we request the non-strict unit type here. If
+ there was an error while reading, like in
+ dw-form-strx-out-of-bounds.exp, then the unit type may
+ not be set. */
+ per_cu->unit_type (false) == DW_UT_partial
+ || per_cu->unit_type (false) == 0
+ || per_objfile->get_symtab (per_cu.get ()) == nullptr)
+ continue;
+ if (!dw2_expand_symtabs_matching_one (per_cu.get (), per_objfile,
+ cus_to_skip, file_matcher,
+ expansion_notify,
+ lang_matcher))
+ return false;
+ }
return true;
}
};
@@ -1992,13 +2017,15 @@ dw2_expand_symtabs_matching_one
return true;
}
- bool symtab_was_null = !per_objfile->symtab_set_p (per_cu);
compunit_symtab *symtab
= dw2_instantiate_symtab (per_cu, per_objfile, false);
gdb_assert (symtab != nullptr);
- if (expansion_notify != NULL && symtab_was_null)
- return expansion_notify (symtab);
+ if (expansion_notify != nullptr)
+ {
+ cus_to_skip.set (per_cu->index, true);
+ return expansion_notify (symtab);
+ }
return true;
}
@@ -2030,13 +2057,6 @@ dw_expand_symtabs_matching_file_matcher
continue;
}
- /* We only need to look at symtabs not already expanded. */
- if (per_objfile->symtab_set_p (per_cu.get ()))
- {
- cus_to_skip.set (per_cu->index, true);
- continue;
- }
-
if (per_cu->fnd != nullptr)
{
file_and_directory *fnd = per_cu->fnd.get ();
@@ -14675,10 +14695,6 @@ cooked_index_functions::expand_symtabs_matching
{
QUIT;
- /* No need to consider symbols from expanded CUs. */
- if (per_objfile->symtab_set_p (entry->per_cu))
- continue;
-
/* We don't need to consider symbols from some CUs. */
if (cus_to_skip.is_set (entry->per_cu->index))
continue;
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index c19e4f2..70a7ca4 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -914,9 +914,6 @@ psymbol_functions::expand_symtabs_matching
{
QUIT;
- if (ps->readin_p (objfile))
- continue;
-
if (file_matcher)
{
bool match;