mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc)
{
struct ui_out *uiout = current_uiout;
- struct objfile *objfile;
if (!mi_valid_noargs ("-file-list-exec-source-files", argc, argv))
error (_("-file-list-exec-source-files: Usage: No args"));
uiout->begin (ui_out_type_list, "files");
/* Look at all of the file symtabs. */
- ALL_FILETABS (objfile, cu, s)
- {
- uiout->begin (ui_out_type_tuple, NULL);
-
- uiout->field_string ("file", symtab_to_filename_for_display (s));
- uiout->field_string ("fullname", symtab_to_fullname (s));
-
- uiout->end (ui_out_type_tuple);
- }
+ 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->field_string ("file", symtab_to_filename_for_display (s));
+ uiout->field_string ("fullname", symtab_to_fullname (s));
+
+ uiout->end (ui_out_type_tuple);
+ }
+ }
+ }
map_symbol_filenames (print_partial_file_name, NULL,
1 /*need_fullname*/);
Although this is a tree structure, GDB only support one level
(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
- 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. */
/* Link to the first separate debug object, if any. */
}
};
-
-/* 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
compunits in one 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) \
for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
if (osect->the_bfd_section == NULL) \
void
select_source_symtab (struct symtab *s)
{
- struct objfile *ofp;
-
if (s)
{
current_source_symtab = s;
current_source_line = 1;
- ALL_FILETABS (ofp, cu, symtab)
+ for (objfile *ofp : all_objfiles (current_program_space))
{
- const char *name = symtab->filename;
- int len = strlen (name);
-
- if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0
- || strcmp (name, "<<C++-namespaces>>") == 0)))
+ for (compunit_symtab *cu : objfile_compunits (ofp))
{
- current_source_pspace = current_program_space;
- current_source_symtab = symtab;
+ for (symtab *symtab : compunit_filetabs (cu))
+ {
+ const char *name = symtab->filename;
+ int len = strlen (name);
+
+ if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0
+ || strcmp (name, "<<C++-namespaces>>") == 0)))
+ {
+ current_source_pspace = current_program_space;
+ current_source_symtab = symtab;
+ }
+ }
}
}
(objfile, symtab_to_fullname (sym_tab));
}
- struct objfile *objfile;
- ALL_FILETABS (objfile, cu, s)
- {
- struct linetable *l;
- int ind;
-
- if (FILENAME_CMP (sym_tab->filename, s->filename) != 0)
- continue;
- if (FILENAME_CMP (symtab_to_fullname (sym_tab),
- symtab_to_fullname (s)) != 0)
- continue;
- l = SYMTAB_LINETABLE (s);
- ind = find_line_common (l, line, &exact, 0);
- if (ind >= 0)
- {
- if (exact)
- {
- best_index = ind;
- best_linetable = l;
- best_symtab = s;
- goto done;
- }
- if (best == 0 || l->item[ind].line < best)
- {
- best = l->item[ind].line;
- best_index = ind;
- best_linetable = l;
- best_symtab = s;
- }
- }
- }
+ for (objfile *objfile : all_objfiles (current_program_space))
+ {
+ for (compunit_symtab *cu : objfile_compunits (objfile))
+ {
+ for (symtab *s : compunit_filetabs (cu))
+ {
+ struct linetable *l;
+ int ind;
+
+ if (FILENAME_CMP (sym_tab->filename, s->filename) != 0)
+ continue;
+ if (FILENAME_CMP (symtab_to_fullname (sym_tab),
+ symtab_to_fullname (s)) != 0)
+ continue;
+ l = SYMTAB_LINETABLE (s);
+ ind = find_line_common (l, line, &exact, 0);
+ if (ind >= 0)
+ {
+ if (exact)
+ {
+ best_index = ind;
+ best_linetable = l;
+ best_symtab = s;
+ goto done;
+ }
+ if (best == 0 || l->item[ind].line < best)
+ {
+ best = l->item[ind].line;
+ best_index = ind;
+ best_linetable = l;
+ best_symtab = s;
+ }
+ }
+ }
+ }
+ }
}
done:
if (best_index < 0)
static void
info_sources_command (const char *ignore, int from_tty)
{
- struct objfile *objfile;
struct output_source_filename_data data;
if (!have_full_symbols () && !have_partial_symbols ())
printf_filtered ("Source files for which symbols have been read in:\n\n");
data.first = 1;
- ALL_FILETABS (objfile, cu, s)
- {
- const char *fullname = symtab_to_fullname (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);
- output_source_filename (fullname, &data);
- }
+ output_source_filename (fullname, &data);
+ }
+ }
+ }
printf_filtered ("\n\n");
printf_filtered ("Source files for which symbols "
completion_list
make_source_files_completion_list (const char *text, const char *word)
{
- struct objfile *objfile;
size_t text_len = strlen (text);
completion_list list;
const char *base_name;
filename_seen_cache filenames_seen;
- ALL_FILETABS (objfile, cu, s)
+ for (objfile *objfile : all_objfiles (current_program_space))
{
- if (not_interesting_fname (s->filename))
- continue;
- if (!filenames_seen.seen (s->filename)
- && filename_ncmp (s->filename, text, text_len) == 0)
- {
- /* This file matches for a completion; add it to the current
- list of matches. */
- add_filename_to_list (s->filename, text, word, &list);
- }
- else
+ for (compunit_symtab *cu : objfile_compunits (objfile))
{
- /* NOTE: We allow the user to type a base name when the
- debug info records leading directories, but not the other
- way around. This is what subroutines of breakpoint
- command do when they parse file names. */
- base_name = lbasename (s->filename);
- if (base_name != s->filename
- && !filenames_seen.seen (base_name)
- && filename_ncmp (base_name, text, text_len) == 0)
- add_filename_to_list (base_name, text, word, &list);
+ for (symtab *s : compunit_filetabs (cu))
+ {
+ if (not_interesting_fname (s->filename))
+ continue;
+ if (!filenames_seen.seen (s->filename)
+ && filename_ncmp (s->filename, text, text_len) == 0)
+ {
+ /* This file matches for a completion; add it to the current
+ list of matches. */
+ add_filename_to_list (s->filename, text, word, &list);
+ }
+ else
+ {
+ /* NOTE: We allow the user to type a base name when the
+ debug info records leading directories, but not the other
+ way around. This is what subroutines of breakpoint
+ command do when they parse file names. */
+ base_name = lbasename (s->filename);
+ if (base_name != s->filename
+ && !filenames_seen.seen (base_name)
+ && filename_ncmp (base_name, text, text_len) == 0)
+ add_filename_to_list (base_name, text, word, &list);
+ }
+ }
}
}