Commit b669c953 authored by Tom Tromey's avatar Tom Tromey
Browse files

Add compunits range adapter to objfile

This removes the objfile_compunits range adapter in favor of using a
method on objfile.

2019-01-15  Tom Tromey  <tom@tromey.com>

	* symtab.c (lookup_objfile_from_block)
	(lookup_symbol_in_objfile_symtabs)
	(basic_lookup_transparent_type_1, find_pc_sect_compunit_symtab)
	(find_line_symtab, info_sources_command)
	(default_collect_symbol_completion_matches_break_on)
	(make_source_files_completion_list): Update.
	* symmisc.c (print_objfile_statistics, dump_objfile)
	(maintenance_print_symbols, maintenance_info_symtabs)
	(maintenance_check_symtabs, maintenance_info_line_tables):
	Update.
	* source.c (select_source_symtab)
	(forget_cached_source_info_for_objfile): Update.
	* objfiles.h (class objfile_compunits): Remove.
	(struct objfile) <compunits_range>: New typedef.
	(compunits): New method.
	* objfiles.c (objfile_relocate1): Update.
	* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update.
	* maint.c (count_symtabs_and_blocks): Update.
	* linespec.c (iterate_over_all_matching_symtabs): Update.
	* cp-support.c (add_symbol_overload_list_qualified): Update.
	* coffread.c (coff_symtab_read): Update.
	* ada-lang.c (add_nonlocal_symbols)
	(ada_collect_symbol_completion_matches)
	(ada_add_global_exceptions): Update.
