aboutsummaryrefslogtreecommitdiff
path: root/gdb/compile
diff options
context:
space:
mode:
authorMarkus Metzger <markus.t.metzger@intel.com>2022-04-11 15:12:33 +0200
committerMarkus Metzger <markus.t.metzger@intel.com>2022-10-18 14:16:09 +0200
commitfb4f3f38e98599690946cc24b09ae6883a36edb0 (patch)
tree2b74a5eb1369bcb534e05315a0324e845ea291ed /gdb/compile
parent2733d9d5d62c62023dc2d7a93fa5afa22f386ffd (diff)
downloadbinutils-fb4f3f38e98599690946cc24b09ae6883a36edb0.zip
binutils-fb4f3f38e98599690946cc24b09ae6883a36edb0.tar.gz
binutils-fb4f3f38e98599690946cc24b09ae6883a36edb0.tar.bz2
gdb, compile: unlink objfile stored in module
When cleaning up after a compile command, we iterate over all objfiles and unlink the first objfile with the same name as the one we compiled. Since we already store a pointer to that objfile in the module and use it to get the name we're comparing against, there's no reason to iterate, at all. We can simply use that objfile. This further avoids potential issues when an objfile with the same name is loaded into a different linker namespace.
Diffstat (limited to 'gdb/compile')
-rw-r--r--gdb/compile/compile-object-run.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c
index 6fcd10b..af761e8 100644
--- a/gdb/compile/compile-object-run.c
+++ b/gdb/compile/compile-object-run.c
@@ -79,21 +79,18 @@ do_module_cleanup (void *arg, int registers_valid)
}
}
+ objfile *objfile = data->module->objfile;
+ gdb_assert (objfile != nullptr);
+
/* We have to make a copy of the name so that we can unlink the
underlying file -- removing the objfile will cause the name to be
freed, so we can't simply keep a reference to it. */
- std::string objfile_name_s = objfile_name (data->module->objfile);
- for (objfile *objfile : current_program_space->objfiles ())
- if ((objfile->flags & OBJF_USERLOADED) == 0
- && objfile_name_s == objfile_name (objfile))
- {
- objfile->unlink ();
-
- /* It may be a bit too pervasive in this dummy_frame dtor callback. */
- clear_symtab_users (0);
-
- break;
- }
+ std::string objfile_name_s = objfile_name (objfile);
+
+ objfile->unlink ();
+
+ /* It may be a bit too pervasive in this dummy_frame dtor callback. */
+ clear_symtab_users (0);
/* Delete the .c file. */
unlink (data->module->source_file.c_str ());