aboutsummaryrefslogtreecommitdiff
path: root/gdb/progspace.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/progspace.c')
-rw-r--r--gdb/progspace.c69
1 files changed, 12 insertions, 57 deletions
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 252b62e..a0b14a6 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -32,7 +32,7 @@
int last_program_space_num = 0;
/* The head of the program spaces list. */
-struct program_space *program_spaces;
+std::vector<struct program_space *> program_spaces;
/* Pointer to the current program space. */
struct program_space *current_program_space;
@@ -80,7 +80,7 @@ maybe_new_address_space (void)
if (shared_aspace)
{
/* Just return the first in the list. */
- return program_spaces->aspace;
+ return program_spaces[0]->aspace;
}
return new_address_space ();
@@ -109,44 +109,17 @@ init_address_spaces (void)
-/* Add a program space from the program spaces list. */
-
-static void
-add_program_space (program_space *pspace)
-{
- if (program_spaces == NULL)
- program_spaces = pspace;
- else
- {
- program_space *last;
-
- for (last = program_spaces; last->next != NULL; last = last->next)
- ;
- last->next = pspace;
- }
-}
-
/* Remove a program space from the program spaces list. */
static void
remove_program_space (program_space *pspace)
{
- program_space *ss, **ss_link;
gdb_assert (pspace != NULL);
- ss = program_spaces;
- ss_link = &program_spaces;
- while (ss != NULL)
- {
- if (ss == pspace)
- {
- *ss_link = ss->next;
- return;
- }
-
- ss_link = &ss->next;
- ss = *ss_link;
- }
+ auto iter = std::find (program_spaces.begin (), program_spaces.end (),
+ pspace);
+ gdb_assert (iter != program_spaces.end ());
+ program_spaces.erase (iter);
}
/* See progspace.h. */
@@ -157,7 +130,7 @@ program_space::program_space (address_space *aspace_)
{
program_space_alloc_data (this);
- add_program_space (this);
+ program_spaces.push_back (this);
}
/* See progspace.h. */
@@ -301,11 +274,10 @@ program_space_empty_p (struct program_space *pspace)
static void
print_program_space (struct ui_out *uiout, int requested)
{
- struct program_space *pspace;
int count = 0;
/* Compute number of pspaces we will print. */
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
{
if (requested != -1 && pspace->num != requested)
continue;
@@ -322,7 +294,7 @@ print_program_space (struct ui_out *uiout, int requested)
uiout->table_header (17, ui_left, "exec", "Executable");
uiout->table_body ();
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
{
struct inferior *inf;
int printed_header;
@@ -375,9 +347,7 @@ print_program_space (struct ui_out *uiout, int requested)
static int
valid_program_space_id (int num)
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
if (pspace->num == num)
return 1;
@@ -403,20 +373,6 @@ maintenance_info_program_spaces_command (const char *args, int from_tty)
print_program_space (current_uiout, requested);
}
-/* Simply returns the count of program spaces. */
-
-int
-number_of_program_spaces (void)
-{
- struct program_space *pspace;
- int count = 0;
-
- ALL_PSPACES (pspace)
- count++;
-
- return count;
-}
-
/* Update all program spaces matching to address spaces. The user may
have created several program spaces, and loaded executables into
them before connecting to the target interface that will create the
@@ -432,7 +388,6 @@ void
update_address_spaces (void)
{
int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch ());
- struct program_space *pspace;
struct inferior *inf;
init_address_spaces ();
@@ -442,11 +397,11 @@ update_address_spaces (void)
struct address_space *aspace = new_address_space ();
free_address_space (current_program_space->aspace);
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
pspace->aspace = aspace;
}
else
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
{
free_address_space (pspace->aspace);
pspace->aspace = new_address_space ();