parent 7e955d83
2019-01-15 Tom Tromey <tom@tromey.com>
* symtab.c (lookup_objfile_from_block)
(lookup_symbol_in_objfile_symtabs)
(basic_lookup_transparent_type_1, find_pc_sect_compunit_symtab)
(find_line_symtab, info_sources_command)
(default_collect_symbol_completion_matches_break_on)
(make_source_files_completion_list): Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_print_symbols, maintenance_info_symtabs)
(maintenance_check_symtabs, maintenance_info_line_tables):
Update.
* source.c (select_source_symtab)
(forget_cached_source_info_for_objfile): Update.
* objfiles.h (class objfile_compunits): Remove.
(struct objfile) <compunits_range>: New typedef.
(compunits): New method.
* objfiles.c (objfile_relocate1): Update.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update.
* maint.c (count_symtabs_and_blocks): Update.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* coffread.c (coff_symtab_read): Update.
* ada-lang.c (add_nonlocal_symbols)
(ada_collect_symbol_completion_matches)
(ada_add_global_exceptions): Update.
2019-01-15 Tom Tromey <tom@tromey.com>
* progspace.h (program_space) <objfiles_safe_range>: New
......
......@@ -5629,7 +5629,7 @@ add_nonlocal_symbols (struct obstack *obstackp,
symbol_name_match_type::FULL,
compare_names);
for (compunit_symtab *cu : objfile_compunits (objfile))
for (compunit_symtab *cu : objfile->compunits ())
{
const struct block *global_block
= BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cu), GLOBAL_BLOCK);
......@@ -6467,7 +6467,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
for (objfile *objfile : current_program_space->objfiles ())
{
for (compunit_symtab *s : objfile_compunits (objfile))
for (compunit_symtab *s : objfile->compunits ())
{
QUIT;
b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK);
......@@ -6486,7 +6486,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
for (objfile *objfile : current_program_space->objfiles ())
{
for (compunit_symtab *s : objfile_compunits (objfile))
for (compunit_symtab *s : objfile->compunits ())
{
QUIT;
b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK);
......@@ -13568,7 +13568,7 @@ ada_add_global_exceptions (compiled_regex *preg,
for (objfile *objfile : current_program_space->objfiles ())
{
for (compunit_symtab *s : objfile_compunits (objfile))
for (compunit_symtab *s : objfile->compunits ())
{
const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (s);
int i;
......
......@@ -1203,7 +1203,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
/* Patch up any opaque types (references to types that are not defined
in the file where they are referenced, e.g. "struct foo *bar"). */
{
for (compunit_symtab *cu : objfile_compunits (objfile))
for (compunit_symtab *cu : objfile->compunits ())
{
for (symtab *s : compunit_filetabs (cu))
patch_opaque_types (s);
......
......@@ -1397,7 +1397,7 @@ add_symbol_overload_list_qualified (const char *func_name,
for (objfile *objfile : current_program_space->objfiles ())
{
for (compunit_symtab *cust : objfile_compunits (objfile))
for (compunit_symtab *cust : objfile->compunits ())
{
QUIT;
b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), GLOBAL_BLOCK);
......@@ -1407,7 +1407,7 @@ add_symbol_overload_list_qualified (const char *func_name,
for (objfile *objfile : current_program_space->objfiles ())
{
for (compunit_symtab *cust : objfile_compunits (objfile))
for (compunit_symtab *cust : objfile->compunits ())
{
QUIT;
b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
......
......@@ -1150,7 +1150,7 @@ iterate_over_all_matching_symtabs
NULL, NULL,
search_domain);
for (compunit_symtab *cu : objfile_compunits (objfile))
for (compunit_symtab *cu : objfile->compunits ())
{
struct symtab *symtab = COMPUNIT_FILETABS (cu);
......
......@@ -773,7 +773,7 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
{
for (objfile *o : current_program_space->objfiles ())
{
for (compunit_symtab *cu : objfile_compunits (o))
for (compunit_symtab *cu : o->compunits ())
{
++nr_compunit_symtabs;
nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu));
......
......@@ -94,7 +94,7 @@ mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc)
/* Look at all of the file symtabs. */
for (objfile *objfile : current_program_space->objfiles ())
{
for (compunit_symtab *cu : objfile_compunits (objfile))
for (compunit_symtab *cu : objfile->compunits ())
{
for (symtab *s : compunit_filetabs (cu))
{
......
......@@ -787,7 +787,7 @@ objfile_relocate1 (struct objfile *objfile,
/* OK, get all the symtabs. */
{
for (compunit_symtab *cust : objfile_compunits (objfile))
for (compunit_symtab *cust : objfile->compunits ())
{
for (symtab *s : compunit_filetabs (cust))
{
......@@ -805,7 +805,7 @@ objfile_relocate1 (struct objfile *objfile,
}
}
for (compunit_symtab *cust : objfile_compunits (objfile))
for (compunit_symtab *cust : objfile->compunits ())
{
const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
......
......@@ -301,6 +301,15 @@ struct objfile
partial_symtabs.reset (new psymtab_storage ());
}
typedef next_adapter<struct compunit_symtab> compunits_range;
/* A range adapter that makes it possible to iterate over all
compunits in one objfile. */
compunits_range compunits ()
{
return compunits_range (compunit_symtabs);
}
/* All struct objfile's are chained together by their next pointers.
The program space field "objfiles" (frequently referenced via
......@@ -553,19 +562,6 @@ extern void default_iterate_over_objfiles_in_search_order
void *cb_data, struct objfile *current_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:
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. */
......
......@@ -271,7 +271,7 @@ select_source_symtab (struct symtab *s)
for (objfile *ofp : current_program_space->objfiles ())
{
for (compunit_symtab *cu : objfile_compunits (ofp))
for (compunit_symtab *cu : ofp->compunits ())
{
for (symtab *symtab : compunit_filetabs (cu))
{
......@@ -353,7 +353,7 @@ show_directories_command (struct ui_file *file, int from_tty,
void
forget_cached_source_info_for_objfile (struct objfile *objfile)
{
for (compunit_symtab *cu : objfile_compunits (objfile))
for (compunit_symtab *cu : objfile->compunits ())
{
for (symtab *s : compunit_filetabs (cu))
{
......
......@@ -108,7 +108,7 @@ print_objfile_statistics (void)
if (objfile->sf)
objfile->sf->qf->print_stats (objfile);
i = linetables = 0;
for (compunit_symtab *cu : objfile_compunits (objfile))
for (compunit_symtab *cu : objfile->compunits ())
{
for (symtab *s : compunit_filetabs (cu))
{
......@@ -117,8 +117,8 @@ print_objfile_statistics (void)
linetables++;
}
}
blockvectors = std::distance (objfile_compunits (objfile).begin (),
objfile_compunits (objfile).end ());
blockvectors = std::distance (objfile->compunits ().begin (),
objfile->compunits ().end ());
printf_filtered (_(" Number of symbol tables: %d\n"), i);
printf_filtered (_(" Number of symbol tables with line tables: %d\n"),
linetables);
......@@ -162,7 +162,7 @@ dump_objfile (struct objfile *objfile)
if (objfile->compunit_symtabs != NULL)
{
printf_filtered ("Symtabs:\n");
for (compunit_symtab *cu : objfile_compunits (objfile))
for (compunit_symtab *cu : objfile->compunits ())
{
for (symtab *symtab : compunit_filetabs (cu))
{
......@@ -486,7 +486,7 @@ maintenance_print_symbols (const char *args, int from_tty)
if (!print_for_objfile)
continue;
for (compunit_symtab *cu : objfile_compunits (objfile))
for (compunit_symtab *cu : objfile->compunits ())
{
for (symtab *s : compunit_filetabs (cu))
{
......@@ -784,7 +784,7 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
actually find a symtab whose name matches. */
int printed_objfile_start = 0;
for (compunit_symtab *cust : objfile_compunits (objfile))
for (compunit_symtab *cust : objfile->compunits ())
{
int printed_compunit_symtab_start = 0;
......@@ -869,7 +869,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
actually find something worth printing. */
int printed_objfile_start = 0;
for (compunit_symtab *cust : objfile_compunits (objfile))
for (compunit_symtab *cust : objfile->compunits ())
{
int found_something = 0;
struct symtab *symtab = compunit_primary_filetab (cust);
......@@ -1032,7 +1032,7 @@ maintenance_info_line_tables (const char *regexp, int from_tty)
ALL_PSPACES (pspace)
for (objfile *objfile : pspace->objfiles ())
{
for (compunit_symtab *cust : objfile_compunits (objfile))
for (compunit_symtab *cust : objfile->compunits ())
{
for (symtab *symtab : compunit_filetabs (cust))
{
......
......@@ -2171,7 +2171,7 @@ lookup_objfile_from_block (const struct block *block)
/* Look through all blockvectors. */
for (objfile *obj : current_program_space->objfiles ())
{
for (compunit_symtab *cust : objfile_compunits (obj))
for (compunit_symtab *cust : obj->compunits ())
if (block == BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
GLOBAL_BLOCK))
{
......@@ -2265,7 +2265,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
name, domain_name (domain));
}
for (compunit_symtab *cust : objfile_compunits (objfile))
for (compunit_symtab *cust : objfile->compunits ())
{
const struct blockvector *bv;
const struct block *block;
......@@ -2763,7 +2763,7 @@ basic_lookup_transparent_type_1 (struct objfile *objfile, int block_index,
const struct block *block;
const struct symbol *sym;
for (compunit_symtab *cust : objfile_compunits (objfile))
for (compunit_symtab *cust : objfile->compunits ())
{
bv = COMPUNIT_BLOCKVECTOR (cust);
block = BLOCKVECTOR_BLOCK (bv, block_index);
......@@ -2904,7 +2904,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
for (objfile *obj_file : current_program_space->objfiles ())
{
for (compunit_symtab *cust : objfile_compunits (obj_file))
for (compunit_symtab *cust : obj_file->compunits ())
{
struct block *b;
const struct blockvector *bv;
......@@ -3360,7 +3360,7 @@ find_line_symtab (struct symtab *sym_tab, int line,
for (objfile *objfile : current_program_space->objfiles ())
{
for (compunit_symtab *cu : objfile_compunits (objfile))
for (compunit_symtab *cu : objfile->compunits ())
{
for (symtab *s : compunit_filetabs (cu))
{
......@@ -4200,7 +4200,7 @@ info_sources_command (const char *ignore, int from_tty)
data.first = 1;
for (objfile *objfile : current_program_space->objfiles ())
{
for (compunit_symtab *cu : objfile_compunits (objfile))
for (compunit_symtab *cu : objfile->compunits ())
{
for (symtab *s : compunit_filetabs (cu))
{
......@@ -4492,7 +4492,7 @@ search_symbols (const char *regexp, enum search_domain kind,
for (objfile *objfile : current_program_space->objfiles ())
{
for (compunit_symtab *cust : objfile_compunits (objfile))
for (compunit_symtab *cust : objfile->compunits ())
{
bv = COMPUNIT_BLOCKVECTOR (cust);
for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
......@@ -5293,7 +5293,7 @@ default_collect_symbol_completion_matches_break_on
/* Add completions for all currently loaded symbol tables. */
for (objfile *objfile : current_program_space->objfiles ())
{
for (compunit_symtab *cust : objfile_compunits (objfile))
for (compunit_symtab *cust : objfile->compunits ())
add_symtab_completions (cust, tracker, mode, lookup_name,
sym_text, word, code);
}
......@@ -5602,7 +5602,7 @@ make_source_files_completion_list (const char *text, const char *word)
for (objfile *objfile : current_program_space->objfiles ())
{
for (compunit_symtab *cu : objfile_compunits (objfile))
for (compunit_symtab *cu : objfile->compunits ())
{
for (symtab *s : compunit_filetabs (cu))
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment