From 7cac64af7bc6a7f7a86f90a1465f7c3d2b6f07e8 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 1 Nov 2019 16:31:28 -0600 Subject: Introduce program_space::add_objfile This introduces a new method, program_space::add_objfile, that adds an objfile to the program space's list of objfiles. It also changes the obfile's constructor so that linking an objfile into this list is not done here. The former is an improvement because it makes more sense to treat the program space as a container holding objfiles -- so manipulation of the list belongs there. The latter is not strictly needed, but seemed better both because it is removing a global side effect from a constructor, and for symmetry reasons, as a subsequent patch will remove unlinking from the destructor. gdb/ChangeLog 2019-12-12 Tom Tromey * progspace.h (struct program_space) : Declare method. * progspace.c (program_space::add_objfile): New method. * objfiles.c (~objfile): Don't unlink objfile. (put_objfile_before): Remove. (add_separate_debug_objfile): Don't call put_objfile_before. (objfile::make): Call add_objfile. Set new_objfiles_available on the per-program-space data. Change-Id: I93e8525dda631cb89dcc2046a5c51c7c9f34ccfd --- gdb/progspace.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'gdb/progspace.c') diff --git a/gdb/progspace.c b/gdb/progspace.c index 366de54..5aa7a3d 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -153,6 +153,28 @@ program_space::~program_space () program_space_free_data (this); } +/* See progspace.h. */ + +void +program_space::add_objfile (struct objfile *objfile, struct objfile *before) +{ + for (struct objfile **objp = &objfiles_head; + *objp != NULL; + objp = &((*objp)->next)) + { + if (*objp == before) + { + objfile->next = *objp; + *objp = objfile; + return; + } + } + + internal_error (__FILE__, __LINE__, + _("put_objfile_before: before objfile not in list")); + +} + /* Copies program space SRC to DEST. Copies the main executable file, and the main symbol file. Returns DEST. */ -- cgit v1.1