Remove ALL_PSPACE_OBJFILES

This removes the ALL_PSPACE_OBJFILES macro in favor of ranged for
loops.

gdb/ChangeLog
2019-01-09  Tom Tromey  <tom@tromey.com>

	* probe.c (parse_probes_in_pspace): Use all_objfiles.
	* guile/scm-progspace.c (gdbscm_progspace_objfiles): Use
	all_objfiles.
	* objfiles.h (ALL_PSPACE_OBJFILES): Remove.
	* 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): Use
	all_objfiles.
	* source.c (forget_cached_source_info): Use all_objfiles.
	* symfile-debug.c (set_debug_symfile): Use all_objfiles.
	* elfread.c (elf_gnu_ifunc_resolve_by_cache)
	(elf_gnu_ifunc_resolve_by_got): Use all_objfiles.
	* objfiles.c (update_section_map): Use all_objfiles.
	(shared_objfile_contains_address_p): Likewise.
	* psymtab.c (maintenance_info_psymtabs): Use all_objfiles.
	* python/py-progspace.c (pspy_get_objfiles): Use all_objfiles.
This commit is contained in:
Tom Tromey 2018-11-23 11:58:27 -07:00
parent 217083254a
commit 99d89cdea6
11 changed files with 343 additions and 342 deletions

View file

@ -1,3 +1,23 @@
2019-01-09 Tom Tromey <tom@tromey.com>
* probe.c (parse_probes_in_pspace): Use all_objfiles.
* guile/scm-progspace.c (gdbscm_progspace_objfiles): Use
all_objfiles.
* objfiles.h (ALL_PSPACE_OBJFILES): Remove.
* 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): Use
all_objfiles.
* source.c (forget_cached_source_info): Use all_objfiles.
* symfile-debug.c (set_debug_symfile): Use all_objfiles.
* elfread.c (elf_gnu_ifunc_resolve_by_cache)
(elf_gnu_ifunc_resolve_by_got): Use all_objfiles.
* objfiles.c (update_section_map): Use all_objfiles.
(shared_objfile_contains_address_p): Likewise.
* psymtab.c (maintenance_info_psymtabs): Use all_objfiles.
* python/py-progspace.c (pspy_get_objfiles): Use all_objfiles.
2019-01-09 Tom Tromey <tom@tromey.com> 2019-01-09 Tom Tromey <tom@tromey.com>
* common/next-iterator.h: New file. * common/next-iterator.h: New file.

View file

