+2019-12-12 Tom Tromey <tom@tromey.com>
+
+ * progspace.h (struct program_space) <remove_objfile>: Declare.
+ * progspace.c (program_space::remove_objfile): New method.
+ * objfiles.c (unlink_objfile): Remove.
+ (objfile::unlink): Call remove_objfile.
+ (objfile): Don't call unlink_objfile.
+
2019-12-12 Tom Tromey <tom@tromey.com>
* progspace.h (struct program_space) <add_objfile>: Declare
return *this;
}
-/* Unlink OBJFILE from the list of known objfiles. */
-
-static void
-unlink_objfile (struct objfile *objfile)
-{
- struct objfile **objpp;
-
- for (objpp = &object_files; *objpp != NULL; objpp = &((*objpp)->next))
- {
- if (*objpp == objfile)
- {
- *objpp = (*objpp)->next;
- objfile->next = NULL;
- return;
- }
- }
-
- internal_error (__FILE__, __LINE__,
- _("unlink_objfile: objfile already unlinked"));
-}
-
/* Add OBJFILE as a separate debug objfile of PARENT. */
static void
void
objfile::unlink ()
{
+ current_program_space->remove_objfile (this);
delete this;
}
else
delete per_bfd;
- /* Remove it from the chain of all objfiles. */
-
- unlink_objfile (this);
-
- if (this == symfile_objfile)
- symfile_objfile = NULL;
-
/* Before the symbol table code was redone to make it easier to
selectively load and remove information particular to a specific
linkage unit, gdb used to do these things whenever the monolithic
}
+/* See progspace.h. */
+
+void
+program_space::remove_objfile (struct objfile *objfile)
+{
+ struct objfile **objpp;
+
+ for (objpp = &object_files; *objpp != NULL; objpp = &((*objpp)->next))
+ {
+ if (*objpp == objfile)
+ {
+ *objpp = (*objpp)->next;
+ objfile->next = NULL;
+
+ if (objfile == symfile_object_file)
+ symfile_object_file = NULL;
+
+ return;
+ }
+ }
+
+ internal_error (__FILE__, __LINE__,
+ _("remove_objfile: objfile already unlinked"));
+}
+
/* Copies program space SRC to DEST. Copies the main executable file,
and the main symbol file. Returns DEST. */
list. */
void add_objfile (struct objfile *objfile, struct objfile *before);
+ /* Remove OBJFILE from the list of objfiles. */
+ void remove_objfile (struct objfile *objfile);
/* Pointer to next in linked list. */
struct program_space *next = NULL;