[binutils-gdb] Hoist language-finding in expand_symtabs_matching

Tom Tromey tromey@sourceware.org
Thu Feb 20 01:25:12 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d08ab84d89035ed1ef489fc230756fa7779255a7

commit d08ab84d89035ed1ef489fc230756fa7779255a7
Author: Tom Tromey <tom@tromey.com>
Date:   Fri Feb 7 19:14:35 2025 -0700

    Hoist language-finding in expand_symtabs_matching
    
    Right now, cooked_index_functions::expand_symtabs_matching computes
    the language for each component of a split name, using the language of
    the corresponding entry.
    
    Instead, I think that we want to do all the comparisons using the
    final entry's language.  I don't think there's a way to trigger bad
    behavior here right now, but with another series I'm working on, we
    end up with some entries whose language can't reliably be determined;
    and in this case using the final entry's language avoids issues.
    
    I suspect we could also dispense with the per-segment name-matcher
    lookup as well.

Diff:
---
 gdb/dwarf2/read.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 821f761558c..5ff80262d03 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16130,6 +16130,7 @@ cooked_index_functions::expand_symtabs_matching
 	  bool found = true;
 
 	  const cooked_index_entry *parent = entry->get_parent ();
+	  const language_defn *lang_def = language_def (entry->lang);
 	  for (int i = name_vec.size () - 1; i > 0; --i)
 	    {
 	      /* If we ran out of entries, or if this segment doesn't
@@ -16141,7 +16142,6 @@ cooked_index_functions::expand_symtabs_matching
 		}
 	      if (parent->lang != language_unknown)
 		{
-		  const language_defn *lang_def = language_def (parent->lang);
 		  symbol_name_matcher_ftype *name_matcher
 		    = lang_def->get_symbol_name_matcher
 		      (segment_lookup_names[i-1]);
@@ -16172,7 +16172,6 @@ cooked_index_functions::expand_symtabs_matching
 
 		  if (entry->lang != language_unknown)
 		    {
-		      const language_defn *lang_def = language_def (entry->lang);
 		      symbol_name_matcher_ftype *name_matcher
 			= lang_def->get_symbol_name_matcher
 			  (segment_lookup_names.back ());


More information about the Gdb-cvs mailing list