@ -758,9 +758,7 @@ elf_gnu_ifunc_record_cache (const char *name, CORE_ADDR addr)
static int static int
elf_gnu_ifunc_resolve_by_cache (const char *name, CORE_ADDR *addr_p) elf_gnu_ifunc_resolve_by_cache (const char *name, CORE_ADDR *addr_p)
{ {
struct objfile *objfile; for (objfile *objfile : all_objfiles (current_program_space))
ALL_PSPACE_OBJFILES (current_program_space, objfile)
{ {
htab_t htab; htab_t htab;
struct elf_gnu_ifunc_cache *entry_p; struct elf_gnu_ifunc_cache *entry_p;
@ -800,13 +798,12 @@ static int
elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p) elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p)
{ {
char *name_got_plt; char *name_got_plt;
struct objfile *objfile;
const size_t got_suffix_len = strlen (SYMBOL_GOT_PLT_SUFFIX); const size_t got_suffix_len = strlen (SYMBOL_GOT_PLT_SUFFIX);
name_got_plt = (char *) alloca (strlen (name) + got_suffix_len + 1); name_got_plt = (char *) alloca (strlen (name) + got_suffix_len + 1);
sprintf (name_got_plt, "%s" SYMBOL_GOT_PLT_SUFFIX, name); sprintf (name_got_plt, "%s" SYMBOL_GOT_PLT_SUFFIX, name);
ALL_PSPACE_OBJFILES (current_program_space, objfile) for (objfile *objfile : all_objfiles (current_program_space))
{ {
bfd *obfd = objfile->obfd; bfd *obfd = objfile->obfd;
struct gdbarch *gdbarch = get_objfile_arch (objfile); struct gdbarch *gdbarch = get_objfile_arch (objfile);

View file

@ -285,12 +285,11 @@ gdbscm_progspace_objfiles (SCM self)
{ {
pspace_smob *p_smob pspace_smob *p_smob
= psscm_get_valid_pspace_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); = psscm_get_valid_pspace_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
struct objfile *objfile;
SCM result; SCM result;
result = SCM_EOL; result = SCM_EOL;
ALL_PSPACE_OBJFILES (p_smob->pspace, objfile) for (objfile *objfile : all_objfiles (p_smob->pspace))
{ {
if (objfile->separate_debug_objfile_backlink == NULL) if (objfile->separate_debug_objfile_backlink == NULL)
{ {

View file

@ -1322,7 +1322,6 @@ update_section_map (struct program_space *pspace,
struct objfile_pspace_info *pspace_info; struct objfile_pspace_info *pspace_info;
int alloc_size, map_size, i; int alloc_size, map_size, i;
struct obj_section *s, **map; struct obj_section *s, **map;
struct objfile *objfile;
pspace_info = get_objfile_pspace_data (pspace); pspace_info = get_objfile_pspace_data (pspace);
gdb_assert (pspace_info->section_map_dirty != 0 gdb_assert (pspace_info->section_map_dirty != 0
@ -1332,7 +1331,7 @@ update_section_map (struct program_space *pspace,
xfree (map); xfree (map);
alloc_size = 0; alloc_size = 0;
ALL_PSPACE_OBJFILES (pspace, objfile) for (objfile *objfile : all_objfiles (pspace))
ALL_OBJFILE_OSECTIONS (objfile, s) ALL_OBJFILE_OSECTIONS (objfile, s)
if (insert_section_p (objfile->obfd, s->the_bfd_section)) if (insert_section_p (objfile->obfd, s->the_bfd_section))
alloc_size += 1; alloc_size += 1;
@ -1348,7 +1347,7 @@ update_section_map (struct program_space *pspace,
map = XNEWVEC (struct obj_section *, alloc_size); map = XNEWVEC (struct obj_section *, alloc_size);
i = 0; i = 0;
ALL_PSPACE_OBJFILES (pspace, objfile) for (objfile *objfile : all_objfiles (pspace))
ALL_OBJFILE_OSECTIONS (objfile, s) ALL_OBJFILE_OSECTIONS (objfile, s)
if (insert_section_p (objfile->obfd, s->the_bfd_section)) if (insert_section_p (objfile->obfd, s->the_bfd_section))
map[i++] = s; map[i++] = s;
@ -1492,9 +1491,7 @@ int
shared_objfile_contains_address_p (struct program_space *pspace, shared_objfile_contains_address_p (struct program_space *pspace,
CORE_ADDR address) CORE_ADDR address)
{ {
struct objfile *objfile; for (objfile *objfile : all_objfiles (pspace))
ALL_PSPACE_OBJFILES (pspace, objfile)
{ {
if ((objfile->flags & OBJF_SHARED) != 0 if ((objfile->flags & OBJF_SHARED) != 0
&& is_addr_in_objfile (address, objfile)) && is_addr_in_objfile (address, objfile))

View file

@ -586,11 +586,6 @@ public:
ALL_OBJFILES_SAFE works even if you delete the objfile during the ALL_OBJFILES_SAFE works even if you delete the objfile during the
traversal. */ traversal. */
/* Traverse all object files in program space SS. */
#define ALL_PSPACE_OBJFILES(ss, obj) \
for ((obj) = ss->objfiles; (obj) != NULL; (obj) = (obj)->next)
#define ALL_OBJFILES(obj) \ #define ALL_OBJFILES(obj) \
for ((obj) = current_program_space->objfiles; \ for ((obj) = current_program_space->objfiles; \
(obj) != NULL; \ (obj) != NULL; \

View file

@ -73,9 +73,7 @@ parse_probes_in_pspace (const static_probe_ops *spops,
const char *name, const char *name,
std::vector<symtab_and_line> *result) std::vector<symtab_and_line> *result)
{ {
struct objfile *objfile; for (objfile *objfile : all_objfiles (search_pspace))
ALL_PSPACE_OBJFILES (search_pspace, objfile)
{ {
if (!objfile->sf || !objfile->sf->sym_probe_fns) if (!objfile->sf || !objfile->sf->sym_probe_fns)
continue; continue;

View file

@ -2031,13 +2031,12 @@ static void
maintenance_info_psymtabs (const char *regexp, int from_tty) maintenance_info_psymtabs (const char *regexp, int from_tty)
{ {
struct program_space *pspace; struct program_space *pspace;
struct objfile *objfile;
if (regexp) if (regexp)
re_comp (regexp); re_comp (regexp);
ALL_PSPACES (pspace) ALL_PSPACES (pspace)
ALL_PSPACE_OBJFILES (pspace, objfile) for (objfile *objfile : all_objfiles (pspace))
{ {
struct gdbarch *gdbarch = get_objfile_arch (objfile); struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct partial_symtab *psymtab; struct partial_symtab *psymtab;
@ -2073,10 +2072,12 @@ maintenance_info_psymtabs (const char *regexp, int from_tty)
psymtab->fullname psymtab->fullname
? psymtab->fullname : "(null)"); ? psymtab->fullname : "(null)");
printf_filtered (" text addresses "); printf_filtered (" text addresses ");
fputs_filtered (paddress (gdbarch, psymtab->text_low (objfile)), fputs_filtered (paddress (gdbarch,
psymtab->text_low (objfile)),
gdb_stdout); gdb_stdout);
printf_filtered (" -- "); printf_filtered (" -- ");
fputs_filtered (paddress (gdbarch, psymtab->text_high (objfile)), fputs_filtered (paddress (gdbarch,
psymtab->text_high (objfile)),
gdb_stdout); gdb_stdout);
printf_filtered ("\n"); printf_filtered ("\n");
printf_filtered (" psymtabs_addrmap_supported %s\n", printf_filtered (" psymtabs_addrmap_supported %s\n",
@ -2085,9 +2086,11 @@ maintenance_info_psymtabs (const char *regexp, int from_tty)
printf_filtered (" globals "); printf_filtered (" globals ");
if (psymtab->n_global_syms) if (psymtab->n_global_syms)
{ {
auto p = &objfile->global_psymbols[psymtab->globals_offset]; auto p
= &objfile->global_psymbols[psymtab->globals_offset];
printf_filtered ("(* (struct partial_symbol **) %s @ %d)\n", printf_filtered
("(* (struct partial_symbol **) %s @ %d)\n",
host_address_to_string (p), host_address_to_string (p),
psymtab->n_global_syms); psymtab->n_global_syms);
} }
@ -2096,9 +2099,11 @@ maintenance_info_psymtabs (const char *regexp, int from_tty)
printf_filtered (" statics "); printf_filtered (" statics ");
if (psymtab->n_static_syms) if (psymtab->n_static_syms)
{ {
auto p = &objfile->static_psymbols[psymtab->statics_offset]; auto p
= &objfile->static_psymbols[psymtab->statics_offset];
printf_filtered ("(* (struct partial_symbol **) %s @ %d)\n", printf_filtered
("(* (struct partial_symbol **) %s @ %d)\n",
host_address_to_string (p), host_address_to_string (p),
psymtab->n_static_syms); psymtab->n_static_syms);
} }
@ -2114,7 +2119,8 @@ maintenance_info_psymtabs (const char *regexp, int from_tty)
{ {
struct partial_symtab *dep = psymtab->dependencies[i]; struct partial_symtab *dep = psymtab->dependencies[i];
/* Note the string concatenation there --- no comma. */ /* Note the string concatenation there --- no
comma. */
printf_filtered (" psymtab %s " printf_filtered (" psymtab %s "
"((struct partial_symtab *) %s)\n", "((struct partial_symtab *) %s)\n",
dep->filename, dep->filename,

View file

@ -333,9 +333,7 @@ pspy_get_objfiles (PyObject *self_, PyObject *args)
if (self->pspace != NULL) if (self->pspace != NULL)
{ {
struct objfile *objf; for (objfile *objf : all_objfiles (self->pspace))
ALL_PSPACE_OBJFILES (self->pspace, objf)
{ {
gdbpy_ref<> item = objfile_to_objfile_object (objf); gdbpy_ref<> item = objfile_to_objfile_object (objf);

View file

@ -377,10 +377,9 @@ void
forget_cached_source_info (void) forget_cached_source_info (void)
{ {
struct program_space *pspace; struct program_space *pspace;
struct objfile *objfile;
ALL_PSPACES (pspace) ALL_PSPACES (pspace)
ALL_PSPACE_OBJFILES (pspace, objfile) for (objfile *objfile : all_objfiles (pspace))
{ {
forget_cached_source_info_for_objfile (objfile); forget_cached_source_info_for_objfile (objfile);
} }

View file

@ -660,10 +660,9 @@ static void
set_debug_symfile (const char *args, int from_tty, struct cmd_list_element *c) set_debug_symfile (const char *args, int from_tty, struct cmd_list_element *c)
{ {
struct program_space *pspace; struct program_space *pspace;
struct objfile *objfile;
ALL_PSPACES (pspace) ALL_PSPACES (pspace)
ALL_PSPACE_OBJFILES (pspace, objfile) for (objfile *objfile : all_objfiles (pspace))
{ {
if (debug_symfile) if (debug_symfile)
{ {

View file

@ -62,10 +62,9 @@ void
print_symbol_bcache_statistics (void) print_symbol_bcache_statistics (void)
{ {
struct program_space *pspace; struct program_space *pspace;
struct objfile *objfile;
ALL_PSPACES (pspace) ALL_PSPACES (pspace)
ALL_PSPACE_OBJFILES (pspace, objfile) for (objfile *objfile : all_objfiles (pspace))
{ {
QUIT; QUIT;
printf_filtered (_("Byte cache statistics for '%s':\n"), printf_filtered (_("Byte cache statistics for '%s':\n"),
@ -83,13 +82,12 @@ void
print_objfile_statistics (void) print_objfile_statistics (void)
{ {
struct program_space *pspace; struct program_space *pspace;
struct objfile *objfile;
struct compunit_symtab *cu; struct compunit_symtab *cu;
struct symtab *s; struct symtab *s;
int i, linetables, blockvectors; int i, linetables, blockvectors;
ALL_PSPACES (pspace) ALL_PSPACES (pspace)
ALL_PSPACE_OBJFILES (pspace, objfile) for (objfile *objfile : all_objfiles (pspace))
{ {
QUIT; QUIT;
printf_filtered (_("Statistics for '%s':\n"), objfile_name (objfile)); printf_filtered (_("Statistics for '%s':\n"), objfile_name (objfile));
@ -749,7 +747,6 @@ static void
maintenance_print_objfiles (const char *regexp, int from_tty) maintenance_print_objfiles (const char *regexp, int from_tty)
{ {
struct program_space *pspace; struct program_space *pspace;
struct objfile *objfile;
dont_repeat (); dont_repeat ();
@ -757,7 +754,7 @@ maintenance_print_objfiles (const char *regexp, int from_tty)
re_comp (regexp); re_comp (regexp);
ALL_PSPACES (pspace) ALL_PSPACES (pspace)
ALL_PSPACE_OBJFILES (pspace, objfile) for (objfile *objfile : all_objfiles (pspace))
{ {
QUIT; QUIT;
if (! regexp if (! regexp
@ -772,7 +769,6 @@ static void
maintenance_info_symtabs (const char *regexp, int from_tty) maintenance_info_symtabs (const char *regexp, int from_tty)
{ {
struct program_space *pspace; struct program_space *pspace;
struct objfile *objfile;
dont_repeat (); dont_repeat ();
@ -780,7 +776,7 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
re_comp (regexp); re_comp (regexp);
ALL_PSPACES (pspace) ALL_PSPACES (pspace)
ALL_PSPACE_OBJFILES (pspace, objfile) for (objfile *objfile : all_objfiles (pspace))
{ {
struct compunit_symtab *cust; struct compunit_symtab *cust;
struct symtab *symtab; struct symtab *symtab;
@ -866,10 +862,9 @@ static void
maintenance_check_symtabs (const char *ignore, int from_tty) maintenance_check_symtabs (const char *ignore, int from_tty)
{ {
struct program_space *pspace; struct program_space *pspace;
struct objfile *objfile;
ALL_PSPACES (pspace) ALL_PSPACES (pspace)
ALL_PSPACE_OBJFILES (pspace, objfile) for (objfile *objfile : all_objfiles (pspace))
{ {
struct compunit_symtab *cust; struct compunit_symtab *cust;
@ -917,7 +912,6 @@ static void
maintenance_expand_symtabs (const char *args, int from_tty) maintenance_expand_symtabs (const char *args, int from_tty)
{ {
struct program_space *pspace; struct program_space *pspace;
struct objfile *objfile;
char *regexp = NULL; char *regexp = NULL;
/* We use buildargv here so that we handle spaces in the regexp /* We use buildargv here so that we handle spaces in the regexp
@ -938,7 +932,7 @@ maintenance_expand_symtabs (const char *args, int from_tty)
re_comp (regexp); re_comp (regexp);
ALL_PSPACES (pspace) ALL_PSPACES (pspace)
ALL_PSPACE_OBJFILES (pspace, objfile) for (objfile *objfile : all_objfiles (pspace))
{ {
if (objfile->sf) if (objfile->sf)
{ {
@ -1032,7 +1026,6 @@ static void
maintenance_info_line_tables (const char *regexp, int from_tty) maintenance_info_line_tables (const char *regexp, int from_tty)
{ {
struct program_space *pspace; struct program_space *pspace;
struct objfile *objfile;
dont_repeat (); dont_repeat ();
@ -1040,7 +1033,7 @@ maintenance_info_line_tables (const char *regexp, int from_tty)
re_comp (regexp); re_comp (regexp);
ALL_PSPACES (pspace) ALL_PSPACES (pspace)
ALL_PSPACE_OBJFILES (pspace, objfile) for (objfile *objfile : all_objfiles (pspace))
{ {
struct compunit_symtab *cust; struct compunit_symtab *cust;
struct symtab *symtab; struct symtab *symtab;