+2020-10-29 Tom Tromey <tom@tromey.com>
+
+ * progspace.c (program_space::exec_close): New method, from
+ exec_close in exec.c.
+ * exec.c (exec_close): Move to progspace.c.
+ (exec_target::close, exec_file_attach): Update.
+ * progspace.h (struct program_space) <exec_close>: Declare
+ method.
+
2020-10-29 Tom Tromey <tom@tromey.com>
* progspace.h (struct program_space) <exec_filename>: Rename from
exec_file_attach (args, from_tty);
}
-/* Close and clear exec_bfd. If we end up with no target sections to
- read memory from, this unpushes the exec_ops target. */
-
-void
-exec_close (void)
-{
- if (exec_bfd)
- {
- bfd *abfd = exec_bfd;
-
- gdb_bfd_unref (abfd);
-
- /* Removing target sections may close the exec_ops target.
- Clear exec_bfd before doing so to prevent recursion. */
- exec_bfd = NULL;
- exec_bfd_mtime = 0;
-
- remove_target_sections (&exec_bfd);
-
- current_program_space->exec_filename.reset (nullptr);
- }
-}
-
/* This is the target_close implementation. Clears all target
sections and closes all executable bfds from all program spaces. */
{
set_current_program_space (ss);
current_target_sections->clear ();
- exec_close ();
+ ss->exec_close ();
}
}
gdb_bfd_ref_ptr exec_bfd_holder = gdb_bfd_ref_ptr::new_reference (exec_bfd);
/* Remove any previous exec file. */
- exec_close ();
+ current_program_space->exec_close ();
/* Now open and digest the file the user requested, if any. */
{
/* Make sure to close exec_bfd, or else "run" might try to use
it. */
- exec_close ();
+ current_program_space->exec_close ();
error (_("\"%ps\": not in executable format: %s"),
styled_string (file_name_style.style (), scratch_pathname),
gdb_bfd_errmsg (bfd_get_error (), matching).c_str ());
extern void print_section_info (target_section_table *table,
bfd *abfd);
-extern void exec_close (void);
-
/* Helper function that attempts to open the symbol file at EXEC_FILE_HOST.
If successful, it proceeds to add the symbol file as the main symbol file.
return next_adapter<struct so_list> (this->so_list);
}
+/* See progspace.h. */
+
+void
+program_space::exec_close ()
+{
+ if (ebfd)
+ {
+ gdb_bfd_unref (ebfd);
+
+ /* Removing target sections may close the exec_ops target.
+ Clear exec_bfd before doing so to prevent recursion. */
+ ebfd = NULL;
+ ebfd_mtime = 0;
+
+ remove_target_sections (&ebfd);
+
+ exec_filename.reset (nullptr);
+ }
+}
+
/* Copies program space SRC to DEST. Copies the main executable file,
and the main symbol file. Returns DEST. */
for (so_list *so : pspace->solibs ()) { ... } */
next_adapter<struct so_list> solibs () const;
+ /* Close and clear exec_bfd. If we end up with no target sections
+ to read memory from, this unpushes the exec_ops target. */
+ void exec_close ();
/* Unique ID number. */
int num = 0;