[8/9] Remove quick_symbol_functions::expand_symtabs_with_fullname

Message ID 20210325170458.2351251-9-tom@tromey.com
State New
Headers show
Series
  • Simplify quick_symbol_functions
Related show

Commit Message

Tom Tromey March 25, 2021, 5:04 p.m.
This removes quick_symbol_functions::expand_symtabs_with_fullname,
replacing it with a call to expand_symtabs_matching.  As with the
previous patches, the implementation is consolidated in the objfile
method.

gdb/ChangeLog
2021-03-25  Tom Tromey  <tom@tromey.com>

	* quick-symbol.h (struct quick_symbol_functions)
	<expand_symtabs_with_fullname>: Remove.
	* psymtab.c (psymbol_functions::expand_symtabs_with_fullname):
	Remove.
	* psympriv.h (struct psymbol_functions)
	<expand_symtabs_with_fullname>: Remove.
	* dwarf2/read.c (struct dwarf2_base_index_functions)
	<expand_symtabs_with_fullname>: Remove.
	(dwarf2_base_index_functions::expand_symtabs_with_fullname):
	Remove.
	* objfiles.h (struct objfile) <expand_symtabs_with_fullname>:
	Update comment.
	* symfile-debug.c (objfile::expand_symtabs_with_fullname):
	Rewrite.
---
 gdb/ChangeLog       | 17 +++++++++++++++++
 gdb/dwarf2/read.c   | 37 -------------------------------------
 gdb/objfiles.h      |  6 +++++-
 gdb/psympriv.h      |  3 ---
 gdb/psymtab.c       | 22 ----------------------
 gdb/quick-symbol.h  |  8 --------
 gdb/symfile-debug.c | 16 +++++++++++++++-
 7 files changed, 37 insertions(+), 72 deletions(-)

-- 
2.26.2

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 09529cf535c..498e34b097d 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -2212,9 +2212,6 @@  struct dwarf2_base_index_functions : public quick_symbol_functions
 
   void expand_all_symtabs (struct objfile *objfile) override;
 
-  void expand_symtabs_with_fullname (struct objfile *objfile,
-				     const char *fullname) override;
-
   struct compunit_symtab *find_pc_sect_compunit_symtab
     (struct objfile *objfile, struct bound_minimal_symbol msymbol,
      CORE_ADDR pc, struct obj_section *section, int warn_if_readin) override;
@@ -3496,40 +3493,6 @@  dwarf2_base_index_functions::expand_all_symtabs (struct objfile *objfile)
     }
 }
 
