aboutsummaryrefslogtreecommitdiff
path: root/gdb/progspace.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-11-01 16:42:29 -0600
committerTom Tromey <tom@tromey.com>2019-12-12 15:50:53 -0700
commit234529260a90b6ac6ed38ddac45d6ed15149e8f8 (patch)
treee071a1122c41679020c08c4e19bde65c1a949750 /gdb/progspace.c
parent7cac64af7bc6a7f7a86f90a1465f7c3d2b6f07e8 (diff)
downloadgdb-234529260a90b6ac6ed38ddac45d6ed15149e8f8.zip
gdb-234529260a90b6ac6ed38ddac45d6ed15149e8f8.tar.gz
gdb-234529260a90b6ac6ed38ddac45d6ed15149e8f8.tar.bz2
Introduce program_space::remove_objfile
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
Diffstat (limited to 'gdb/progspace.c')
-rw-r--r--gdb/progspace.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 5aa7a3d..e6c4f55 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -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. */