Remove ALL_OBJFILE_FILETABS

This removes ALL_OBJFILE_FILETABS, replacing its uses with ranged for
loops.

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

	* symmisc.c (print_objfile_statistics, dump_objfile)
	(maintenance_print_symbols): Use compunit_filetabs.
	* source.c (forget_cached_source_info_for_objfile): Use
	compunit_filetabs.
	* objfiles.h (ALL_OBJFILE_FILETABS): Remove.
	(ALL_FILETABS): Use compunit_filetabs.
	* objfiles.c (objfile_relocate1): Use compunit_filetabs.
	* coffread.c (coff_symtab_read): Use compunit_filetabs.
This commit is contained in:
Tom Tromey 2018-11-24 09:51:44 -07:00
parent 5accd1a07e
commit d5da8b3c0d
6 changed files with 81 additions and 56 deletions

View file

@ -1,3 +1,14 @@
2019-01-09 Tom Tromey <tom@tromey.com>
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_print_symbols): Use compunit_filetabs.
* source.c (forget_cached_source_info_for_objfile): Use
compunit_filetabs.
* objfiles.h (ALL_OBJFILE_FILETABS): Remove.
(ALL_FILETABS): Use compunit_filetabs.
* objfiles.c (objfile_relocate1): Use compunit_filetabs.
* coffread.c (coff_symtab_read): Use compunit_filetabs.
2019-01-09 Tom Tromey <tom@tromey.com> 2019-01-09 Tom Tromey <tom@tromey.com>
* symtab.h (ALL_COMPUNIT_FILETABS): Remove. * symtab.h (ALL_COMPUNIT_FILETABS): Remove.

View file

@ -1203,8 +1203,11 @@ coff_symtab_read (minimal_symbol_reader &reader,
/* Patch up any opaque types (references to types that are not defined /* Patch up any opaque types (references to types that are not defined
in the file where they are referenced, e.g. "struct foo *bar"). */ in the file where they are referenced, e.g. "struct foo *bar"). */
{ {
ALL_OBJFILE_FILETABS (objfile, cu, s) for (compunit_symtab *cu : objfile_compunits (objfile))
patch_opaque_types (s); {
for (symtab *s : compunit_filetabs (cu))
patch_opaque_types (s);
}
} }
coffread_objfile = NULL; coffread_objfile = NULL;

View file

