gdb: remove COMPUNIT_BLOCKVECTOR macro, add getter/setter

Add a getter and a setter for a compunit_symtab's blockvector.  Remove
the corresponding macro and adjust all callers.

Change-Id: I99484c6619dcbbea7c5d89c72aa660316ca62f64
This commit is contained in:
Simon Marchi 2021-11-19 22:25:23 -05:00 committed by Simon Marchi
parent 0d9acb4531
commit af39c5c874
15 changed files with 48 additions and 39 deletions

View File

@ -5237,7 +5237,7 @@ map_matching_symbols (struct objfile *objfile,
for (compunit_symtab *symtab : objfile->compunits ())
{
const struct block *block
= BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (symtab), block_kind);
= BLOCKVECTOR_BLOCK (symtab->blockvector (), block_kind);
if (!iterate_over_symbols_terminated (block, lookup_name,
domain, data))
break;
@ -5266,7 +5266,7 @@ add_nonlocal_symbols (std::vector<struct block_symbol> &result,
for (compunit_symtab *cu : objfile->compunits ())
{
const struct block *global_block
= BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cu), GLOBAL_BLOCK);
= BLOCKVECTOR_BLOCK (cu->blockvector (), GLOBAL_BLOCK);
if (ada_add_block_renamings (result, global_block, lookup_name,
domain))
@ -12617,7 +12617,7 @@ ada_add_global_exceptions (compiled_regex *preg,
{
for (compunit_symtab *s : objfile->compunits ())
{
const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (s);
const struct blockvector *bv = s->blockvector ();
int i;
for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
@ -13204,7 +13204,7 @@ public:
for (compunit_symtab *s : objfile->compunits ())
{
QUIT;
b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK);
b = BLOCKVECTOR_BLOCK (s->blockvector (), GLOBAL_BLOCK);
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
if (completion_skip_symbol (mode, sym))
@ -13223,7 +13223,7 @@ public:
for (compunit_symtab *s : objfile->compunits ())
{
QUIT;
b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK);
b = BLOCKVECTOR_BLOCK (s->blockvector (), STATIC_BLOCK);
/* Don't do this block twice. */
if (b == surrounding_static_block)
continue;

View File

@ -197,7 +197,7 @@ blockvector_for_pc_sect (CORE_ADDR pc, struct obj_section *section,
return 0;
}
bl = COMPUNIT_BLOCKVECTOR (cust);
bl = cust->blockvector ();
/* Then search that symtab for the smallest block that wins. */
b = find_block_in_blockvector (bl, pc);
@ -543,7 +543,7 @@ block_iterator_step (struct block_iterator *iterator, int first)
if (cust == NULL)
return NULL;
block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
block = BLOCKVECTOR_BLOCK (cust->blockvector (),
iterator->which);
sym = mdict_iterator_first (BLOCK_MULTIDICT (block),
&iterator->mdict_iter);
@ -612,7 +612,7 @@ block_iter_match_step (struct block_iterator *iterator,
if (cust == NULL)
return NULL;
block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
block = BLOCKVECTOR_BLOCK (cust->blockvector (),
iterator->which);
sym = mdict_iter_match_first (BLOCK_MULTIDICT (block), name,
&iterator->mdict_iter);

View File

@ -1015,7 +1015,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
/* Similarly for the producer. */
cu->set_producer (m_producer);
COMPUNIT_BLOCKVECTOR (cu) = blockvector;
cu->set_blockvector (blockvector);
{
struct block *b = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
@ -1163,7 +1163,7 @@ void
buildsym_compunit::augment_type_symtab ()
{
struct compunit_symtab *cust = m_compunit_symtab;
const struct blockvector *blockvector = COMPUNIT_BLOCKVECTOR (cust);
const struct blockvector *blockvector = cust->blockvector ();
if (!m_context_stack.empty ())
complaint (_("Context stack not empty in augment_type_symtab"));

View File

@ -1464,7 +1464,7 @@ add_symbol_overload_list_qualified (const char *func_name,
for (compunit_symtab *cust : objfile->compunits ())
{
QUIT;
b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), GLOBAL_BLOCK);
b = BLOCKVECTOR_BLOCK (cust->blockvector (), GLOBAL_BLOCK);
add_symbol_overload_list_block (func_name, b, overload_list);
}
}
@ -1474,7 +1474,7 @@ add_symbol_overload_list_qualified (const char *func_name,
for (compunit_symtab *cust : objfile->compunits ())
{
QUIT;
b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
b = BLOCKVECTOR_BLOCK (cust->blockvector (), STATIC_BLOCK);
/* Don't do this block twice. */
if (b == surrounding_static_block)
continue;

View File

@ -4451,8 +4451,8 @@ recursively_find_pc_sect_compunit_symtab (struct compunit_symtab *cust,
{
int i;
if (COMPUNIT_BLOCKVECTOR (cust) != NULL
&& blockvector_contains_pc (COMPUNIT_BLOCKVECTOR (cust), pc))
if (cust->blockvector () != nullptr
&& blockvector_contains_pc (cust->blockvector (), pc))
return cust;
if (cust->includes == NULL)

View File

@ -531,7 +531,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
+ (actual_nblocks - 1) * sizeof (struct block *));
bv = (struct blockvector *) obstack_alloc (&objfile->objfile_obstack,
blockvector_size);
COMPUNIT_BLOCKVECTOR (cust) = bv;
cust->set_blockvector (bv);
/* At the end of this function, (begin, end) will contain the PC range this
entire blockvector spans. */

View File

@ -946,7 +946,7 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
for (compunit_symtab *cu : o->compunits ())
{
++nr_compunit_symtabs;
nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu));
nr_blocks += BLOCKVECTOR_NBLOCKS (cu->blockvector ());
nr_symtabs += std::distance (cu->filetabs ().begin (),
cu->filetabs ().end ());
}

View File

@ -1965,7 +1965,7 @@ parse_procedure (PDR *pr, struct compunit_symtab *search_symtab,
#else
s = mylookup_symbol
(sh_name,
BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (search_symtab),
BLOCKVECTOR_BLOCK (search_symtab->blockvector (),
STATIC_BLOCK),
VAR_DOMAIN,
LOC_BLOCK);
@ -4096,7 +4096,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
push_parse_stack ();
top_stack->cur_st = cust->primary_filetab ();
top_stack->cur_block
= BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
= BLOCKVECTOR_BLOCK (cust->blockvector (), STATIC_BLOCK);
BLOCK_START (top_stack->cur_block) = pst->text_low (objfile);
BLOCK_END (top_stack->cur_block) = 0;
top_stack->blocktype = stFile;
@ -4502,7 +4502,7 @@ add_block (struct block *b, struct symtab *s)
+ BLOCKVECTOR_NBLOCKS (bv)
* sizeof (bv->block)));
if (bv != SYMTAB_BLOCKVECTOR (s))
SYMTAB_BLOCKVECTOR (s) = bv;
SYMTAB_COMPUNIT (s)->set_blockvector (bv);
BLOCKVECTOR_BLOCK (bv, BLOCKVECTOR_NBLOCKS (bv)++) = b;
}
@ -4632,7 +4632,7 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile)
BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = new_block (NON_FUNCTION_BLOCK, lang);
BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
COMPUNIT_BLOCKVECTOR (cust) = bv;
cust->set_blockvector (bv);
cust->set_debugformat ("ECOFF");
return cust;

View File

@ -667,7 +667,7 @@ objfile_relocate1 (struct objfile *objfile,
for (compunit_symtab *cust : objfile->compunits ())
{
const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
const struct blockvector *bv = cust->blockvector ();
int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
if (BLOCKVECTOR_MAP (bv))

View File

@ -1801,7 +1801,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
/* Now do checks requiring the associated symtab. */
if (cust == NULL)
continue;
bv = COMPUNIT_BLOCKVECTOR (cust);
bv = cust->blockvector ();
b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
for (partial_symbol *psym : ps->static_psymbols)
{

View File

@ -571,7 +571,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
const struct blockvector *bv;
const struct block *block;
bv = COMPUNIT_BLOCKVECTOR (cust);
bv = cust->blockvector ();
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
if (block != nullptr)

View File

@ -245,7 +245,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
auto search_one_symtab = [&] (compunit_symtab *stab)
{
struct symbol *sym, *with_opaque = NULL;
const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (stab);
const struct blockvector *bv = stab->blockvector ();
const struct block *block = BLOCKVECTOR_BLOCK (bv, kind);
sym = block_find_symbol (block, name, domain,

View File

@ -787,7 +787,7 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
printf_filtered (" blockvector"
" ((struct blockvector *) %s)\n",
host_address_to_string
(COMPUNIT_BLOCKVECTOR (cust)));
(cust->blockvector ()));
printf_filtered (" user"
" ((struct compunit_symtab *) %s)\n",
cust->user != nullptr
@ -863,7 +863,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
QUIT;
if (COMPUNIT_BLOCKVECTOR (cust) == NULL)
if (cust->blockvector () == NULL)
found_something = 1;
/* Add more checks here. */
@ -879,7 +879,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
}
printf_filtered (" { symtab %s\n",
symtab_to_filename_for_display (symtab));
if (COMPUNIT_BLOCKVECTOR (cust) == NULL)
if (cust->blockvector () == NULL)
printf_filtered (" NULL blockvector\n");
printf_filtered (" }\n");
}

View File

@ -2309,7 +2309,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
const struct block *block;
struct block_symbol result;
bv = COMPUNIT_BLOCKVECTOR (cust);
bv = cust->blockvector ();
block = BLOCKVECTOR_BLOCK (bv, block_index);
result.symbol = block_lookup_symbol_primary (block, name, domain);
result.block = block;
@ -2442,7 +2442,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
return {};
}
bv = COMPUNIT_BLOCKVECTOR (cust);
bv = cust->blockvector ();
block = BLOCKVECTOR_BLOCK (bv, block_index);
result.symbol = block_lookup_symbol (block, name,
symbol_name_match_type::FULL, domain);
@ -2792,7 +2792,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
if (cust == NULL)
return NULL;
bv = COMPUNIT_BLOCKVECTOR (cust);
bv = cust->blockvector ();
block = BLOCKVECTOR_BLOCK (bv, block_index);
sym = block_find_symbol (block, name, STRUCT_DOMAIN,
block_find_non_opaque_type, NULL);
@ -2817,7 +2817,7 @@ basic_lookup_transparent_type_1 (struct objfile *objfile,
for (compunit_symtab *cust : objfile->compunits ())
{
bv = COMPUNIT_BLOCKVECTOR (cust);
bv = cust->blockvector ();
block = BLOCKVECTOR_BLOCK (bv, block_index);
sym = block_find_symbol (block, name, STRUCT_DOMAIN,
block_find_non_opaque_type, NULL);
@ -2962,7 +2962,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
{
for (compunit_symtab *cust : obj_file->compunits ())
{
const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
const struct blockvector *bv = cust->blockvector ();
const struct block *global_block
= BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
CORE_ADDR start = BLOCK_START (global_block);
@ -3068,7 +3068,7 @@ find_symbol_at_address (CORE_ADDR address)
ADDR. */
auto search_symtab = [] (compunit_symtab *symtab, CORE_ADDR addr) -> symbol *
{
const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (symtab);
const struct blockvector *bv = symtab->blockvector ();
for (int i = GLOBAL_BLOCK; i <= STATIC_BLOCK; ++i)
{
@ -3276,7 +3276,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
return val;
}
bv = COMPUNIT_BLOCKVECTOR (cust);
bv = cust->blockvector ();
/* Look at all the symtabs that share this blockvector.
They all have the same apriori range, that we found was right;
@ -4793,7 +4793,7 @@ global_symbol_searcher::add_matching_symbols
/* Add matching symbols (if not already present). */
for (compunit_symtab *cust : objfile->compunits ())
{
const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
const struct blockvector *bv = cust->blockvector ();
for (block_enum block : { GLOBAL_BLOCK, STATIC_BLOCK })
{
@ -5773,7 +5773,7 @@ add_symtab_completions (struct compunit_symtab *cust,
for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
{
QUIT;
b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), i);
b = BLOCKVECTOR_BLOCK (cust->blockvector (), i);
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
if (completion_skip_symbol (mode, sym))

View File

@ -1409,7 +1409,7 @@ using symtab_range = next_range<symtab>;
#define SYMTAB_LINETABLE(symtab) ((symtab)->linetable)
#define SYMTAB_LANGUAGE(symtab) ((symtab)->language)
#define SYMTAB_BLOCKVECTOR(symtab) \
COMPUNIT_BLOCKVECTOR (SYMTAB_COMPUNIT (symtab))
(SYMTAB_COMPUNIT (symtab)->blockvector ())
#define SYMTAB_OBJFILE(symtab) \
(SYMTAB_COMPUNIT (symtab)->objfile ())
#define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace)
@ -1511,6 +1511,16 @@ struct compunit_symtab
m_dirname = dirname;
}
const struct blockvector *blockvector () const
{
return m_blockvector;
}
void set_blockvector (const struct blockvector *blockvector)
{
m_blockvector = blockvector;
}
/* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
PRIMARY_FILETAB must already be a filetab of this compunit symtab. */
@ -1564,7 +1574,7 @@ struct compunit_symtab
/* List of all symbol scope blocks for this symtab. It is shared among
all symtabs in a given compilation unit. */
const struct blockvector *blockvector;
const struct blockvector *m_blockvector;
/* Section in objfile->section_offsets for the blockvector and
the linetable. Probably always SECT_OFF_TEXT. */
@ -1606,7 +1616,6 @@ struct compunit_symtab
using compunit_symtab_range = next_range<compunit_symtab>;
#define COMPUNIT_BLOCKVECTOR(cust) ((cust)->blockvector)
#define COMPUNIT_BLOCK_LINE_SECTION(cust) ((cust)->block_line_section)
#define COMPUNIT_LOCATIONS_VALID(cust) ((cust)->locations_valid)
#define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid)