Remove quick_symbol_functions::expand_symtabs_with_fullname
authorTom Tromey <tom@tromey.com>
Sat, 17 Apr 2021 15:35:04 +0000 (09:35 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 17 Apr 2021 15:35:06 +0000 (09:35 -0600)
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-04-17  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
gdb/dwarf2/read.c
gdb/objfiles.h
gdb/psympriv.h
gdb/psymtab.c
gdb/quick-symbol.h
gdb/symfile-debug.c

index 88e87905915a257619a815ff42663cb35dcf8a36..6de85cb7983612409678e066441cc5cdcdd308a1 100644 (file)
@@ -1,3 +1,20 @@
+2021-04-17  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.
+
 2021-04-17  Tom Tromey  <tom@tromey.com>
 
        * symfile-debug.c (objfile::expand_symtabs_for_function):
index 007b70ec32aea8f6958f9307a57a2e09cd645e61..6befb77a2b6d8ee602333f90dea31b5d5010d6c1 100644 (file)
@@ -2241,9 +2241,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;
@@ -3525,40 +3522,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,
index 64cfca41f156c97a813f35690355e15c105e5373..90ea49e7c9079695b791402e9d2b09c146e9b1d8 100644 (file)
@@ -613,7 +613,11 @@ public:
   /* 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.  */
index 4bd6decfaa45f5ff18614ebd04d2161849b6c6f6..a5395718b7a1297d182d18ff46d7c92357b8f265 100644 (file)
@@ -518,9 +518,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,
index 8afeeb39fb7c9461d717dad7452301c11cb9a6f2..7c73293ecf164a0a2e53c5138063a87f2e686aec 100644 (file)
@@ -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.  */
 
index 1aa02e9ff4ce4a5985b2006d4b502b572ff3aff0..d883d7b0c1b79745a4f9b0466464602e7c9f7f38 100644 (file)
@@ -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
index deabea4737c3ff92a96cd0235919220bf0bbd512..dd5a70b4356bbd361dd6aedfaf91269f938875b4 100644 (file)
@@ -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