Introduce program_space::remove_objfile
authorTom Tromey <tom@tromey.com>
Fri, 1 Nov 2019 22:42:29 +0000 (16:42 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 12 Dec 2019 22:50:53 +0000 (15:50 -0700)
This introduces a new method, program_space::remove_objfile, and
changes the objfile destructor not to unlink an objfile from the
program space's list.

This is cleaner because, like the previous patch, it treats the
program space more like a container for objfiles.  Also, this makes it
possible to keep an objfile alive even though it has been unlinked
from the program space's list, which is important for processing in a
worker thread.

gdb/ChangeLog
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.

Change-Id: I22f768827723dce21886fae9b3664532c8349e68

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

index 01636119d99f6e7980c379ecb88585dd3bbadaca..c6345c0d63fcafb5accee1087ce726571787417d 100644 (file)
@@ -1,3 +1,11 @@
+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
index b4fb6f2d18c4ec49ddfe6d0018e0d1905fb8ba34..34f6a29387e21d336115b955a9613a425d18a343 100644 (file)
@@ -456,27 +456,6 @@ separate_debug_iterator::operator++ ()
   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
@@ -519,6 +498,7 @@ objfile::make (bfd *bfd_, const char *name_, objfile_flags flags_,
 void
 objfile::unlink ()
 {
+  current_program_space->remove_objfile (this);
   delete this;
 }
 
@@ -609,13 +589,6 @@ objfile::~objfile ()
   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
index 5aa7a3d177e488a24c218e8ba617dbf78b84df62..e6c4f55c4e8b1c39dda555ff7a019d3ec84f4a89 100644 (file)
@@ -175,6 +175,31 @@ program_space::add_objfile (struct objfile *objfile, struct objfile *before)
 
 }
 
+/* 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.  */
 
index bb10c4bbd26c74dd001258ddea5804642e0f60cf..e1fcc3c68d2e00932aaa68bee77f8fc080db2271 100644 (file)
@@ -170,6 +170,8 @@ struct program_space
      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;
This page took 0.031579 seconds and 4 git commands to generate.