Remove ALL_OBJFILES and ALL_FILETABS

This removes the ALL_OBJFILES and ALL_FILETABS macros, replacing them
with ranged for loops.

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

	* symtab.c (find_line_symtab, info_sources_command)
	(make_source_files_completion_list): Use objfile_compunits.
	* source.c (select_source_symtab): Use objfile_compunits.
	* objfiles.h (struct objfile): Update comment.
	(ALL_OBJFILES): Remove.
	(ALL_FILETABS): Remove.
	* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Use
	objfile_compunits.
This commit is contained in:
Tom Tromey
2018-11-24 09:58:20 -07:00
parent d5da8b3c0d
commit 8b31193aa9
5 changed files with 111 additions and 92 deletions

View File

@ -1,3 +1,14 @@
2019-01-09 Tom Tromey <tom@tromey.com>
* symtab.c (find_line_symtab, info_sources_command)
(make_source_files_completion_list): Use objfile_compunits.
* source.c (select_source_symtab): Use objfile_compunits.
* objfiles.h (struct objfile): Update comment.
(ALL_OBJFILES): Remove.
(ALL_FILETABS): Remove.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Use
objfile_compunits.
2019-01-09 Tom Tromey <tom@tromey.com> 2019-01-09 Tom Tromey <tom@tromey.com>
* symmisc.c (print_objfile_statistics, dump_objfile) * symmisc.c (print_objfile_statistics, dump_objfile)

View File

@ -84,7 +84,6 @@ void
mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc) mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc)
{ {
struct ui_out *uiout = current_uiout; struct ui_out *uiout = current_uiout;
struct objfile *objfile;
if (!mi_valid_noargs ("-file-list-exec-source-files", argc, argv)) if (!mi_valid_noargs ("-file-list-exec-source-files", argc, argv))
error (_("-file-list-exec-source-files: Usage: No args")); error (_("-file-list-exec-source-files: Usage: No args"));
@ -93,7 +92,11 @@ mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc)
uiout->begin (ui_out_type_list, "files"); uiout->begin (ui_out_type_list, "files");
/* Look at all of the file symtabs. */ /* Look at all of the file symtabs. */
ALL_FILETABS (objfile, cu, s) for (objfile *objfile : all_objfiles (current_program_space))
{
for (compunit_symtab *cu : objfile_compunits (objfile))
{
for (symtab *s : compunit_filetabs (cu))
{ {
uiout->begin (ui_out_type_tuple, NULL); uiout->begin (ui_out_type_tuple, NULL);
@ -102,6 +105,8 @@ mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc)
uiout->end (ui_out_type_tuple); uiout->end (ui_out_type_tuple);
} }
}
}
map_symbol_filenames (print_partial_file_name, NULL, map_symbol_filenames (print_partial_file_name, NULL,
1 /*need_fullname*/); 1 /*need_fullname*/);

View File

@ -430,7 +430,7 @@ struct objfile
Although this is a tree structure, GDB only support one level Although this is a tree structure, GDB only support one level
(ie a separate debug for a separate debug is not supported). Note that (ie a separate debug for a separate debug is not supported). Note that
separate debug object are in the main chain and therefore will be separate debug object are in the main chain and therefore will be
visited by ALL_OBJFILES & co iterators. Separate debug objfile always visited by all_objfiles & co iterators. Separate debug objfile always
has a non-nul separate_debug_objfile_backlink. */ has a non-nul separate_debug_objfile_backlink. */
/* Link to the first separate debug object, if any. */ /* Link to the first separate debug object, if any. */
@ -604,14 +604,6 @@ public:
} }
}; };
/* Traverse all object files in the current program space. */
#define ALL_OBJFILES(obj) \
for ((obj) = current_program_space->objfiles; \
(obj) != NULL; \
(obj) = (obj)->next)
/* 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. */
@ -705,14 +697,6 @@ private:
struct objfile *m_objfile; struct objfile *m_objfile;
}; };
/* Traverse all symtabs in all objfiles in the current symbol
space. */
#define ALL_FILETABS(objfile, ps, s) \
ALL_OBJFILES (objfile) \
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++) \
if (osect->the_bfd_section == NULL) \ if (osect->the_bfd_section == NULL) \

View File