-void
-dwarf2_base_index_functions::expand_symtabs_with_fullname
-     (struct objfile *objfile, const char *fullname)
-{
-  dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-
-  /* We don't need to consider type units here.
-     This is only called for examining code, e.g. expand_line_sal.
-     There can be an order of magnitude (or more) more type units
-     than comp units, and we avoid them if we can.  */
-
-  for (dwarf2_per_cu_data *per_cu : per_objfile->per_bfd->all_comp_units)
-    {
-      /* We only need to look at symtabs not already expanded.  */
-      if (per_objfile->symtab_set_p (per_cu))
-	continue;
-
-      quick_file_names *file_data = dw2_get_file_names (per_cu, per_objfile);
-      if (file_data == NULL)
-	continue;
-
-      for (int j = 0; j < file_data->num_file_names; ++j)
-	{
-	  const char *this_fullname = file_data->file_names[j];
-
-	  if (filename_cmp (this_fullname, fullname) == 0)
-	    {
-	      dw2_instantiate_symtab (per_cu, per_objfile, false);
-	      break;
-	    }
-	}
-    }
-}
-
 static bool
 dw2_expand_symtabs_matching_symbol
   (mapped_index_base &index,
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 4a170415ece..264e783c76e 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -585,7 +585,11 @@  struct objfile
   /* See quick_symbol_functions.  */
   void expand_all_symtabs ();
 
-  /* See quick_symbol_functions.  */
+  /* Read all symbol tables associated with OBJFILE which have
+     symtab_to_fullname equal to FULLNAME.
+     This is for the purposes of examining code only, e.g., expand_line_sal.
+     The routine may ignore debug info that is known to not be useful with
+     code, e.g., DW_TAG_type_unit for dwarf debug info.  */
   void expand_symtabs_with_fullname (const char *fullname);
 
   /* See quick_symbol_functions.  */
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index a400bc85f41..664f14b45d5 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -517,9 +517,6 @@  struct psymbol_functions : public quick_symbol_functions
 
   void expand_all_symtabs (struct objfile *objfile) override;
 
-  void expand_symtabs_with_fullname (struct objfile *objfile,
-				     const char *fullname) override;
-
   void map_matching_symbols
     (struct objfile *,
      const lookup_name_info &lookup_name,
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 8205dbc2923..f35a9f1dca2 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -902,28 +902,6 @@  psymbol_functions::expand_all_symtabs (struct objfile *objfile)
     psymtab_to_symtab (objfile, psymtab);
 }
 
-/* Psymtab version of expand_symtabs_with_fullname.  See its definition in
-   the definition of quick_symbol_functions in symfile.h.  */
-
-void
-psymbol_functions::expand_symtabs_with_fullname (struct objfile *objfile,
-						 const char *fullname)
-{
-  for (partial_symtab *p : require_partial_symbols (objfile))
-    {
-      /* Anonymous psymtabs don't have a name of a source file.  */
-      if (p->anonymous)
-	continue;
-
-      /* psymtab_to_fullname tries to open the file which is slow.
-	 Don't call it if we know the basenames don't match.  */
-      if ((basenames_may_differ
-	   || filename_cmp (lbasename (fullname), lbasename (p->filename)) == 0)
-	  && filename_cmp (fullname, psymtab_to_fullname (p)) == 0)
-	psymtab_to_symtab (objfile, p);
-    }
-}
-
 /* Psymtab version of map_symbol_filenames.  See its definition in
    the definition of quick_symbol_functions in symfile.h.  */
 
diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h
index 50bcf397e2e..064922a3b66 100644
--- a/gdb/quick-symbol.h
+++ b/gdb/quick-symbol.h
@@ -119,14 +119,6 @@  struct quick_symbol_functions
   /* Read all symbol tables associated with OBJFILE.  */
   virtual void expand_all_symtabs (struct objfile *objfile) = 0;
 
-  /* Read all symbol tables associated with OBJFILE which have
-     symtab_to_fullname equal to FULLNAME.
-     This is for the purposes of examining code only, e.g., expand_line_sal.
-     The routine may ignore debug info that is known to not be useful with
-     code, e.g., DW_TAG_type_unit for dwarf debug info.  */
-  virtual void expand_symtabs_with_fullname (struct objfile *objfile,
-					     const char *fullname) = 0;
-
   /* Find global or static symbols in all tables that are in DOMAIN
      and for which MATCH (symbol name, NAME) == 0, passing each to 
      CALLBACK, reading in partial symbol tables as needed.  Look
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 97e806b659f..7addb85453f 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -334,8 +334,22 @@  objfile::expand_symtabs_with_fullname (const char *fullname)
 		      "qf->expand_symtabs_with_fullname (%s, \"%s\")\n",
 		      objfile_debug_name (this), fullname);
 
+  const char *basename = lbasename (fullname);
+  auto file_matcher = [&] (const char *filename, bool basenames)
+  {
+    return filename_cmp (basenames ? basename : fullname, filename) == 0;
+  };
+
   for (const auto &iter : qf)
-    iter->expand_symtabs_with_fullname (this, fullname);
+    iter->expand_symtabs_matching (this,
+				   file_matcher,
+				   nullptr,
+				   nullptr,
+				   nullptr,
+				   (SEARCH_GLOBAL_BLOCK
+				    | SEARCH_STATIC_BLOCK),
+				   UNDEF_DOMAIN,
+				   ALL_DOMAIN);
 }
 
 void