2019-01-09 Tom Tromey <tom@tromey.com>
+ * symtab.h (ALL_COMPUNIT_FILETABS): Remove.
+ (compunit_filetabs): New.
+ * symtab.c (iterate_over_some_symtabs, find_pc_sect_line): Use
+ compunit_filetabs.
+ (info_sources_command, make_source_files_completion_list): Remove
+ declaration.
+ * symmisc.c (print_objfile_statistics, dump_objfile)
+ (maintenance_print_symbols): Remove declaration.
+ (maintenance_info_symtabs): Use compunit_filetabs.
+ (maintenance_info_line_tables): Likewise.
+ * source.c (select_source_symtab): Change local variable name.
+ (forget_cached_source_info_for_objfile): Remove declaration.
+ * objfiles.h (ALL_OBJFILE_FILETABS): Use compunit_filetabs.
+ * objfiles.c (objfile_relocate1): Remove declaration.
+ * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Remove
+ declaration.
+ * maint.c (count_symtabs_and_blocks): Use compunit_filetabs.
+ * coffread.c (coff_symtab_read): Remove declaration.
+ * buildsym.c (buildsym_compunit::end_symtab_with_blockvector): Use
+ compunit_filetabs.
+
+2019-01-09 Tom Tromey <tom@tromey.com>
+
* symtab.c (lookup_objfile_from_block)
(find_pc_sect_compunit_symtab, search_symbols)
(default_collect_symbol_completion_matches_break_on): Use
int section, int expandable)
{
struct compunit_symtab *cu = m_compunit_symtab;
- struct symtab *symtab;
struct blockvector *blockvector;
struct subfile *subfile;
CORE_ADDR end_addr;
/* Allocate a symbol table if necessary. */
if (subfile->symtab == NULL)
subfile->symtab = allocate_symtab (cu, subfile->name);
- symtab = subfile->symtab;
+ struct symtab *symtab = subfile->symtab;
/* Fill in its components. */
main_symtab = m_main_subfile->symtab;
prev_symtab = NULL;
- ALL_COMPUNIT_FILETABS (cu, symtab)
+ for (symtab *symtab : compunit_filetabs (cu))
{
if (symtab == main_symtab)
{
int block_i;
/* The main source file's symtab. */
- symtab = COMPUNIT_FILETABS (cu);
+ struct symtab *symtab = COMPUNIT_FILETABS (cu);
for (block_i = 0; block_i < BLOCKVECTOR_NBLOCKS (blockvector); block_i++)
{
/* Patch up any opaque types (references to types that are not defined
in the file where they are referenced, e.g. "struct foo *bar"). */
{
- struct symtab *s;
-
ALL_OBJFILE_FILETABS (objfile, cu, s)
patch_opaque_types (s);
}
count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
int *nr_blocks_ptr)
{
- struct symtab *s;
int nr_symtabs = 0;
int nr_compunit_symtabs = 0;
int nr_blocks = 0;
{
++nr_compunit_symtabs;
nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu));
- ALL_COMPUNIT_FILETABS (cu, s)
- ++nr_symtabs;
+ nr_symtabs += std::distance (compunit_filetabs (cu).begin (),
+ compunit_filetabs (cu).end ());
}
}
}
mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc)
{
struct ui_out *uiout = current_uiout;
- struct symtab *s;
struct objfile *objfile;
if (!mi_valid_noargs ("-file-list-exec-source-files", argc, argv))
/* OK, get all the symtabs. */
{
- struct symtab *s;
-
ALL_OBJFILE_FILETABS (objfile, cust, s)
{
struct linetable *l;
#define ALL_OBJFILE_FILETABS(objfile, cu, s) \
for (compunit_symtab *cu : objfile_compunits (objfile)) \
- ALL_COMPUNIT_FILETABS (cu, s)
+ for (symtab *s : compunit_filetabs (cu))
/* A range adapter that makes it possible to iterate over all
compunits in one objfile. */
current_source_line = 1;
- ALL_FILETABS (ofp, cu, s)
+ ALL_FILETABS (ofp, cu, symtab)
{
- const char *name = s->filename;
+ 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 = s;
+ current_source_symtab = symtab;
}
}
void
forget_cached_source_info_for_objfile (struct objfile *objfile)
{
- struct symtab *s;
-
ALL_OBJFILE_FILETABS (objfile, cu, s)
{
if (s->line_charpos != NULL)
print_objfile_statistics (void)
{
struct program_space *pspace;
- struct symtab *s;
int i, linetables, blockvectors;
ALL_PSPACES (pspace)
static void
dump_objfile (struct objfile *objfile)
{
- struct symtab *symtab;
-
printf_filtered ("\nObject file %s: ", objfile_name (objfile));
printf_filtered ("Objfile at ");
gdb_print_host_address (objfile, gdb_stdout);
}
else
{
- struct symtab *s;
int found = 0;
for (objfile *objfile : all_objfiles (current_program_space))
ALL_PSPACES (pspace)
for (objfile *objfile : all_objfiles (pspace))
{
- struct symtab *symtab;
-
/* We don't want to print anything for this objfile until we
actually find a symtab whose name matches. */
int printed_objfile_start = 0;
{
int printed_compunit_symtab_start = 0;
- ALL_COMPUNIT_FILETABS (cust, symtab)
+ for (symtab *symtab : compunit_filetabs (cust))
{
QUIT;
ALL_PSPACES (pspace)
for (objfile *objfile : all_objfiles (pspace))
{
- struct symtab *symtab;
-
for (compunit_symtab *cust : objfile_compunits (objfile))
{
- ALL_COMPUNIT_FILETABS (cust, symtab)
+ for (symtab *symtab : compunit_filetabs (cust))
{
QUIT;
gdb::function_view<bool (symtab *)> callback)
{
struct compunit_symtab *cust;
- struct symtab *s;
const char* base_name = lbasename (name);
for (cust = first; cust != NULL && cust != after_last; cust = cust->next)
{
- ALL_COMPUNIT_FILETABS (cust, s)
+ for (symtab *s : compunit_filetabs (cust))
{
if (compare_filenames_for_search (s->filename, name))
{
find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
{
struct compunit_symtab *cust;
- struct symtab *iter_s;
struct linetable *l;
int len;
struct linetable_entry *item;
They all have the same apriori range, that we found was right;
but they have different line tables. */
- ALL_COMPUNIT_FILETABS (cust, iter_s)
+ for (symtab *iter_s : compunit_filetabs (cust))
{
/* Find the best line in this symtab. */
l = SYMTAB_LINETABLE (iter_s);
If not found, return NULL. */
struct symtab *
-find_line_symtab (struct symtab *symtab, int line,
+find_line_symtab (struct symtab *sym_tab, int line,
int *index, int *exact_match)
{
int exact = 0; /* Initialized here to avoid a compiler warning. */
struct symtab *best_symtab;
/* First try looking it up in the given symtab. */
- best_linetable = SYMTAB_LINETABLE (symtab);
- best_symtab = symtab;
+ best_linetable = SYMTAB_LINETABLE (sym_tab);
+ best_symtab = sym_tab;
best_index = find_line_common (best_linetable, line, &exact, 0);
if (best_index < 0 || !exact)
{
BEST_INDEX and BEST_LINETABLE identify the item for it. */
int best;
- struct symtab *s;
-
if (best_index >= 0)
best = best_linetable->item[best_index].line;
else
{
if (objfile->sf)
objfile->sf->qf->expand_symtabs_with_fullname
- (objfile, symtab_to_fullname (symtab));
+ (objfile, symtab_to_fullname (sym_tab));
}
struct objfile *objfile;
struct linetable *l;
int ind;
- if (FILENAME_CMP (symtab->filename, s->filename) != 0)
+ if (FILENAME_CMP (sym_tab->filename, s->filename) != 0)
continue;
- if (FILENAME_CMP (symtab_to_fullname (symtab),
+ if (FILENAME_CMP (symtab_to_fullname (sym_tab),
symtab_to_fullname (s)) != 0)
continue;
l = SYMTAB_LINETABLE (s);
static void
info_sources_command (const char *ignore, int from_tty)
{
- struct symtab *s;
struct objfile *objfile;
struct output_source_filename_data data;
completion_list
make_source_files_completion_list (const char *text, const char *word)
{
- struct symtab *s;
struct objfile *objfile;
size_t text_len = strlen (text);
completion_list list;
#include "common/enum-flags.h"
#include "common/function-view.h"
#include "common/gdb_optional.h"
+#include "common/next-iterator.h"
#include "completer.h"
/* Opaque declarations. */
#define COMPUNIT_CALL_SITE_HTAB(cust) ((cust)->call_site_htab)
#define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table)
-/* Iterate over all file tables (struct symtab) within a compunit. */
+/* A range adapter to allowing iterating over all the file tables
+ within a compunit. */
-#define ALL_COMPUNIT_FILETABS(cu, s) \
- for ((s) = (cu) -> filetabs; (s) != NULL; (s) = (s) -> next)
+struct compunit_filetabs : public next_adapter<struct symtab>
+{
+ compunit_filetabs (struct compunit_symtab *cu)
+ : next_adapter<struct symtab> (cu->filetabs)
+ {
+ }
+};
/* Return the primary symtab of CUST. */