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,20 +285,19 @@ 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)
{ {
SCM item = ofscm_scm_from_objfile (objfile); SCM item = ofscm_scm_from_objfile (objfile);
result = scm_cons (item, result); result = scm_cons (item, result);
} }
} }
/* We don't really have to return the list in the same order as recorded /* We don't really have to return the list in the same order as recorded
internally, but for consistency we do. We still advertise that one internally, but for consistency we do. We still advertise that one

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,106 +2031,112 @@ 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;
/* We don't want to print anything for this objfile until we /* We don't want to print anything for this objfile until we
actually find a symtab whose name matches. */ actually find a symtab whose name matches. */
int printed_objfile_start = 0; int printed_objfile_start = 0;
ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, psymtab) ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, psymtab)
{ {
QUIT; QUIT;
if (! regexp if (! regexp
|| re_exec (psymtab->filename)) || re_exec (psymtab->filename))
{ {
if (! printed_objfile_start) if (! printed_objfile_start)
{ {
printf_filtered ("{ objfile %s ", objfile_name (objfile)); printf_filtered ("{ objfile %s ", objfile_name (objfile));
wrap_here (" "); wrap_here (" ");
printf_filtered ("((struct objfile *) %s)\n", printf_filtered ("((struct objfile *) %s)\n",
host_address_to_string (objfile)); host_address_to_string (objfile));
printed_objfile_start = 1; printed_objfile_start = 1;
} }
printf_filtered (" { psymtab %s ", psymtab->filename); printf_filtered (" { psymtab %s ", psymtab->filename);
wrap_here (" "); wrap_here (" ");
printf_filtered ("((struct partial_symtab *) %s)\n", printf_filtered ("((struct partial_symtab *) %s)\n",
host_address_to_string (psymtab)); host_address_to_string (psymtab));
printf_filtered (" readin %s\n", printf_filtered (" readin %s\n",
psymtab->readin ? "yes" : "no"); psymtab->readin ? "yes" : "no");
printf_filtered (" fullname %s\n", printf_filtered (" fullname %s\n",
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,
gdb_stdout); psymtab->text_low (objfile)),
printf_filtered (" -- "); gdb_stdout);
fputs_filtered (paddress (gdbarch, psymtab->text_high (objfile)), printf_filtered (" -- ");
gdb_stdout); fputs_filtered (paddress (gdbarch,
printf_filtered ("\n"); psymtab->text_high (objfile)),
printf_filtered (" psymtabs_addrmap_supported %s\n", gdb_stdout);
(psymtab->psymtabs_addrmap_supported printf_filtered ("\n");
? "yes" : "no")); printf_filtered (" psymtabs_addrmap_supported %s\n",
printf_filtered (" globals "); (psymtab->psymtabs_addrmap_supported
if (psymtab->n_global_syms) ? "yes" : "no"));
{ printf_filtered (" globals ");
auto p = &objfile->global_psymbols[psymtab->globals_offset]; if (psymtab->n_global_syms)
{
auto p
= &objfile->global_psymbols[psymtab->globals_offset];
printf_filtered ("(* (struct partial_symbol **) %s @ %d)\n", printf_filtered
host_address_to_string (p), ("(* (struct partial_symbol **) %s @ %d)\n",
psymtab->n_global_syms); host_address_to_string (p),
} psymtab->n_global_syms);
else }
printf_filtered ("(none)\n"); else
printf_filtered (" statics "); printf_filtered ("(none)\n");
if (psymtab->n_static_syms) printf_filtered (" statics ");
{ 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
host_address_to_string (p), ("(* (struct partial_symbol **) %s @ %d)\n",
psymtab->n_static_syms); host_address_to_string (p),
} psymtab->n_static_syms);
else }
printf_filtered ("(none)\n"); else
printf_filtered (" dependencies "); printf_filtered ("(none)\n");
if (psymtab->number_of_dependencies) printf_filtered (" dependencies ");
{ if (psymtab->number_of_dependencies)
int i; {
int i;
printf_filtered ("{\n"); printf_filtered ("{\n");
for (i = 0; i < psymtab->number_of_dependencies; i++) for (i = 0; i < psymtab->number_of_dependencies; i++)
{ {
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
printf_filtered (" psymtab %s " comma. */
"((struct partial_symtab *) %s)\n", printf_filtered (" psymtab %s "
dep->filename, "((struct partial_symtab *) %s)\n",
host_address_to_string (dep)); dep->filename,
} host_address_to_string (dep));
printf_filtered (" }\n"); }
} printf_filtered (" }\n");
else }
printf_filtered ("(none)\n"); else
printf_filtered (" }\n"); printf_filtered ("(none)\n");
} printf_filtered (" }\n");
} }
}
if (printed_objfile_start) if (printed_objfile_start)
printf_filtered ("}\n"); printf_filtered ("}\n");
} }
} }
/* Check consistency of currently expanded psymtabs vs symtabs. */ /* Check consistency of currently expanded psymtabs vs symtabs. */

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,13 +377,12 @@ 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);
} }
g_source_cache.clear (); g_source_cache.clear ();
last_source_visited = NULL; last_source_visited = NULL;

