Move free_all_objfiles to program_space
authorTom Tromey <tom@tromey.com>
Sat, 2 Nov 2019 03:02:38 +0000 (21:02 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 12 Dec 2019 22:50:56 +0000 (15:50 -0700)
This changes free_all_objfiles to be a method on program_space, in
line with the other changes to treat program_space as a container for
objfiles.

gdb/ChangeLog
2019-12-12  Tom Tromey  <tom@tromey.com>

* symfile.c (symbol_file_clear): Update.
* progspace.h (struct program_space) <free_all_objfiles>: Declare
method.
* progspace.c (program_space::free_all_objfiles): New method.
* objfiles.h (free_all_objfiles): Don't declare.
* objfiles.c (free_all_objfiles): Move to program_space.

Change-Id: I908b549d2981b6005f7ca181fc0e6d24fc8b7b6f

gdb/ChangeLog
gdb/objfiles.c
gdb/objfiles.h
gdb/progspace.c
gdb/progspace.h
gdb/symfile.c

index 9b96f3d8fd92cf1951233eb69fe90cf4cdf35169..9c1322d2a0da10e6907bcea8146a427702de0733 100644 (file)
@@ -1,3 +1,12 @@
+2019-12-12  Tom Tromey  <tom@tromey.com>
+
+       * symfile.c (symbol_file_clear): Update.
+       * progspace.h (struct program_space) <free_all_objfiles>: Declare
+       method.
+       * progspace.c (program_space::free_all_objfiles): New method.
+       * objfiles.h (free_all_objfiles): Don't declare.
+       * objfiles.c (free_all_objfiles): Move to program_space.
+
 2019-12-12  Tom Tromey  <tom@tromey.com>
 
        * progspace.c (program_space::add_objfile)
index 31265c1653d944e32c9a618faf7e97b22e9a4056..56854cc5c63bdf92de7263faad8f492970119134 100644 (file)
@@ -618,21 +618,6 @@ objfile::~objfile ()
   get_objfile_pspace_data (pspace)->section_map_dirty = 1;
 }
 
-/* Free all the object files at once and clean up their users.  */
-
-void
-free_all_objfiles (void)
-{
-  struct so_list *so;
-
-  /* Any objfile reference would become stale.  */
-  for (so = master_so_list (); so; so = so->next)
-    gdb_assert (so->objfile == NULL);
-
-  for (objfile *objfile : current_program_space->objfiles_safe ())
-    objfile->unlink ();
-  clear_symtab_users (0);
-}
 \f
 /* A helper function for objfile_relocate1 that relocates a single
    symbol.  */
index f9bf102bc80a354c433dff1d4068ce897db434dd..34240558da3d8823fd6206c356f0b8652a2b0cc3 100644 (file)
@@ -662,8 +662,6 @@ extern void build_objfile_section_table (struct objfile *);
 
 extern void free_objfile_separate_debug (struct objfile *);
 
-extern void free_all_objfiles (void);
-
 extern void objfile_relocate (struct objfile *, const struct section_offsets *);
 extern void objfile_rebase (struct objfile *, CORE_ADDR);
 
index d1bf0c6aba3dd5a546661da210101d05fa572f27..3cb0d4c61e3966eb571e18b92fdb7a0fa0c8906a 100644 (file)
@@ -23,6 +23,7 @@
 #include "arch-utils.h"
 #include "gdbcore.h"
 #include "solib.h"
+#include "solist.h"
 #include "gdbthread.h"
 #include "inferior.h"
 #include <algorithm>
@@ -156,6 +157,23 @@ program_space::~program_space ()
 
 /* See progspace.h.  */
 
+void
+program_space::free_all_objfiles ()
+{
+  struct so_list *so;
+
+  /* Any objfile reference would become stale.  */
+  for (so = master_so_list (); so; so = so->next)
+    gdb_assert (so->objfile == NULL);
+
+  while (!objfiles_list.empty ())
+    objfiles_list.front ()->unlink ();
+
+  clear_symtab_users (0);
+}
+
+/* See progspace.h.  */
+
 void
 program_space::add_objfile (struct objfile *objfile, struct objfile *before)
 {
index a731eb6e24de73461d14eeddfd9cc4078c0308fa..6945e38eb921f41353a7699b386d2aaddb317a95 100644 (file)
@@ -179,6 +179,9 @@ struct program_space
     return objfiles_list.size () > 1;
   }
 
+  /* Free all the objfiles associated with this program space.  */
+  void free_all_objfiles ();
+
 
   /* Pointer to next in linked list.  */
   struct program_space *next = NULL;
index 965237191ad197e8c173f07c62c052ead83b95df..8852e2893a4f5657cdb5ea034020da2fbb564c7c 100644 (file)
@@ -1251,7 +1251,7 @@ symbol_file_clear (int from_tty)
      objfiles get stale by free_all_objfiles.  */
   no_shared_libraries (NULL, from_tty);
 
-  free_all_objfiles ();
+  current_program_space->free_all_objfiles ();
 
   gdb_assert (symfile_objfile == NULL);
   if (from_tty)
This page took 0.035061 seconds and 4 git commands to generate.