summaryrefslogtreecommitdiff
path: root/gdb/progspace.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-05-08 14:21:22 -0600
committerTom Tromey <tromey@adacore.com>2020-05-08 14:21:22 -0600
commit94c93c35b50d0783fdfda277508d0ae6c3e372fb (patch)
treee7df63b540b33dc1f070c3394b1ad942121470eb /gdb/progspace.c
parenta1fd1ac9def557cbb7570cf90178a00cb26e7fef (diff)
downloadbinutils-gdb-94c93c35b50d0783fdfda277508d0ae6c3e372fb.tar.gz
Remove ALL_PSPACES
This removes the ALL_PSPACES macro. In this case it seemed cleanest to change how program spaces are stored -- instead of using a linked list, they are now stored in a std::vector. gdb/ChangeLog 2020-05-08 Tom Tromey <tom@tromey.com> * symtab.c (set_symbol_cache_size) (maintenance_print_symbol_cache, maintenance_flush_symbol_cache) (maintenance_print_symbol_cache_statistics): Update. * symmisc.c (print_symbol_bcache_statistics) (print_objfile_statistics, maintenance_print_objfiles) (maintenance_info_symtabs, maintenance_check_symtabs) (maintenance_expand_symtabs, maintenance_info_line_tables): Update. * symfile-debug.c (set_debug_symfile): Update. * source.c (forget_cached_source_info): Update. * python/python.c (gdbpy_progspaces): Update. * psymtab.c (maintenance_info_psymtabs): Update. * probe.c (parse_probes): Update. * linespec.c (iterate_over_all_matching_symtabs) (collect_symtabs_from_filename, search_minsyms_for_name): Update. * guile/scm-progspace.c (gdbscm_progspaces): Update. * exec.c (exec_target::close): Update. * ada-tasks.c (ada_tasks_new_objfile_observer): Update. * breakpoint.c (print_one_breakpoint_location) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint): Update. * progspace.c (program_spaces): Now a std::vector. (maybe_new_address_space): Update. (add_program_space): Remove. (program_space::program_space): Update. (remove_program_space): Update. (number_of_program_spaces): Remove. (print_program_space, update_address_spaces): Update. * progspace.h (program_spaces): Change type. (ALL_PSPACES): Remove. (number_of_program_spaces): Don't declare. (struct program_space) <next>: Remove.
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 252b62e02d7..a0b14a6d2eb 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 ();