View file

@ -660,22 +660,21 @@ 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)
{ {
if (!symfile_debug_installed (objfile)) if (!symfile_debug_installed (objfile))
install_symfile_debug_logging (objfile); install_symfile_debug_logging (objfile);
} }
else else
{ {
if (symfile_debug_installed (objfile)) if (symfile_debug_installed (objfile))
uninstall_symfile_debug_logging (objfile); uninstall_symfile_debug_logging (objfile);
} }
} }
} }
static void static void

View file

@ -62,86 +62,84 @@ 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"),
objfile_name (objfile)); objfile_name (objfile));
print_bcache_statistics (psymbol_bcache_get_bcache (objfile->psymbol_cache), print_bcache_statistics (psymbol_bcache_get_bcache (objfile->psymbol_cache),
"partial symbol cache"); "partial symbol cache");
print_bcache_statistics (objfile->per_bfd->macro_cache, print_bcache_statistics (objfile->per_bfd->macro_cache,
"preprocessor macro cache"); "preprocessor macro cache");
print_bcache_statistics (objfile->per_bfd->filename_cache, print_bcache_statistics (objfile->per_bfd->filename_cache,
"file name cache"); "file name cache");
} }
} }
void 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));
if (OBJSTAT (objfile, n_stabs) > 0) if (OBJSTAT (objfile, n_stabs) > 0)
printf_filtered (_(" Number of \"stab\" symbols read: %d\n"), printf_filtered (_(" Number of \"stab\" symbols read: %d\n"),
OBJSTAT (objfile, n_stabs)); OBJSTAT (objfile, n_stabs));
if (objfile->per_bfd->n_minsyms > 0) if (objfile->per_bfd->n_minsyms > 0)
printf_filtered (_(" Number of \"minimal\" symbols read: %d\n"), printf_filtered (_(" Number of \"minimal\" symbols read: %d\n"),
objfile->per_bfd->n_minsyms); objfile->per_bfd->n_minsyms);
if (OBJSTAT (objfile, n_psyms) > 0) if (OBJSTAT (objfile, n_psyms) > 0)
printf_filtered (_(" Number of \"partial\" symbols read: %d\n"), printf_filtered (_(" Number of \"partial\" symbols read: %d\n"),
OBJSTAT (objfile, n_psyms)); OBJSTAT (objfile, n_psyms));
if (OBJSTAT (objfile, n_syms) > 0) if (OBJSTAT (objfile, n_syms) > 0)
printf_filtered (_(" Number of \"full\" symbols read: %d\n"), printf_filtered (_(" Number of \"full\" symbols read: %d\n"),
OBJSTAT (objfile, n_syms)); OBJSTAT (objfile, n_syms));
if (OBJSTAT (objfile, n_types) > 0) if (OBJSTAT (objfile, n_types) > 0)
printf_filtered (_(" Number of \"types\" defined: %d\n"), printf_filtered (_(" Number of \"types\" defined: %d\n"),
OBJSTAT (objfile, n_types)); OBJSTAT (objfile, n_types));
if (objfile->sf) if (objfile->sf)
objfile->sf->qf->print_stats (objfile); objfile->sf->qf->print_stats (objfile);
i = linetables = blockvectors = 0; i = linetables = blockvectors = 0;
ALL_OBJFILE_FILETABS (objfile, cu, s) ALL_OBJFILE_FILETABS (objfile, cu, s)
{ {
i++; i++;
if (SYMTAB_LINETABLE (s) != NULL) if (SYMTAB_LINETABLE (s) != NULL)
linetables++; linetables++;
} }
ALL_OBJFILE_COMPUNITS (objfile, cu) ALL_OBJFILE_COMPUNITS (objfile, cu)
blockvectors++; blockvectors++;
printf_filtered (_(" Number of symbol tables: %d\n"), i); printf_filtered (_(" Number of symbol tables: %d\n"), i);
printf_filtered (_(" Number of symbol tables with line tables: %d\n"), printf_filtered (_(" Number of symbol tables with line tables: %d\n"),
linetables); linetables);
printf_filtered (_(" Number of symbol tables with blockvectors: %d\n"), printf_filtered (_(" Number of symbol tables with blockvectors: %d\n"),
blockvectors); blockvectors);
if (OBJSTAT (objfile, sz_strtab) > 0) if (OBJSTAT (objfile, sz_strtab) > 0)
printf_filtered (_(" Space used by string tables: %d\n"), printf_filtered (_(" Space used by string tables: %d\n"),
OBJSTAT (objfile, sz_strtab)); OBJSTAT (objfile, sz_strtab));
printf_filtered (_(" Total memory used for objfile obstack: %s\n"), printf_filtered (_(" Total memory used for objfile obstack: %s\n"),
pulongest (obstack_memory_used (&objfile pulongest (obstack_memory_used (&objfile
->objfile_obstack))); ->objfile_obstack)));
printf_filtered (_(" Total memory used for BFD obstack: %s\n"), printf_filtered (_(" Total memory used for BFD obstack: %s\n"),
pulongest (obstack_memory_used (&objfile->per_bfd pulongest (obstack_memory_used (&objfile->per_bfd
->storage_obstack))); ->storage_obstack)));
printf_filtered (_(" Total memory used for psymbol cache: %d\n"), printf_filtered (_(" Total memory used for psymbol cache: %d\n"),
bcache_memory_used (psymbol_bcache_get_bcache bcache_memory_used (psymbol_bcache_get_bcache
(objfile->psymbol_cache))); (objfile->psymbol_cache)));
printf_filtered (_(" Total memory used for macro cache: %d\n"), printf_filtered (_(" Total memory used for macro cache: %d\n"),
bcache_memory_used (objfile->per_bfd->macro_cache)); bcache_memory_used (objfile->per_bfd->macro_cache));
printf_filtered (_(" Total memory used for file name cache: %d\n"), printf_filtered (_(" Total memory used for file name cache: %d\n"),
bcache_memory_used (objfile->per_bfd->filename_cache)); bcache_memory_used (objfile->per_bfd->filename_cache));
} }
} }
static void static void
@ -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,78 +776,78 @@ 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;
/* We don't want to print anything for this objfile until we /* We don't want to print anything for this objfile until we
actually find a symtab whose name matches. */ actually find a symtab whose name matches. */
int printed_objfile_start = 0; int printed_objfile_start = 0;
ALL_OBJFILE_COMPUNITS (objfile, cust) ALL_OBJFILE_COMPUNITS (objfile, cust)
{ {
int printed_compunit_symtab_start = 0; int printed_compunit_symtab_start = 0;
ALL_COMPUNIT_FILETABS (cust, symtab) ALL_COMPUNIT_FILETABS (cust, symtab)
{ {
QUIT; QUIT;
if (! regexp if (! regexp
|| re_exec (symtab_to_filename_for_display (symtab))) || re_exec (symtab_to_filename_for_display (symtab)))
{ {
if (! printed_objfile_start) if (! printed_objfile_start)
{ {
printf_filtered ("{ objfile %s ", objfile_name (objfile)); printf_filtered ("{ objfile %s ", objfile_name (objfile));
wrap_here (" "); wrap_here (" ");
printf_filtered ("((struct objfile *) %s)\n", printf_filtered ("((struct objfile *) %s)\n",
host_address_to_string (objfile)); host_address_to_string (objfile));
printed_objfile_start = 1; printed_objfile_start = 1;
} }
if (! printed_compunit_symtab_start) if (! printed_compunit_symtab_start)
{ {
printf_filtered (" { ((struct compunit_symtab *) %s)\n", printf_filtered (" { ((struct compunit_symtab *) %s)\n",
host_address_to_string (cust)); host_address_to_string (cust));
printf_filtered (" debugformat %s\n", printf_filtered (" debugformat %s\n",
COMPUNIT_DEBUGFORMAT (cust)); COMPUNIT_DEBUGFORMAT (cust));
printf_filtered (" producer %s\n", printf_filtered (" producer %s\n",
COMPUNIT_PRODUCER (cust) != NULL COMPUNIT_PRODUCER (cust) != NULL
? COMPUNIT_PRODUCER (cust) ? COMPUNIT_PRODUCER (cust)
: "(null)"); : "(null)");
printf_filtered (" dirname %s\n", printf_filtered (" dirname %s\n",
COMPUNIT_DIRNAME (cust) != NULL COMPUNIT_DIRNAME (cust) != NULL
? COMPUNIT_DIRNAME (cust) ? COMPUNIT_DIRNAME (cust)
: "(null)"); : "(null)");
printf_filtered (" blockvector" printf_filtered (" blockvector"
" ((struct blockvector *) %s)\n", " ((struct blockvector *) %s)\n",
host_address_to_string host_address_to_string
(COMPUNIT_BLOCKVECTOR (cust))); (COMPUNIT_BLOCKVECTOR (cust)));
printed_compunit_symtab_start = 1; printed_compunit_symtab_start = 1;
} }
printf_filtered ("\t{ symtab %s ", printf_filtered ("\t{ symtab %s ",
symtab_to_filename_for_display (symtab)); symtab_to_filename_for_display (symtab));
wrap_here (" "); wrap_here (" ");
printf_filtered ("((struct symtab *) %s)\n", printf_filtered ("((struct symtab *) %s)\n",
host_address_to_string (symtab)); host_address_to_string (symtab));
printf_filtered ("\t fullname %s\n", printf_filtered ("\t fullname %s\n",
symtab->fullname != NULL symtab->fullname != NULL
? symtab->fullname ? symtab->fullname
: "(null)"); : "(null)");
printf_filtered ("\t " printf_filtered ("\t "
"linetable ((struct linetable *) %s)\n", "linetable ((struct linetable *) %s)\n",
host_address_to_string (symtab->linetable)); host_address_to_string (symtab->linetable));
printf_filtered ("\t}\n"); printf_filtered ("\t}\n");
} }
} }
if (printed_compunit_symtab_start) if (printed_compunit_symtab_start)
printf_filtered (" }\n"); printf_filtered (" }\n");
} }
if (printed_objfile_start) if (printed_objfile_start)
printf_filtered ("}\n"); printf_filtered ("}\n");
} }
} }
/* Check consistency of symtabs. /* Check consistency of symtabs.
@ -866,49 +862,48 @@ 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;
/* We don't want to print anything for this objfile until we /* We don't want to print anything for this objfile until we
actually find something worth printing. */ actually find something worth printing. */
int printed_objfile_start = 0; int printed_objfile_start = 0;
ALL_OBJFILE_COMPUNITS (objfile, cust) ALL_OBJFILE_COMPUNITS (objfile, cust)
{ {
int found_something = 0; int found_something = 0;
struct symtab *symtab = compunit_primary_filetab (cust); struct symtab *symtab = compunit_primary_filetab (cust);
QUIT; QUIT;
if (COMPUNIT_BLOCKVECTOR (cust) == NULL) if (COMPUNIT_BLOCKVECTOR (cust) == NULL)
found_something = 1; found_something = 1;
/* Add more checks here. */ /* Add more checks here. */
if (found_something) if (found_something)
{ {
if (! printed_objfile_start) if (! printed_objfile_start)
{ {
printf_filtered ("{ objfile %s ", objfile_name (objfile)); printf_filtered ("{ objfile %s ", objfile_name (objfile));
wrap_here (" "); wrap_here (" ");
printf_filtered ("((struct objfile *) %s)\n", printf_filtered ("((struct objfile *) %s)\n",
host_address_to_string (objfile)); host_address_to_string (objfile));
printed_objfile_start = 1; printed_objfile_start = 1;
} }
printf_filtered (" { symtab %s\n", printf_filtered (" { symtab %s\n",
symtab_to_filename_for_display (symtab)); symtab_to_filename_for_display (symtab));
if (COMPUNIT_BLOCKVECTOR (cust) == NULL) if (COMPUNIT_BLOCKVECTOR (cust) == NULL)
printf_filtered (" NULL blockvector\n"); printf_filtered (" NULL blockvector\n");
printf_filtered (" }\n"); printf_filtered (" }\n");
} }
} }
if (printed_objfile_start) if (printed_objfile_start)
printf_filtered ("}\n"); printf_filtered ("}\n");
} }
} }
/* Expand all symbol tables whose name matches an optional regexp. */ /* Expand all symbol tables whose name matches an optional regexp. */
@ -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,28 +932,28 @@ 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)
{ {
objfile->sf->qf->expand_symtabs_matching objfile->sf->qf->expand_symtabs_matching
(objfile, (objfile,
[&] (const char *filename, bool basenames) [&] (const char *filename, bool basenames)
{ {
/* KISS: Only apply the regexp to the complete file name. */ /* KISS: Only apply the regexp to the complete file name. */
return (!basenames return (!basenames
&& (regexp == NULL || re_exec (filename))); && (regexp == NULL || re_exec (filename)));
}, },
lookup_name_info::match_any (), lookup_name_info::match_any (),
[] (const char *symname) [] (const char *symname)
{ {
/* Since we're not searching on symbols, just return true. */ /* Since we're not searching on symbols, just return true. */
return true; return true;
}, },
NULL, NULL,
ALL_DOMAIN); ALL_DOMAIN);
} }
} }
} }
@ -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,23 +1033,23 @@ 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;
ALL_OBJFILE_COMPUNITS (objfile, cust) ALL_OBJFILE_COMPUNITS (objfile, cust)
{ {
ALL_COMPUNIT_FILETABS (cust, symtab) ALL_COMPUNIT_FILETABS (cust, symtab)
{ {
QUIT; QUIT;
if (regexp == NULL if (regexp == NULL
|| re_exec (symtab_to_filename_for_display (symtab))) || re_exec (symtab_to_filename_for_display (symtab)))
maintenance_print_one_line_table (symtab, NULL); maintenance_print_one_line_table (symtab, NULL);
} }
} }
} }
} }