forked from Imagelibrary/binutils-gdb
Remove ALL_COMPUNITS
This removes the ALL_COMPUNITS, replacing its uses with two nested ranged for loops. gdb/ChangeLog 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 objfile_compunits. * objfiles.h (ALL_COMPUNITS): Remove. * maint.c (count_symtabs_and_blocks): Use objfile_compunits. * cp-support.c (add_symbol_overload_list_qualified): Use objfile_compunits. * ada-lang.c (ada_collect_symbol_completion_matches) (ada_add_global_exceptions): Use objfile_compunits.
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
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
|
||||
objfile_compunits.
|
||||
* objfiles.h (ALL_COMPUNITS): Remove.
|
||||
* maint.c (count_symtabs_and_blocks): Use objfile_compunits.
|
||||
* cp-support.c (add_symbol_overload_list_qualified): Use
|
||||
objfile_compunits.
|
||||
* ada-lang.c (ada_collect_symbol_completion_matches)
|
||||
(ada_add_global_exceptions): Use objfile_compunits.
|
||||
|
||||
2019-01-09 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* source.c (select_source_symtab)
|
||||
|
||||
@@ -6465,8 +6465,9 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
|
||||
/* Go through the symtabs and check the externs and statics for
|
||||
symbols which match. */
|
||||
|
||||
struct objfile *objfile;
|
||||
ALL_COMPUNITS (objfile, s)
|
||||
for (objfile *objfile : all_objfiles (current_program_space))
|
||||
{
|
||||
for (compunit_symtab *s : objfile_compunits (objfile))
|
||||
{
|
||||
QUIT;
|
||||
b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK);
|
||||
@@ -6481,8 +6482,11 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
|
||||
lookup_name, text, word);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ALL_COMPUNITS (objfile, s)
|
||||
for (objfile *objfile : all_objfiles (current_program_space))
|
||||
{
|
||||
for (compunit_symtab *s : objfile_compunits (objfile))
|
||||
{
|
||||
QUIT;
|
||||
b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK);
|
||||
@@ -6500,6 +6504,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
|
||||
lookup_name, text, word);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Field Access */
|
||||
@@ -13548,8 +13553,6 @@ static void
|
||||
ada_add_global_exceptions (compiled_regex *preg,
|
||||
std::vector<ada_exc_info> *exceptions)
|
||||
{
|
||||
struct objfile *objfile;
|
||||
|
||||
/* In Ada, the symbol "search name" is a linkage name, whereas the
|
||||
regular expression used to do the matching refers to the natural
|
||||
name. So match against the decoded name. */
|
||||
@@ -13563,7 +13566,9 @@ ada_add_global_exceptions (compiled_regex *preg,
|
||||
NULL,
|
||||
VARIABLES_DOMAIN);
|
||||
|
||||
ALL_COMPUNITS (objfile, s)
|
||||
for (objfile *objfile : all_objfiles (current_program_space))
|
||||
{
|
||||
for (compunit_symtab *s : objfile_compunits (objfile))
|
||||
{
|
||||
const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (s);
|
||||
int i;
|
||||
@@ -13585,6 +13590,7 @@ ada_add_global_exceptions (compiled_regex *preg,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Implements ada_exceptions_list with the regular expression passed
|
||||
|
||||
@@ -1395,15 +1395,19 @@ add_symbol_overload_list_qualified (const char *func_name,
|
||||
/* Go through the symtabs and check the externs and statics for
|
||||
symbols which match. */
|
||||
|
||||
struct objfile *objfile;
|
||||
ALL_COMPUNITS (objfile, cust)
|
||||
for (objfile *objfile : all_objfiles (current_program_space))
|
||||
{
|
||||
for (compunit_symtab *cust : objfile_compunits (objfile))
|
||||
{
|
||||
QUIT;
|
||||
b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), GLOBAL_BLOCK);
|
||||
add_symbol_overload_list_block (func_name, b, overload_list);
|
||||
}
|
||||
}
|
||||
|
||||
ALL_COMPUNITS (objfile, cust)
|
||||
for (objfile *objfile : all_objfiles (current_program_space))
|
||||
{
|
||||
for (compunit_symtab *cust : objfile_compunits (objfile))
|
||||
{
|
||||
QUIT;
|
||||
b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
|
||||
@@ -1412,6 +1416,7 @@ add_symbol_overload_list_qualified (const char *func_name,
|
||||
continue;
|
||||
add_symbol_overload_list_block (func_name, b, overload_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Lookup the rtti type for a class name. */
|
||||
|
||||
@@ -762,7 +762,6 @@ static void
|
||||
count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
|
||||
int *nr_blocks_ptr)
|
||||
{
|
||||
struct objfile *o;
|
||||
struct symtab *s;
|
||||
int nr_symtabs = 0;
|
||||
int nr_compunit_symtabs = 0;
|
||||
@@ -773,7 +772,9 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
|
||||
current_program_space may be NULL. */
|
||||
if (current_program_space != NULL)
|
||||
{
|
||||
ALL_COMPUNITS (o, cu)
|
||||
for (objfile *o : all_objfiles (current_program_space))
|
||||
{
|
||||
for (compunit_symtab *cu : objfile_compunits (o))
|
||||
{
|
||||
++nr_compunit_symtabs;
|
||||
nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu));
|
||||
@@ -781,6 +782,7 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
|
||||
++nr_symtabs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*nr_symtabs_ptr = nr_symtabs;
|
||||
*nr_compunit_symtabs_ptr = nr_compunit_symtabs;
|
||||
|
||||
@@ -718,12 +718,6 @@ private:
|
||||
ALL_OBJFILES (objfile) \
|
||||
ALL_OBJFILE_FILETABS (objfile, ps, s)
|
||||
|
||||
/* Traverse all compunits in all objfiles in the current program space. */
|
||||
|
||||
#define ALL_COMPUNITS(objfile, cu) \
|
||||
ALL_OBJFILES (objfile) \
|
||||
for (compunit_symtab *cu : objfile_compunits (objfile))
|
||||
|
||||
#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
|
||||
for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
|
||||
if (osect->the_bfd_section == NULL) \
|
||||
|
||||
31
gdb/symtab.c
31
gdb/symtab.c
@@ -2166,14 +2166,14 @@ lookup_local_symbol (const char *name,
|
||||
struct objfile *
|
||||
lookup_objfile_from_block (const struct block *block)
|
||||
{
|
||||
struct objfile *obj;
|
||||
|
||||
if (block == NULL)
|
||||
return NULL;
|
||||
|
||||
block = block_global_block (block);
|
||||
/* Look through all blockvectors. */
|
||||
ALL_COMPUNITS (obj, cust)
|
||||
for (objfile *obj : all_objfiles (current_program_space))
|
||||
{
|
||||
for (compunit_symtab *cust : objfile_compunits (obj))
|
||||
if (block == BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
|
||||
GLOBAL_BLOCK))
|
||||
{
|
||||
@@ -2182,6 +2182,7 @@ lookup_objfile_from_block (const struct block *block)
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -2871,7 +2872,6 @@ struct compunit_symtab *
|
||||
find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
|
||||
{
|
||||
struct compunit_symtab *best_cust = NULL;
|
||||
struct objfile *obj_file;
|
||||
CORE_ADDR distance = 0;
|
||||
struct bound_minimal_symbol msymbol;
|
||||
|
||||
@@ -2904,7 +2904,9 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
|
||||
It also happens for objfiles that have their functions reordered.
|
||||
For these, the symtab we are looking for is not necessarily read in. */
|
||||
|
||||
ALL_COMPUNITS (obj_file, cust)
|
||||
for (objfile *obj_file : all_objfiles (current_program_space))
|
||||
{
|
||||
for (compunit_symtab *cust : objfile_compunits (obj_file))
|
||||
{
|
||||
struct block *b;
|
||||
const struct blockvector *bv;
|
||||
@@ -2930,7 +2932,8 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
|
||||
result
|
||||
= obj_file->sf->qf->find_pc_sect_compunit_symtab (obj_file,
|
||||
msymbol,
|
||||
pc, section,
|
||||
pc,
|
||||
section,
|
||||
0);
|
||||
if (result != NULL)
|
||||
return result;
|
||||
@@ -2943,7 +2946,8 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
|
||||
ALL_BLOCK_SYMBOLS (b, iter, sym)
|
||||
{
|
||||
fixup_symbol_section (sym, obj_file);
|
||||
if (matching_obj_sections (SYMBOL_OBJ_SECTION (obj_file, sym),
|
||||
if (matching_obj_sections (SYMBOL_OBJ_SECTION (obj_file,
|
||||
sym),
|
||||
section))
|
||||
break;
|
||||
}
|
||||
@@ -2955,6 +2959,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
|
||||
best_cust = cust;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (best_cust != NULL)
|
||||
return best_cust;
|
||||
@@ -4465,7 +4470,7 @@ search_symbols (const char *regexp, enum search_domain kind,
|
||||
/* Note: An important side-effect of these
|
||||
lookup functions is to expand the symbol
|
||||
table if msymbol is found, for the benefit of
|
||||
the next loop on ALL_COMPUNITS. */
|
||||
the next loop on compunits. */
|
||||
if (kind == FUNCTIONS_DOMAIN
|
||||
? (find_pc_compunit_symtab
|
||||
(MSYMBOL_VALUE_ADDRESS (objfile, msymbol))
|
||||
@@ -4481,9 +4486,9 @@ search_symbols (const char *regexp, enum search_domain kind,
|
||||
}
|
||||
}
|
||||
|
||||
for (objfile *objfile : all_objfiles (current_program_space))
|
||||
{
|
||||
struct objfile *objfile;
|
||||
ALL_COMPUNITS (objfile, cust)
|
||||
for (compunit_symtab *cust : objfile_compunits (objfile))
|
||||
{
|
||||
bv = COMPUNIT_BLOCKVECTOR (cust);
|
||||
for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
|
||||
@@ -5282,10 +5287,12 @@ default_collect_symbol_completion_matches_break_on
|
||||
}
|
||||
|
||||
/* Add completions for all currently loaded symbol tables. */
|
||||
struct objfile *objfile;
|
||||
ALL_COMPUNITS (objfile, cust)
|
||||
for (objfile *objfile : all_objfiles (current_program_space))
|
||||
{
|
||||
for (compunit_symtab *cust : objfile_compunits (objfile))
|
||||
add_symtab_completions (cust, tracker, mode, lookup_name,
|
||||
sym_text, word, code);
|
||||
}
|
||||
|
||||
/* Look through the partial symtabs for all symbols which begin by
|
||||
matching SYM_TEXT. Expand all CUs that you find to the list. */
|
||||
|
||||
Reference in New Issue
Block a user