public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Dmitry Neverov <dmitry.neverov@jetbrains.com>
To: gdb-patches@sourceware.org
Cc: dmitry.neverov@jetbrains.com
Subject: [RFC][PR symtab/30520] gdb/symtab: check name matches before expanding a CU
Date: Tue, 16 Jan 2024 17:07:52 +0100	[thread overview]
Message-ID: <20240116160752.372201-1-dmitry.neverov@jetbrains.com> (raw)

From: "Dmitry.Neverov" <dmitry.neverov@jetbrains.com>

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
---
 gdb/dwarf2/read.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 1b5e566bb01..ccb32f152b0 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16882,9 +16882,24 @@ 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;
+
+		  enum language cu_lang = entry->per_cu->lang (false);
+		  if (cu_lang != language_unknown)
+		  {
+		    const language_defn *lang_def = language_def (cu_lang);
+		    symbol_name_matcher_ftype *name_matcher
+		      = lang_def->get_symbol_name_matcher
+		      (lookup_name_without_params);
+		    auto_obstack temp_storage;
+		    if (!name_matcher (entry->full_name(&temp_storage),
+				       lookup_name_without_params, nullptr))
+		      continue;
+		  }
+	      }
 	    }
 	  else
 	    {
-- 
2.39.2


             reply	other threads:[~2024-01-16 16:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16 16:07 Dmitry Neverov [this message]
2024-01-19 16:52 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240116160752.372201-1-dmitry.neverov@jetbrains.com \
    --to=dmitry.neverov@jetbrains.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).