aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry.Neverov <dmitry.neverov@jetbrains.com>2024-05-06 17:09:17 +0200
committerTom Tromey <tromey@adacore.com>2024-05-17 08:02:29 -0600
commit3a0fae312983989a33608d924ff902d7b78e8ec1 (patch)
treeff58b3e1fcdba215e5b939a83aaa825843cc7d97
parent9ea82bfdd612081e21b38ea89d9bb0f836d92814 (diff)
downloadgdb-3a0fae312983989a33608d924ff902d7b78e8ec1.zip
gdb-3a0fae312983989a33608d924ff902d7b78e8ec1.tar.gz
gdb-3a0fae312983989a33608d924ff902d7b78e8ec1.tar.bz2
gdb/symtab: check name matches before expanding a CU
The added check fixes the case when an unqualified lookup name without template arguments causes expansion of many CUs which contain the name with template arguments. This is similar to what dw2_expand_symtabs_matching_symbol does before expanding the CU. In the referenced issue the lookup name was wxObjectDataPtr and many CUs had names like wxObjectDataPtr<wxBitmapBundleImpl>. This caused their expansion and the lookup took around a minute. The added check helps to avoid the expansion and makes the symbol lookup to return in a second or so. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30520
-rw-r--r--gdb/dwarf2/read.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 049ee4d..e2f010b 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16694,9 +16694,25 @@ cooked_index_functions::expand_symtabs_matching
= lookup_name_without_params.match_type ();
if ((match_type == symbol_name_match_type::FULL
|| (lang != language_ada
- && match_type == symbol_name_match_type::EXPRESSION))
- && parent != nullptr)
- continue;
+ && match_type == symbol_name_match_type::EXPRESSION)))
+ {
+ if (parent != nullptr)
+ continue;
+
+ if (entry->lang != language_unknown)
+ {
+ const language_defn *lang_def = language_def (entry->lang);
+ lookup_name_info last_segment_lookup_name (
+ last_name.data (), symbol_name_match_type::FULL,
+ false, true);
+ symbol_name_matcher_ftype *name_matcher
+ = lang_def->get_symbol_name_matcher
+ (last_segment_lookup_name);
+ if (!name_matcher (entry->canonical,
+ last_segment_lookup_name, nullptr))
+ continue;
+ }
+ }
}
else
{