@ -788,20 +788,23 @@ objfile_relocate1 (struct objfile *objfile,
/* OK, get all the symtabs. */ /* OK, get all the symtabs. */
{ {
ALL_OBJFILE_FILETABS (objfile, cust, s) for (compunit_symtab *cust : objfile_compunits (objfile))
{ {
struct linetable *l; for (symtab *s : compunit_filetabs (cust))
{
struct linetable *l;
/* First the line table. */ /* First the line table. */
l = SYMTAB_LINETABLE (s); l = SYMTAB_LINETABLE (s);
if (l) if (l)
{ {
for (int i = 0; i < l->nitems; ++i) for (int i = 0; i < l->nitems; ++i)
l->item[i].pc += ANOFFSET (delta, l->item[i].pc += ANOFFSET (delta,
COMPUNIT_BLOCK_LINE_SECTION COMPUNIT_BLOCK_LINE_SECTION
(cust)); (cust));
} }
} }
}
for (compunit_symtab *cust : objfile_compunits (objfile)) for (compunit_symtab *cust : objfile_compunits (objfile))
{ {

View file

@ -612,12 +612,6 @@ public:
(obj) != NULL; \ (obj) != NULL; \
(obj) = (obj)->next) (obj) = (obj)->next)
/* Traverse all symtabs in one objfile. */
#define ALL_OBJFILE_FILETABS(objfile, cu, s) \
for (compunit_symtab *cu : objfile_compunits (objfile)) \
for (symtab *s : compunit_filetabs (cu))
/* A range adapter that makes it possible to iterate over all /* A range adapter that makes it possible to iterate over all
compunits in one objfile. */ compunits in one objfile. */
@ -714,9 +708,10 @@ private:
/* Traverse all symtabs in all objfiles in the current symbol /* Traverse all symtabs in all objfiles in the current symbol
space. */ space. */
#define ALL_FILETABS(objfile, ps, s) \ #define ALL_FILETABS(objfile, ps, s) \
ALL_OBJFILES (objfile) \ ALL_OBJFILES (objfile) \
ALL_OBJFILE_FILETABS (objfile, ps, s) for (compunit_symtab *ps : objfile_compunits (objfile)) \
for (symtab *s : compunit_filetabs (cu))
#define ALL_OBJFILE_OSECTIONS(objfile, osect) \ #define ALL_OBJFILE_OSECTIONS(objfile, osect) \
for (osect = objfile->sections; osect < objfile->sections_end; osect++) \ for (osect = objfile->sections; osect < objfile->sections_end; osect++) \

View file

@ -349,17 +349,20 @@ show_directories_command (struct ui_file *file, int from_tty,
void void
forget_cached_source_info_for_objfile (struct objfile *objfile) forget_cached_source_info_for_objfile (struct objfile *objfile)
{ {
ALL_OBJFILE_FILETABS (objfile, cu, s) for (compunit_symtab *cu : objfile_compunits (objfile))
{ {
if (s->line_charpos != NULL) for (symtab *s : compunit_filetabs (cu))
{ {
xfree (s->line_charpos); if (s->line_charpos != NULL)
s->line_charpos = NULL; {
} xfree (s->line_charpos);
if (s->fullname != NULL) s->line_charpos = NULL;
{ }
xfree (s->fullname); if (s->fullname != NULL)
s->fullname = NULL; {
xfree (s->fullname);
s->fullname = NULL;
}
} }
} }

View file

@ -107,11 +107,14 @@ print_objfile_statistics (void)
if (objfile->sf) if (objfile->sf)
objfile->sf->qf->print_stats (objfile); objfile->sf->qf->print_stats (objfile);
i = linetables = 0; i = linetables = 0;
ALL_OBJFILE_FILETABS (objfile, cu, s) for (compunit_symtab *cu : objfile_compunits (objfile))
{ {
i++; for (symtab *s : compunit_filetabs (cu))
if (SYMTAB_LINETABLE (s) != NULL) {
linetables++; i++;
if (SYMTAB_LINETABLE (s) != NULL)
linetables++;
}
} }
blockvectors = std::distance (objfile_compunits (objfile).begin (), blockvectors = std::distance (objfile_compunits (objfile).begin (),
objfile_compunits (objfile).end ()); objfile_compunits (objfile).end ());
@ -157,16 +160,20 @@ dump_objfile (struct objfile *objfile)
if (objfile->compunit_symtabs != NULL) if (objfile->compunit_symtabs != NULL)
{ {
printf_filtered ("Symtabs:\n"); printf_filtered ("Symtabs:\n");
ALL_OBJFILE_FILETABS (objfile, cust, symtab) for (compunit_symtab *cu : objfile_compunits (objfile))
{ {
printf_filtered ("%s at ", symtab_to_filename_for_display (symtab)); for (symtab *symtab : compunit_filetabs (cu))
gdb_print_host_address (symtab, gdb_stdout);
printf_filtered (", ");
if (SYMTAB_OBJFILE (symtab) != objfile)
{ {
printf_filtered ("NOT ON CHAIN! "); printf_filtered ("%s at ",
symtab_to_filename_for_display (symtab));
gdb_print_host_address (symtab, gdb_stdout);
printf_filtered (", ");
if (SYMTAB_OBJFILE (symtab) != objfile)
{
printf_filtered ("NOT ON CHAIN! ");
}
wrap_here (" ");
} }
wrap_here (" ");
} }
printf_filtered ("\n\n"); printf_filtered ("\n\n");
} }
@ -477,21 +484,24 @@ maintenance_print_symbols (const char *args, int from_tty)
if (!print_for_objfile) if (!print_for_objfile)
continue; continue;
ALL_OBJFILE_FILETABS (objfile, cu, s) for (compunit_symtab *cu : objfile_compunits (objfile))
{ {
int print_for_source = 0; for (symtab *s : compunit_filetabs (cu))
QUIT;
if (source_arg != NULL)
{ {
print_for_source int print_for_source = 0;
= compare_filenames_for_search
(symtab_to_filename_for_display (s), source_arg); QUIT;
found = 1; if (source_arg != NULL)
{
print_for_source
= compare_filenames_for_search
(symtab_to_filename_for_display (s), source_arg);
found = 1;
}
if (source_arg == NULL
|| print_for_source)
dump_symtab (s, outfile);
} }
if (source_arg == NULL
|| print_for_source)
dump_symtab (s, outfile);
} }
} }