/* Program and address space management, for GDB, the GNU debugger.
- Copyright (C) 2009-2020 Free Software Foundation, Inc.
+ Copyright (C) 2009-2021 Free Software Foundation, Inc.
This file is part of GDB.
#include <algorithm>
/* The last program space number assigned. */
-int last_program_space_num = 0;
+static int last_program_space_num = 0;
/* The head of the program spaces list. */
std::vector<struct program_space *> program_spaces;
breakpoint_program_space_exit (this);
no_shared_libraries (NULL, 0);
- exec_close ();
free_all_objfiles ();
/* Defer breakpoint re-set because we don't want to create new
locations for this pspace which we're tearing down. */
clear_symtab_users (SYMFILE_DEFER_BP_RESET);
if (!gdbarch_has_shared_address_space (target_gdbarch ()))
free_address_space (this->aspace);
- clear_program_space_solib_cache (this);
/* Discard any data modules have associated with the PSPACE. */
program_space_free_data (this);
}
/* See progspace.h. */
-next_adapter<struct so_list>
-program_space::solibs () const
+void
+program_space::exec_close ()
{
- return next_adapter<struct so_list> (this->so_list);
+ if (ebfd != nullptr)
+ {
+ /* Removing target sections may close the exec_ops target.
+ Clear ebfd before doing so to prevent recursion. */
+ ebfd.reset (nullptr);
+ ebfd_mtime = 0;
+
+ remove_target_sections (&ebfd);
+
+ exec_filename.reset (nullptr);
+ }
}
/* Copies program space SRC to DEST. Copies the main executable file,
/* Returns true iff there's no inferior bound to PSPACE. */
-int
-program_space_empty_p (struct program_space *pspace)
+bool
+program_space::empty ()
{
- if (find_inferior_for_program_space (pspace) != NULL)
- return 0;
-
- return 1;
+ return find_inferior_for_program_space (this) == nullptr;
}
/* Prints the list of program spaces and their details on UIOUT. If
update_address_spaces (void)
{
int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch ());
- struct inferior *inf;
init_address_spaces ();
pspace->aspace = new_address_space ();
}
- for (inf = inferior_list; inf; inf = inf->next)
+ for (inferior *inf : all_inferiors ())
if (gdbarch_has_global_solist (target_gdbarch ()))
inf->aspace = maybe_new_address_space ();
else
/* See progspace.h. */
void
-clear_program_space_solib_cache (struct program_space *pspace)
+program_space::clear_solib_cache ()
{
- pspace->added_solibs.clear ();
- pspace->deleted_solibs.clear ();
+ added_solibs.clear ();
+ deleted_solibs.clear ();
}
\f
_initialize_foo routines may need to install their per-pspace
data keys. We can only allocate a progspace when all those
modules have done that. Do this before
- initialize_current_architecture, because that accesses exec_bfd,
- which in turn dereferences current_program_space. */
+ initialize_current_architecture, because that accesses the ebfd
+ of current_program_space. */
current_program_space = new program_space (new_address_space ());
}