@ -238,8 +238,6 @@ clear_current_source_symtab_and_line (void)
void void
select_source_symtab (struct symtab *s) select_source_symtab (struct symtab *s)
{ {
struct objfile *ofp;
if (s) if (s)
{ {
current_source_symtab = s; current_source_symtab = s;
@ -271,7 +269,11 @@ select_source_symtab (struct symtab *s)
current_source_line = 1; current_source_line = 1;
ALL_FILETABS (ofp, cu, symtab) for (objfile *ofp : all_objfiles (current_program_space))
{
for (compunit_symtab *cu : objfile_compunits (ofp))
{
for (symtab *symtab : compunit_filetabs (cu))
{ {
const char *name = symtab->filename; const char *name = symtab->filename;
int len = strlen (name); int len = strlen (name);
@ -283,6 +285,8 @@ select_source_symtab (struct symtab *s)
current_source_symtab = symtab; current_source_symtab = symtab;
} }
} }
}
}
if (current_source_symtab) if (current_source_symtab)
return; return;

View File

@ -3359,8 +3359,11 @@ find_line_symtab (struct symtab *sym_tab, int line,
(objfile, symtab_to_fullname (sym_tab)); (objfile, symtab_to_fullname (sym_tab));
} }
struct objfile *objfile; for (objfile *objfile : all_objfiles (current_program_space))
ALL_FILETABS (objfile, cu, s) {
for (compunit_symtab *cu : objfile_compunits (objfile))
{
for (symtab *s : compunit_filetabs (cu))
{ {
struct linetable *l; struct linetable *l;
int ind; int ind;
@ -3391,6 +3394,8 @@ find_line_symtab (struct symtab *sym_tab, int line,
} }
} }
} }
}
}
done: done:
if (best_index < 0) if (best_index < 0)
return NULL; return NULL;
@ -4180,7 +4185,6 @@ output_partial_symbol_filename (const char *filename, const char *fullname,
static void static void
info_sources_command (const char *ignore, int from_tty) info_sources_command (const char *ignore, int from_tty)
{ {
struct objfile *objfile;
struct output_source_filename_data data; struct output_source_filename_data data;
if (!have_full_symbols () && !have_partial_symbols ()) if (!have_full_symbols () && !have_partial_symbols ())
@ -4195,12 +4199,18 @@ info_sources_command (const char *ignore, int from_tty)
printf_filtered ("Source files for which symbols have been read in:\n\n"); printf_filtered ("Source files for which symbols have been read in:\n\n");
data.first = 1; data.first = 1;
ALL_FILETABS (objfile, cu, s) for (objfile *objfile : all_objfiles (current_program_space))
{
for (compunit_symtab *cu : objfile_compunits (objfile))
{
for (symtab *s : compunit_filetabs (cu))
{ {
const char *fullname = symtab_to_fullname (s); const char *fullname = symtab_to_fullname (s);
output_source_filename (fullname, &data); output_source_filename (fullname, &data);
} }
}
}
printf_filtered ("\n\n"); printf_filtered ("\n\n");
printf_filtered ("Source files for which symbols " printf_filtered ("Source files for which symbols "
@ -5581,7 +5591,6 @@ maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
completion_list completion_list
make_source_files_completion_list (const char *text, const char *word) make_source_files_completion_list (const char *text, const char *word)
{ {
struct objfile *objfile;
size_t text_len = strlen (text); size_t text_len = strlen (text);
completion_list list; completion_list list;
const char *base_name; const char *base_name;
@ -5592,7 +5601,11 @@ make_source_files_completion_list (const char *text, const char *word)
filename_seen_cache filenames_seen; filename_seen_cache filenames_seen;
ALL_FILETABS (objfile, cu, s) for (objfile *objfile : all_objfiles (current_program_space))
{
for (compunit_symtab *cu : objfile_compunits (objfile))
{
for (symtab *s : compunit_filetabs (cu))
{ {
if (not_interesting_fname (s->filename)) if (not_interesting_fname (s->filename))
continue; continue;
@ -5616,6 +5629,8 @@ make_source_files_completion_list (const char *text, const char *word)
add_filename_to_list (base_name, text, word, &list); add_filename_to_list (base_name, text, word, &list);
} }
} }
}
}
datum.filename_seen_cache = &filenames_seen; datum.filename_seen_cache = &filenames_seen;
datum.text = text; datum.text = text;