[review] Move free_all_objfiles to program_space
Commit Message
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/500
......................................................................
Move free_all_objfiles to program_space
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.
2019-11-03 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
---
M gdb/ChangeLog
M gdb/objfiles.c
M gdb/objfiles.h
M gdb/progspace.c
M gdb/progspace.h
M gdb/symfile.c
6 files changed, 31 insertions(+), 18 deletions(-)
@@ -1,5 +1,14 @@
2019-11-03 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-11-03 Tom Tromey <tom@tromey.com>
+
* progspace.c (program_space::add_objfile)
(program_space::remove_objfile): Update.
(program_space::multi_objfile_p): Remove.
@@ -618,21 +618,6 @@
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);
-}
/* A helper function for objfile_relocate1 that relocates a single
symbol. */
@@ -662,8 +662,6 @@
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);
@@ -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>
@@ -157,6 +158,23 @@
/* 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)
{
if (before == nullptr)
@@ -179,6 +179,9 @@
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;
@@ -1251,7 +1251,7 @@
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)