[19/28] Remove objfile::expand_symtabs_for_function

Message ID 20250311-search-in-psyms-v1-19-d73d9be20983@tromey.com
State New
Headers
Series Search symbols via quick API |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Tom Tromey March 11, 2025, 2:12 p.m. UTC
  objfile::expand_symtabs_for_function only has a single caller now, so
it can be removed.  This also allows us to merge the expansion and
searching phases, as done in other patches in this series.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998
---
 gdb/cp-support.c    | 28 +++++++++++++++++-----------
 gdb/objfiles.h      |  4 ----
 gdb/symfile-debug.c | 22 ----------------------
 3 files changed, 17 insertions(+), 37 deletions(-)
  

Patch

diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 6dd364df1c4dc60a42c20482f195ee3f2350b5ca..22124d3f6091b53a7c1e100c4881027f716ce233 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1455,17 +1455,15 @@  add_symbol_overload_list_qualified (const char *func_name,
 				     ? selected_block->objfile ()
 				     : nullptr);
 
+  lookup_name_info base_lookup (func_name, symbol_name_match_type::FULL);
+  lookup_name_info lookup_name = base_lookup.make_ignore_params ();
+
   gdbarch_iterate_over_objfiles_in_search_order
     (current_objfile ? current_objfile->arch () : current_inferior ()->arch (),
-     [func_name, surrounding_static_block, &overload_list]
+     [func_name, surrounding_static_block, &overload_list, lookup_name]
      (struct objfile *obj)
        {
-	 /* Look through the partial symtabs for all symbols which
-	    begin by matching FUNC_NAME.  Make sure we read that
-	    symbol table in.  */
-	 obj->expand_symtabs_for_function (func_name);
-
-	 for (compunit_symtab *cust : obj->compunits ())
+	 auto callback = [&] (compunit_symtab *cust)
 	   {
 	     QUIT;
 	     const struct block *b = cust->blockvector ()->global_block ();
@@ -1473,11 +1471,19 @@  add_symbol_overload_list_qualified (const char *func_name,
 
 	     b = cust->blockvector ()->static_block ();
 	     /* Don't do this block twice.  */
-	     if (b == surrounding_static_block)
-	       continue;
+	     if (b != surrounding_static_block)
+	       add_symbol_overload_list_block (func_name, b, overload_list);
+	     return true;
+	   };
 
-	     add_symbol_overload_list_block (func_name, b, overload_list);
-	   }
+	 /* Look through the partial symtabs for all symbols which
+	    begin by matching FUNC_NAME.  Make sure we read that
+	    symbol table in.  */
+	 obj->expand_symtabs_matching (nullptr, &lookup_name,
+				       nullptr, callback,
+				       (SEARCH_GLOBAL_BLOCK
+					| SEARCH_STATIC_BLOCK),
+				       SEARCH_FUNCTION_DOMAIN);
 
 	 return 0;
        }, current_objfile);
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 05e1e01d6352f6c0295e71fd611d6d6a19853673..6e119a5071f3b7846e060e9e433ea4729a286f14 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -577,10 +577,6 @@  struct objfile : intrusive_list_node<objfile>
   /* See quick_symbol_functions.  */
   void dump ();
 
-  /* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that
-     the corresponding symbol tables are loaded.  */
-  void expand_symtabs_for_function (const char *func_name);
-
   /* See quick_symbol_functions.  */
   void expand_all_symtabs ();
 
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index dda3efe9db35fa9bded93edf77ded7a0250a96b2..24304a05d7d978058659950b16190e24e04d0da7 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -310,28 +310,6 @@  objfile::dump ()
     iter->dump (this);
 }
 
-void
-objfile::expand_symtabs_for_function (const char *func_name)
-{
-  if (debug_symfile)
-    gdb_printf (gdb_stdlog,
-		"qf->expand_symtabs_for_function (%s, \"%s\")\n",
-		objfile_debug_name (this), func_name);
-
-  lookup_name_info base_lookup (func_name, symbol_name_match_type::FULL);
-  lookup_name_info lookup_name = base_lookup.make_ignore_params ();
-
-  for (const auto &iter : qf)
-    iter->expand_symtabs_matching (this,
-				   nullptr,
-				   &lookup_name,
-				   nullptr,
-				   nullptr,
-				   (SEARCH_GLOBAL_BLOCK
-				    | SEARCH_STATIC_BLOCK),
-				   SEARCH_FUNCTION_DOMAIN);
-}
-
 void
 objfile::expand_all_symtabs ()
 {