+2019-01-09 Tom Tromey <tom@tromey.com>
+
+ * source.c (select_source_symtab)
+ (forget_cached_source_info_for_objfile): Remove declaration.
+ * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Remove
+ declaration.
+ * maint.c (count_symtabs_and_blocks): Remove declaration.
+ * cp-support.c (add_symbol_overload_list_qualified): Remove
+ declaration.
+ * coffread.c (coff_symtab_read): Remove declaration.
+ * symtab.c (lookup_symbol_in_objfile_symtabs)
+ (basic_lookup_transparent_type_1): Use objfile_compunits.
+ (lookup_objfile_from_block, find_pc_sect_compunit_symtab)
+ (info_sources_command, search_symbols)
+ (default_collect_symbol_completion_matches_break_on)
+ (make_source_files_completion_list): Remove declaration.
+ * ada-lang.c (add_nonlocal_symbols): Use objfile_compunits.
+ (ada_collect_symbol_completion_matches)
+ (ada_add_global_exceptions): Remove declaration.
+ * linespec.c (iterate_over_all_matching_symtabs): Use
+ objfile_compunits.
+ * objfiles.h (ALL_OBJFILE_COMPUNITS): Remove.
+ (class objfile_compunits): New.
+ (ALL_COMPUNITS): Use objfile_compunits.
+ * symmisc.c (print_objfile_statistics, maintenance_info_symtabs)
+ (maintenance_check_symtabs, maintenance_info_line_tables): Use
+ objfile_compunits.
+ * objfiles.c (objfile_relocate1): Use objfile_compunits.
+
2019-01-09 Tom Tromey <tom@tromey.com>
* symtab.c (search_symbols)
const lookup_name_info &lookup_name,
domain_enum domain, int global)
{
- struct compunit_symtab *cu;
struct match_data data;
memset (&data, 0, sizeof data);
symbol_name_match_type::FULL,
compare_names);
- ALL_OBJFILE_COMPUNITS (objfile, cu)
+ for (compunit_symtab *cu : objfile_compunits (objfile))
{
const struct block *global_block
= BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cu), GLOBAL_BLOCK);
enum type_code code)
{
struct symbol *sym;
- struct compunit_symtab *s;
const struct block *b, *surrounding_static_block = 0;
struct block_iterator iter;
std::vector<ada_exc_info> *exceptions)
{
struct objfile *objfile;
- struct compunit_symtab *s;
/* In Ada, the symbol "search name" is a linkage name, whereas the
regular expression used to do the matching refers to the natural
/* 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 compunit_symtab *cu;
struct symtab *s;
ALL_OBJFILE_FILETABS (objfile, cu, s)
add_symbol_overload_list_qualified (const char *func_name,
std::vector<symbol *> *overload_list)
{
- struct compunit_symtab *cust;
const struct block *b, *surrounding_static_block = 0;
/* Look through the partial symtabs for all symbols which begin by
for (objfile *objfile : all_objfiles (current_program_space))
{
- struct compunit_symtab *cu;
-
if (objfile->sf)
objfile->sf->qf->expand_symtabs_matching (objfile,
NULL,
NULL, NULL,
search_domain);
- ALL_OBJFILE_COMPUNITS (objfile, cu)
+ for (compunit_symtab *cu : objfile_compunits (objfile))
{
struct symtab *symtab = COMPUNIT_FILETABS (cu);
int *nr_blocks_ptr)
{
struct objfile *o;
- struct compunit_symtab *cu;
struct symtab *s;
int nr_symtabs = 0;
int nr_compunit_symtabs = 0;
mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc)
{
struct ui_out *uiout = current_uiout;
- struct compunit_symtab *cu;
struct symtab *s;
struct objfile *objfile;
/* OK, get all the symtabs. */
{
- struct compunit_symtab *cust;
struct symtab *s;
ALL_OBJFILE_FILETABS (objfile, cust, s)
}
}
- ALL_OBJFILE_COMPUNITS (objfile, cust)
- {
- const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
- int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
-
- if (BLOCKVECTOR_MAP (bv))
- addrmap_relocate (BLOCKVECTOR_MAP (bv),
- ANOFFSET (delta, block_line_section));
-
- for (int i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i)
- {
- struct block *b;
- struct symbol *sym;
- struct dict_iterator iter;
-
- b = BLOCKVECTOR_BLOCK (bv, i);
- BLOCK_START (b) += ANOFFSET (delta, block_line_section);
- BLOCK_END (b) += ANOFFSET (delta, block_line_section);
-
- if (BLOCK_RANGES (b) != nullptr)
- for (int j = 0; j < BLOCK_NRANGES (b); j++)
+ for (compunit_symtab *cust : objfile_compunits (objfile))
+ {
+ const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
+ int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
+
+ if (BLOCKVECTOR_MAP (bv))
+ addrmap_relocate (BLOCKVECTOR_MAP (bv),
+ ANOFFSET (delta, block_line_section));
+
+ for (int i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i)
+ {
+ struct block *b;
+ struct symbol *sym;
+ struct dict_iterator iter;
+
+ b = BLOCKVECTOR_BLOCK (bv, i);
+ BLOCK_START (b) += ANOFFSET (delta, block_line_section);
+ BLOCK_END (b) += ANOFFSET (delta, block_line_section);
+
+ if (BLOCK_RANGES (b) != nullptr)
+ for (int j = 0; j < BLOCK_NRANGES (b); j++)
+ {
+ BLOCK_RANGE_START (b, j)
+ += ANOFFSET (delta, block_line_section);
+ BLOCK_RANGE_END (b, j) += ANOFFSET (delta,
+ block_line_section);
+ }
+
+ /* We only want to iterate over the local symbols, not any
+ symbols in included symtabs. */
+ ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym)
{
- BLOCK_RANGE_START (b, j)
- += ANOFFSET (delta, block_line_section);
- BLOCK_RANGE_END (b, j) += ANOFFSET (delta, block_line_section);
+ relocate_one_symbol (sym, objfile, delta);
}
-
- /* We only want to iterate over the local symbols, not any
- symbols in included symtabs. */
- ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym)
- {
- relocate_one_symbol (sym, objfile, delta);
- }
- }
- }
+ }
+ }
}
/* This stores relocated addresses and so must be cleared. This
/* Traverse all symtabs in one objfile. */
#define ALL_OBJFILE_FILETABS(objfile, cu, s) \
- ALL_OBJFILE_COMPUNITS (objfile, cu) \
+ for (compunit_symtab *cu : objfile_compunits (objfile)) \
ALL_COMPUNIT_FILETABS (cu, s)
-/* Traverse all compunits in one objfile. */
+/* A range adapter that makes it possible to iterate over all
+ compunits in one objfile. */
+
+class objfile_compunits : public next_adapter<struct compunit_symtab>
+{
+public:
-#define ALL_OBJFILE_COMPUNITS(objfile, cu) \
- for ((cu) = (objfile) -> compunit_symtabs; (cu) != NULL; (cu) = (cu) -> next)
+ explicit objfile_compunits (struct objfile *objfile)
+ : next_adapter<struct compunit_symtab> (objfile->compunit_symtabs)
+ {
+ }
+};
/* A range adapter that makes it possible to iterate over all
minimal symbols of an objfile. */
#define ALL_COMPUNITS(objfile, cu) \
ALL_OBJFILES (objfile) \
- ALL_OBJFILE_COMPUNITS (objfile, cu)
+ for (compunit_symtab *cu : objfile_compunits (objfile))
#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
select_source_symtab (struct symtab *s)
{
struct objfile *ofp;
- struct compunit_symtab *cu;
if (s)
{
void
forget_cached_source_info_for_objfile (struct objfile *objfile)
{
- struct compunit_symtab *cu;
struct symtab *s;
ALL_OBJFILE_FILETABS (objfile, cu, s)
print_objfile_statistics (void)
{
struct program_space *pspace;
- struct compunit_symtab *cu;
struct symtab *s;
int i, linetables, blockvectors;
OBJSTAT (objfile, n_types));
if (objfile->sf)
objfile->sf->qf->print_stats (objfile);
- i = linetables = blockvectors = 0;
+ i = linetables = 0;
ALL_OBJFILE_FILETABS (objfile, cu, s)
{
i++;
if (SYMTAB_LINETABLE (s) != NULL)
linetables++;
}
- ALL_OBJFILE_COMPUNITS (objfile, cu)
- blockvectors++;
+ blockvectors = std::distance (objfile_compunits (objfile).begin (),
+ objfile_compunits (objfile).end ());
printf_filtered (_(" Number of symbol tables: %d\n"), i);
printf_filtered (_(" Number of symbol tables with line tables: %d\n"),
linetables);
static void
dump_objfile (struct objfile *objfile)
{
- struct compunit_symtab *cust;
struct symtab *symtab;
printf_filtered ("\nObject file %s: ", objfile_name (objfile));
}
else
{
- struct compunit_symtab *cu;
struct symtab *s;
int found = 0;
ALL_PSPACES (pspace)
for (objfile *objfile : all_objfiles (pspace))
{
- struct compunit_symtab *cust;
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;
- ALL_OBJFILE_COMPUNITS (objfile, cust)
+ for (compunit_symtab *cust : objfile_compunits (objfile))
{
int printed_compunit_symtab_start = 0;
ALL_PSPACES (pspace)
for (objfile *objfile : all_objfiles (pspace))
{
- struct compunit_symtab *cust;
-
/* We don't want to print anything for this objfile until we
actually find something worth printing. */
int printed_objfile_start = 0;
- ALL_OBJFILE_COMPUNITS (objfile, cust)
+ for (compunit_symtab *cust : objfile_compunits (objfile))
{
int found_something = 0;
struct symtab *symtab = compunit_primary_filetab (cust);
ALL_PSPACES (pspace)
for (objfile *objfile : all_objfiles (pspace))
{
- struct compunit_symtab *cust;
struct symtab *symtab;
- ALL_OBJFILE_COMPUNITS (objfile, cust)
+ for (compunit_symtab *cust : objfile_compunits (objfile))
{
ALL_COMPUNIT_FILETABS (cust, symtab)
{
lookup_objfile_from_block (const struct block *block)
{
struct objfile *obj;
- struct compunit_symtab *cust;
if (block == NULL)
return NULL;
lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
const char *name, const domain_enum domain)
{
- struct compunit_symtab *cust;
-
gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
if (symbol_lookup_debug > 1)
name, domain_name (domain));
}
- ALL_OBJFILE_COMPUNITS (objfile, cust)
+ for (compunit_symtab *cust : objfile_compunits (objfile))
{
const struct blockvector *bv;
const struct block *block;
basic_lookup_transparent_type_1 (struct objfile *objfile, int block_index,
const char *name)
{
- const struct compunit_symtab *cust;
const struct blockvector *bv;
const struct block *block;
const struct symbol *sym;
- ALL_OBJFILE_COMPUNITS (objfile, cust)
+ for (compunit_symtab *cust : objfile_compunits (objfile))
{
bv = COMPUNIT_BLOCKVECTOR (cust);
block = BLOCKVECTOR_BLOCK (bv, block_index);
struct compunit_symtab *
find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
{
- struct compunit_symtab *cust;
struct compunit_symtab *best_cust = NULL;
struct objfile *obj_file;
CORE_ADDR distance = 0;
BEST_INDEX and BEST_LINETABLE identify the item for it. */
int best;
- struct compunit_symtab *cu;
struct symtab *s;
if (best_index >= 0)
static void
info_sources_command (const char *ignore, int from_tty)
{
- struct compunit_symtab *cu;
struct symtab *s;
struct objfile *objfile;
struct output_source_filename_data data;
const char *t_regexp,
int nfiles, const char *files[])
{
- struct compunit_symtab *cust;
const struct blockvector *bv;
struct block *b;
int i = 0;
won't be that many. */
struct symbol *sym;
- struct compunit_symtab *cust;
const struct block *b;
const struct block *surrounding_static_block, *surrounding_global_block;
struct block_iterator iter;
completion_list
make_source_files_completion_list (const char *text, const char *word)
{
- struct compunit_symtab *cu;
struct symtab *s;
struct objfile *objfile;
size_t text_len = strlen (text);