]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Convert map_symbol_filenames to method
authorTom Tromey <tom@tromey.com>
Sat, 27 Sep 2025 21:11:13 +0000 (15:11 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 9 Oct 2025 21:29:23 +0000 (15:29 -0600)
This patch changes the free function map_symbol_filenames to be a
method of program_space.  This seems a bit cleaner, and also lets us
hoist a use of the global into the callers.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
gdb/progspace.c
gdb/progspace.h
gdb/symfile.c
gdb/symfile.h
gdb/symtab.c

index 6ee0134f20b822da13f0e64ec82a0c89942ef85d..4017d0f4f27baba8b1d2264cd9156898428dc26d 100644 (file)
@@ -160,6 +160,16 @@ program_space::iterate_over_objfiles_in_search_order
 
 /* See progspace.h.  */
 
+void
+program_space::map_symbol_filenames (symbol_filename_listener fun,
+                                    bool need_fullname)
+{
+  for (objfile &objfile : objfiles ())
+    objfile.map_symbol_filenames (fun, need_fullname);
+}
+
+/* See progspace.h.  */
+
 void
 program_space::add_objfile (std::unique_ptr<objfile> &&objfile,
                            struct objfile *before)
index 1cf60420f73938cd8d21e920029b8624fd32117a..498a5b460f12fb8341c1c2b605f09810227fc164 100644 (file)
@@ -24,6 +24,7 @@
 #include "solib.h"
 #include "target.h"
 #include "gdb_bfd.h"
+#include "quick-symbol.h"
 #include "registry.h"
 #include "gdbsupport/safe-iterator.h"
 #include "gdbsupport/intrusive_list.h"
@@ -224,6 +225,12 @@ struct program_space
     (iterate_over_objfiles_in_search_order_cb_ftype cb,
      objfile *current_objfile);
 
+  /* Wrapper around the quick_symbol_functions map_symbol_filenames
+     "method".  Map function FUN over every file, in every objfile in
+     this program space.  See
+     quick_symbol_functions.map_symbol_filenames for details.  */
+  void map_symbol_filenames (symbol_filename_listener fun, bool need_fullname);
+
   /* Add OBJFILE to the list of objfiles, putting it just before
      BEFORE.  If BEFORE is nullptr, it will go at the end of the
      list.  */
index 2a687c01ab406dd9b0087c364b91a7bb46c42936..b15782ea9de3fcab5294045eb798ecd61ec6c38a 100644 (file)
@@ -3755,17 +3755,6 @@ symfile_free_objfile (struct objfile *objfile)
   objfile->pspace ()->remove_target_sections (objfile);
 }
 
-/* Wrapper around the quick_symbol_functions map_symbol_filenames "method".
-   Map function FUN over every file.
-   See quick_symbol_functions.map_symbol_filenames for details.  */
-
-void
-map_symbol_filenames (symbol_filename_listener fun, bool need_fullname)
-{
-  for (objfile &objfile : current_program_space->objfiles ())
-    objfile.map_symbol_filenames (fun, need_fullname);
-}
-
 #if GDB_SELF_TEST
 
 namespace selftests {
index 06509a61d03fd955048d00d01827d54c85b8b7d6..7e7de3800d82a94d9829cb41ce2010d6bf027823 100644 (file)
@@ -345,8 +345,6 @@ symfile_segment_data_up get_symfile_segment_data (bfd *abfd);
 
 extern scoped_restore_tmpl<int> increment_reading_symtab (void);
 
-void map_symbol_filenames (symbol_filename_listener fun, bool need_fullname);
-
 /* Target-agnostic function to load the sections of an executable into memory.
 
    ARGS should be in the form "EXECUTABLE [OFFSET]", where OFFSET is an
index aef4842a7af38b2d3c3dea618efd3317a600af77..05a1fd0ba6856cb47755a15b30db685b497cac66 100644 (file)
@@ -4630,7 +4630,8 @@ info_sources_worker (struct ui_out *uiout,
   if (!group_by_objfile)
     {
       data.reset_output ();
-      map_symbol_filenames (data, true /*need_fullname*/);
+      current_program_space->map_symbol_filenames (data,
+                                                  true /*need_fullname*/);
     }
 }
 
@@ -6323,7 +6324,7 @@ make_source_files_completion_list (const char *text)
   datum.word = text;
   datum.text_len = text_len;
   datum.list = &list;
-  map_symbol_filenames (datum, false /*need_fullname*/);
+  current_program_space->map_symbol_filenames (datum, false /*need_fullname*/);
 
   return list;
 }