symtab = NULL;
if (symtab != NULL)
- result = BLOCKVECTOR_BLOCK (symtab->compunit ()->blockvector (),
- STATIC_BLOCK);
+ result = symtab->compunit ()->blockvector ()->static_block ();
else if (syms.empty () || syms[0].symbol->aclass () != LOC_BLOCK)
{
if (context == NULL)
for that symbol depends on the context. To determine whether
the symbol is local or not, we check the block where we found it
against the global and static blocks of its associated symtab. */
- if (sym
- && BLOCKVECTOR_BLOCK (sym->symtab ()->compunit ()->blockvector (),
- GLOBAL_BLOCK) != block
- && BLOCKVECTOR_BLOCK (sym->symtab ()->compunit ()->blockvector (),
- STATIC_BLOCK) != block)
- return;
+ if (sym != nullptr)
+ {
+ const blockvector &bv = *sym->symtab ()->compunit ()->blockvector ();
+
+ if (bv.global_block () != block && bv.static_block () != block)
+ return;
+ }
h = msymbol_hash (name) % HASH_SIZE;
e = XOBNEW (&sym_cache->cache_space, cache_entry);
for (compunit_symtab *symtab : objfile->compunits ())
{
const struct block *block
- = BLOCKVECTOR_BLOCK (symtab->blockvector (), block_kind);
+ = symtab->blockvector ()->block (block_kind);
if (!iterate_over_symbols_terminated (block, lookup_name,
domain, data))
break;
for (compunit_symtab *cu : objfile->compunits ())
{
const struct block *global_block
- = BLOCKVECTOR_BLOCK (cu->blockvector (), GLOBAL_BLOCK);
+ = cu->blockvector ()->global_block ();
if (ada_add_block_renamings (result, global_block, lookup_name,
domain))
for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
{
- const struct block *b = BLOCKVECTOR_BLOCK (bv, i);
+ const struct block *b = bv->block (i);
struct block_iterator iter;
struct symbol *sym;
for (compunit_symtab *s : objfile->compunits ())
{
QUIT;
- b = BLOCKVECTOR_BLOCK (s->blockvector (), GLOBAL_BLOCK);
+ b = s->blockvector ()->global_block ();
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
if (completion_skip_symbol (mode, sym))
for (compunit_symtab *s : objfile->compunits ())
{
QUIT;
- b = BLOCKVECTOR_BLOCK (s->blockvector (), STATIC_BLOCK);
+ b = s->blockvector ()->static_block ();
/* Don't do this block twice. */
if (b == surrounding_static_block)
continue;
They both have the same START,END values.
Historically this code would choose STATIC_BLOCK over GLOBAL_BLOCK but the
fact that this choice was made was subtle, now we make it explicit. */
- gdb_assert (BLOCKVECTOR_NBLOCKS (bl) >= 2);
+ gdb_assert (bl->blocks ().size () >= 2);
bot = STATIC_BLOCK;
- top = BLOCKVECTOR_NBLOCKS (bl);
+ top = bl->blocks ().size ();
while (top - bot > 1)
{
half = (top - bot + 1) >> 1;
- b = BLOCKVECTOR_BLOCK (bl, bot + half);
+ b = bl->block (bot + half);
if (b->start () <= pc)
bot += half;
else
while (bot >= STATIC_BLOCK)
{
- b = BLOCKVECTOR_BLOCK (bl, bot);
+ b = bl->block (bot);
if (!(b->start () <= pc))
return NULL;
if (b->end () > pc)
if (cust == NULL)
return NULL;
- block = BLOCKVECTOR_BLOCK (cust->blockvector (),
- iterator->which);
+ block = cust->blockvector ()->block (iterator->which);
sym = mdict_iterator_first (block->multidict (),
&iterator->mdict_iter);
}
if (cust == NULL)
return NULL;
- block = BLOCKVECTOR_BLOCK (cust->blockvector (),
- iterator->which);
+ block = cust->blockvector ()->block (iterator->which);
sym = mdict_iter_match_first (block->multidict (), name,
&iterator->mdict_iter);
}
struct blockvector
{
- /* Number of blocks in the list. */
- int nblocks;
+ /* Return a view on the blocks of this blockvector. */
+ gdb::array_view<struct block *> blocks ()
+ {
+ return gdb::array_view<struct block *> (m_blocks, m_num_blocks);
+ }
+
+ /* Const version of the above. */
+ gdb::array_view<const struct block *const> blocks () const
+ {
+ const struct block **blocks = (const struct block **) m_blocks;
+ return gdb::array_view<const struct block *const> (blocks, m_num_blocks);
+ }
+
+ /* Return the block at index I. */
+ struct block *block (size_t i)
+ { return this->blocks ()[i]; }
+
+ /* Const version of the above. */
+ const struct block *block (size_t i) const
+ { return this->blocks ()[i]; }
+
+ /* Set the block at index I. */
+ void set_block (int i, struct block *block)
+ { m_blocks[i] = block; }
+
+ /* Set the number of blocks of this blockvector.
+
+ The storage of blocks is done using a flexible array member, so the number
+ of blocks set here must agree with what was effectively allocated. */
+ void set_num_blocks (int num_blocks)
+ { m_num_blocks = num_blocks; }
+
+ /* Return the number of blocks in this blockvector. */
+ int num_blocks () const
+ { return m_num_blocks; }
+
+ /* Return the global block of this blockvector. */
+ struct block *global_block ()
+ { return this->block (GLOBAL_BLOCK); }
+
+ /* Const version of the above. */
+ const struct block *global_block () const
+ { return this->block (GLOBAL_BLOCK); }
+
+ /* Return the static block of this blockvector. */
+ struct block *static_block ()
+ { return this->block (STATIC_BLOCK); }
+
+ /* Const version of the above. */
+ const struct block *static_block () const
+ { return this->block (STATIC_BLOCK); }
+
/* An address map mapping addresses to blocks in this blockvector.
This pointer is zero if the blocks' start and end addresses are
enough. */
struct addrmap *map;
+
+private:
+ /* Number of blocks in the list. */
+ int m_num_blocks;
+
/* The blocks themselves. */
- struct block *block[1];
+ struct block *m_blocks[1];
};
-#define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks
-#define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n]
#define BLOCKVECTOR_MAP(blocklist) ((blocklist)->map)
/* Return the objfile of BLOCK, which must be non-NULL. */
each block into the list after its subblocks in order to make
sure this is true. */
- BLOCKVECTOR_NBLOCKS (blockvector) = i;
+ blockvector->set_num_blocks (i);
for (next = m_pending_blocks; next; next = next->next)
- {
- BLOCKVECTOR_BLOCK (blockvector, --i) = next->block;
- }
+ blockvector->set_block (--i, next->block);
free_pending_blocks ();
Note: Remember that the first two blocks are the global and static
blocks. We could special case that fact and begin checking at block 2.
To avoid making that assumption we do not. */
- if (BLOCKVECTOR_NBLOCKS (blockvector) > 1)
+ if (blockvector->num_blocks () > 1)
{
- for (i = 1; i < BLOCKVECTOR_NBLOCKS (blockvector); i++)
+ for (i = 1; i < blockvector->num_blocks (); i++)
{
- if (BLOCKVECTOR_BLOCK(blockvector, i - 1)->start ()
- > BLOCKVECTOR_BLOCK(blockvector, i)->start ())
+ if (blockvector->block (i - 1)->start ()
+ > blockvector->block (i)->start ())
{
CORE_ADDR start
- = BLOCKVECTOR_BLOCK(blockvector, i)->start ();
+ = blockvector->block (i)->start ();
complaint (_("block at %s out of order"),
hex_string ((LONGEST) start));
cu->set_blockvector (blockvector);
{
- struct block *b = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
+ struct block *b = blockvector->global_block ();
set_block_compunit_symtab (b, cu);
}
/* The main source file's symtab. */
struct symtab *symtab = cu->primary_filetab ();
- for (block_i = 0; block_i < BLOCKVECTOR_NBLOCKS (blockvector); block_i++)
+ for (block_i = 0; block_i < blockvector->num_blocks (); block_i++)
{
- struct block *block = BLOCKVECTOR_BLOCK (blockvector, block_i);
+ struct block *block = blockvector->block (block_i);
struct symbol *sym;
struct mdict_iterator miter;
buildsym_compunit::augment_type_symtab ()
{
struct compunit_symtab *cust = m_compunit_symtab;
- const struct blockvector *blockvector = cust->blockvector ();
+ struct blockvector *blockvector = cust->blockvector ();
if (!m_context_stack.empty ())
complaint (_("Context stack not empty in augment_type_symtab"));
if (m_file_symbols != NULL)
{
- struct block *block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK);
+ struct block *block = blockvector->static_block ();
/* First mark any symbols without a specified symtab as belonging
to the primary symtab. */
if (m_global_symbols != NULL)
{
- struct block *block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
+ struct block *block = blockvector->global_block ();
/* First mark any symbols without a specified symtab as belonging
to the primary symtab. */
if (symtab)
{
yylval.bval
- = BLOCKVECTOR_BLOCK (symtab->compunit ()->blockvector (),
- STATIC_BLOCK);
+ = symtab->compunit ()->blockvector ()->static_block ();
+
return FILENAME;
}
}
static void
patch_opaque_types (struct symtab *s)
{
- const struct block *b;
struct block_iterator iter;
struct symbol *real_sym;
/* Go through the per-file symbols only. */
- b = BLOCKVECTOR_BLOCK (s->compunit ()->blockvector (), STATIC_BLOCK);
+ const struct block *b = s->compunit ()->blockvector ()->static_block ();
ALL_BLOCK_SYMBOLS (b, iter, real_sym)
{
/* Find completed typedefs to use to fix opaque ones.
symbol_name_match_type::SEARCH_NAME);
bv = func_sym->symtab ()->compunit ()->blockvector ();
- nblocks = BLOCKVECTOR_NBLOCKS (bv);
+ nblocks = bv->num_blocks ();
gdb_ptr_type_sym = NULL;
for (block_loop = 0; block_loop < nblocks; block_loop++)
struct symbol *function = NULL;
const struct block *function_block;
- block = BLOCKVECTOR_BLOCK (bv, block_loop);
+ block = bv->block (block_loop);
if (block->function () != NULL)
continue;
gdb_val_sym = block_lookup_symbol (block,
continue;
function_block = block;
- while (function_block != BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)
- && function_block != BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK))
+ while (function_block != bv->static_block ()
+ && function_block != bv->global_block ())
{
function_block = function_block->superblock ();
function = function_block->function ();
break;
}
if (function != NULL
- && (function_block->superblock ()
- == BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK))
+ && function_block->superblock () == bv->static_block ()
&& symbol_matches_search_name (function, func_matcher))
break;
}
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
if (cursal.symtab)
- block = BLOCKVECTOR_BLOCK (cursal.symtab->compunit ()->blockvector (),
- STATIC_BLOCK);
+ block = cursal.symtab->compunit ()->blockvector ()->static_block ();
+
if (block != NULL)
*pc = block->entry_pc ();
}
add_symbol_overload_list_qualified (const char *func_name,
std::vector<symbol *> *overload_list)
{
- const struct block *b, *surrounding_static_block = 0;
+ const struct block *surrounding_static_block = 0;
/* Look through the partial symtabs for all symbols which begin by
matching FUNC_NAME. Make sure we read that symbol table in. */
/* Search upwards from currently selected frame (so that we can
complete on local vars. */
- for (b = get_selected_block (0); b != NULL; b = b->superblock ())
+ for (const block *b = get_selected_block (0);
+ b != nullptr;
+ b = b->superblock ())
add_symbol_overload_list_block (func_name, b, overload_list);
surrounding_static_block = block_static_block (get_selected_block (0));
for (compunit_symtab *cust : objfile->compunits ())
{
QUIT;
- b = BLOCKVECTOR_BLOCK (cust->blockvector (), GLOBAL_BLOCK);
+ const block *b = cust->blockvector ()->global_block ();
add_symbol_overload_list_block (func_name, b, overload_list);
}
}
for (compunit_symtab *cust : objfile->compunits ())
{
QUIT;
- b = BLOCKVECTOR_BLOCK (cust->blockvector (), STATIC_BLOCK);
+ const block *b = cust->blockvector ()->static_block ();
+
/* Don't do this block twice. */
if (b == surrounding_static_block)
continue;
+
add_symbol_overload_list_block (func_name, b, overload_list);
}
}
= stscm_get_valid_symtab_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct symtab *symtab = st_smob->symtab;
const struct blockvector *blockvector;
- const struct block *block;
blockvector = symtab->compunit ()->blockvector ();
- block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
+ const struct block *block = blockvector->global_block ();
return bkscm_scm_from_block (block, symtab->compunit ()->objfile ());
}
= stscm_get_valid_symtab_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct symtab *symtab = st_smob->symtab;
const struct blockvector *blockvector;
- const struct block *block;
blockvector = symtab->compunit ()->blockvector ();
- block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK);
+ const struct block *block = blockvector->static_block ();
return bkscm_scm_from_block (block, symtab->compunit ()->objfile ());
}
BLOCKVECTOR_MAP (bv) = NULL;
begin = stab->blocks.front ().begin;
end = stab->blocks.front ().end;
- BLOCKVECTOR_NBLOCKS (bv) = actual_nblocks;
+ bv->set_num_blocks (actual_nblocks);
/* First run over all the gdb_block objects, creating a real block
object for each. Simultaneously, keep setting the real_block
new_block->set_function (block_name);
- BLOCKVECTOR_BLOCK (bv, block_idx) = new_block;
+ bv->set_block (block_idx, new_block);
if (begin > new_block->start ())
begin = new_block->start ();
if (end < new_block->end ())
new_block->set_start (begin);
new_block->set_end (end);
- BLOCKVECTOR_BLOCK (bv, i) = new_block;
+ bv->set_block (i, new_block);
if (i == GLOBAL_BLOCK)
set_block_compunit_symtab (new_block, cust);
else
{
/* And if not, we set a default parent block. */
- gdb_block_iter.real_block->set_superblock
- (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK));
+ gdb_block_iter.real_block->set_superblock (bv->static_block ());
}
}
}
int i;
const blockvector *bv = symtab->compunit ()->blockvector ();
- for (i = FIRST_LOCAL_BLOCK; i < BLOCKVECTOR_NBLOCKS (bv); i++)
+ for (i = FIRST_LOCAL_BLOCK; i < bv->num_blocks (); i++)
{
- block = BLOCKVECTOR_BLOCK (bv, i);
+ block = bv->block (i);
state->language->iterate_over_symbols
(block, lookup_name, name_domain,
[&] (block_symbol *bsym)
{
const struct block *block;
- for (block = BLOCKVECTOR_BLOCK (symtab->compunit ()->blockvector (),
- STATIC_BLOCK);
+ for (block = symtab->compunit ()->blockvector ()->static_block ();
block != NULL;
block = block->superblock ())
current_language->iterate_over_symbols (block, name, domain, callback);
for (compunit_symtab *cu : o->compunits ())
{
++nr_compunit_symtabs;
- nr_blocks += BLOCKVECTOR_NBLOCKS (cu->blockvector ());
+ nr_blocks += cu->blockvector ()->num_blocks ();
nr_symtabs += std::distance (cu->filetabs ().begin (),
cu->filetabs ().end ());
}
break;
case stGlobal: /* External symbol, goes into global block. */
- b = BLOCKVECTOR_BLOCK (top_stack->cur_st->compunit ()->blockvector (),
- GLOBAL_BLOCK);
+ b = top_stack->cur_st->compunit ()->blockvector ()->global_block ();
s = new_symbol (name);
s->set_value_address (sh->value);
add_data_symbol (sh, ax, bigend, s, LOC_STATIC, b, objfile, name);
b = top_stack->cur_block;
if (sh->st == stProc)
{
- const struct blockvector *bv
+ struct blockvector *bv
= top_stack->cur_st->compunit ()->blockvector ();
/* The next test should normally be true, but provides a
hook for nested functions (which we don't want to make
global). */
- if (b == BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK))
- b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ if (b == bv->static_block ())
+ b = bv->global_block ();
/* Irix 5 sometimes has duplicate names for the same
function. We want to add such names up at the global
level, not as a nested function. */
else if (sh->value == top_stack->procadr)
- b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ b = bv->global_block ();
}
add_symbol (s, top_stack->cur_st, b);
top_stack->blocktype == stStaticProc))
{
/* Finished with procedure */
- const struct blockvector *bv
+ struct blockvector *bv
= top_stack->cur_st->compunit ()->blockvector ();
struct mdebug_extra_func_info *e;
struct block *cblock = top_stack->cur_block;
struct type *ftype = top_stack->cur_type;
- int i;
top_stack->cur_block->set_end
(top_stack->cur_block->end () + sh->value); /* size */
/* f77 emits proc-level with address bounds==[0,0],
So look for such child blocks, and patch them. */
- for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); i++)
+ for (block *b_bad : bv->blocks ())
{
- struct block *b_bad = BLOCKVECTOR_BLOCK (bv, i);
-
if (b_bad->superblock () == cblock
&& b_bad->start () == top_stack->procadr
&& b_bad->end () == top_stack->procadr)
#else
s = mylookup_symbol
(sh_name,
- BLOCKVECTOR_BLOCK (search_symtab->blockvector (),
- STATIC_BLOCK),
+ search_symtab->blockvector ()->static_block (),
VAR_DOMAIN,
LOC_BLOCK);
#endif
push_parse_stack ();
top_stack->cur_st = cust->primary_filetab ();
- top_stack->cur_block
- = BLOCKVECTOR_BLOCK (cust->blockvector (), STATIC_BLOCK);
+ top_stack->cur_block = cust->blockvector ()->static_block ();
top_stack->cur_block->set_start (pst->text_low (objfile));
top_stack->cur_block->set_end (0);
top_stack->blocktype = stFile;
FIXME, Maybe quit once we have found the right number of ext's? */
top_stack->cur_st = cust->primary_filetab ();
top_stack->cur_block
- = BLOCKVECTOR_BLOCK (top_stack->cur_st->compunit ()->blockvector (),
- GLOBAL_BLOCK);
+ = top_stack->cur_st->compunit ()->blockvector ()->global_block ();
top_stack->blocktype = stFile;
ext_ptr = PST_PRIVATE (pst)->extern_tab;
bv = (struct blockvector *) xrealloc ((void *) bv,
(sizeof (struct blockvector)
- + BLOCKVECTOR_NBLOCKS (bv)
- * sizeof (bv->block)));
+ + bv->num_blocks ()
+ * sizeof (struct block)));
if (bv != s->compunit ()->blockvector ())
s->compunit ()->set_blockvector (bv);
- BLOCKVECTOR_BLOCK (bv, BLOCKVECTOR_NBLOCKS (bv)++) = b;
+ bv->set_block (bv->num_blocks (), b);
+ bv->set_num_blocks (bv->num_blocks () + 1);
}
/* Add a new linenumber entry (LINENO,ADR) to a linevector LT.
struct blockvector *bv
= (struct blockvector *) s->compunit ()->blockvector ();
- if (BLOCKVECTOR_NBLOCKS (bv) <= FIRST_LOCAL_BLOCK)
+ if (bv->num_blocks () <= FIRST_LOCAL_BLOCK)
{
/* Cosmetic */
- if (BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK)->end () == 0)
- BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK)->set_start (0);
- if (BLOCKVECTOR_BLOCK(bv, STATIC_BLOCK)->end () == 0)
- BLOCKVECTOR_BLOCK(bv, STATIC_BLOCK)->set_start (0);
+ if (bv->global_block ()->end () == 0)
+ bv->global_block ()->set_start (0);
+ if (bv->static_block ()->end () == 0)
+ bv->static_block ()->set_start (0);
return;
}
/*
* are very different. It would be nice to find a reliable test
* to detect -O3 images in advance.
*/
- if (BLOCKVECTOR_NBLOCKS (bv) > FIRST_LOCAL_BLOCK + 1)
- std::sort (&BLOCKVECTOR_BLOCK (bv, FIRST_LOCAL_BLOCK),
- &BLOCKVECTOR_BLOCK (bv, BLOCKVECTOR_NBLOCKS (bv)),
- block_is_less_than);
+ if (bv->num_blocks () > FIRST_LOCAL_BLOCK + 1)
+ {
+ gdb::array_view<block *> blocks_view = bv->blocks ();
+
+ std::sort (blocks_view.begin () + FIRST_LOCAL_BLOCK,
+ blocks_view.end (), block_is_less_than);
+ }
{
CORE_ADDR high = 0;
- int i, j = BLOCKVECTOR_NBLOCKS (bv);
+ int i, j = bv->num_blocks ();
for (i = FIRST_LOCAL_BLOCK; i < j; i++)
- if (high < BLOCKVECTOR_BLOCK(bv, i)->end ())
- high = BLOCKVECTOR_BLOCK(bv, i)->end ();
- BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK)->set_end (high);
+ if (high < bv->block (i)->end ())
+ high = bv->block (i)->end ();
+ bv->global_block ()->set_end (high);
}
- BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK)->set_start
- (BLOCKVECTOR_BLOCK(bv, FIRST_LOCAL_BLOCK)->start ());
-
- BLOCKVECTOR_BLOCK(bv, STATIC_BLOCK)->set_start
- (BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK)->start ());
-
- BLOCKVECTOR_BLOCK(bv, STATIC_BLOCK)->set_end
- (BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK)->end ());
+ bv->global_block ()->set_start (bv->block (FIRST_LOCAL_BLOCK)->start ());
+ bv->static_block ()->set_start (bv->global_block ()->start ());
+ bv->static_block ()->set_end (bv->global_block ()->end ());
}
\f
/* All symtabs must have at least two blocks. */
bv = new_bvect (2);
- BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = new_block (NON_FUNCTION_BLOCK, lang);
- BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = new_block (NON_FUNCTION_BLOCK, lang);
- BLOCKVECTOR_BLOCK(bv, STATIC_BLOCK)->set_superblock
- (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK));
+ bv->set_block (GLOBAL_BLOCK, new_block (NON_FUNCTION_BLOCK, lang));
+ bv->set_block (STATIC_BLOCK, new_block (NON_FUNCTION_BLOCK, lang));
+ bv->static_block ()->set_superblock (bv->global_block ());
cust->set_blockvector (bv);
cust->set_debugformat ("ECOFF");
size = sizeof (struct blockvector) + nblocks * sizeof (struct block *);
bv = (struct blockvector *) xzalloc (size);
-
- BLOCKVECTOR_NBLOCKS (bv) = nblocks;
+ bv->set_num_blocks (nblocks);
return bv;
}
for (compunit_symtab *cust : objfile->compunits ())
{
- const struct blockvector *bv = cust->blockvector ();
+ struct blockvector *bv = cust->blockvector ();
int block_line_section = cust->block_line_section ();
if (BLOCKVECTOR_MAP (bv))
addrmap_relocate (BLOCKVECTOR_MAP (bv), delta[block_line_section]);
- for (int i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i)
+ for (block *b : bv->blocks ())
{
- struct block *b;
struct symbol *sym;
struct mdict_iterator miter;
- b = BLOCKVECTOR_BLOCK (bv, i);
b->set_start (b->start () + delta[block_line_section]);
b->set_end (b->end () + delta[block_line_section]);
struct symtab *tem =
lookup_symtab (copy.c_str ());
if (tem)
- $$ = BLOCKVECTOR_BLOCK
- (tem->compunit ()->blockvector (),
- STATIC_BLOCK);
+ $$ = (tem->compunit ()->blockvector ()
+ ->static_block ());
else
error (_("No file or function \"%s\"."),
copy.c_str ());
if (!expression_context_block)
{
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+
if (cursal.symtab)
expression_context_block
- = BLOCKVECTOR_BLOCK (cursal.symtab->compunit ()->blockvector (),
- STATIC_BLOCK);
+ = cursal.symtab->compunit ()->blockvector ()->static_block ();
+
if (expression_context_block)
expression_context_pc = expression_context_block->entry_pc ();
}
if (cust == NULL)
continue;
bv = cust->blockvector ();
- b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+ b = bv->static_block ();
for (partial_symbol *psym : ps->static_psymbols)
{
/* Skip symbols for inlined functions without address. These may
gdb_printf (" psymtab\n");
}
}
- b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ b = bv->global_block ();
for (partial_symbol *psym : ps->global_psymbols)
{
sym = block_lookup_symbol (b, psym->ginfo.search_name (),
for (compunit_symtab *cust : objfile->compunits ())
{
const struct blockvector *bv;
- const struct block *block;
bv = cust->blockvector ();
- block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+ const struct block *block = bv->static_block ();
if (block != nullptr)
{
stpy_global_block (PyObject *self, PyObject *args)
{
struct symtab *symtab = NULL;
- const struct block *block = NULL;
const struct blockvector *blockvector;
STPY_REQUIRE_VALID (self, symtab);
blockvector = symtab->compunit ()->blockvector ();
- block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
+ const struct block *block = blockvector->global_block ();
+
return block_to_block_object (block, symtab->compunit ()->objfile ());
}
stpy_static_block (PyObject *self, PyObject *args)
{
struct symtab *symtab = NULL;
- const struct block *block = NULL;
const struct blockvector *blockvector;
STPY_REQUIRE_VALID (self, symtab);
blockvector = symtab->compunit ()->blockvector ();
- block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK);
+ const struct block *block = blockvector->static_block ();
+
return block_to_block_object (block, symtab->compunit ()->objfile ());
}
{
struct symbol *sym, *with_opaque = NULL;
const struct blockvector *bv = stab->blockvector ();
- const struct block *block = BLOCKVECTOR_BLOCK (bv, kind);
+ const struct block *block = bv->block (kind);
sym = block_find_symbol (block, name, domain,
block_find_non_opaque_type_preferred,
{
struct objfile *objfile = symtab->compunit ()->objfile ();
struct gdbarch *gdbarch = objfile->arch ();
- int i;
struct mdict_iterator miter;
- int len;
struct linetable *l;
- const struct blockvector *bv;
struct symbol *sym;
- const struct block *b;
int depth;
gdb_printf (outfile, "\nSymtab for file %s at %s\n",
if (l)
{
gdb_printf (outfile, "\nLine table:\n\n");
- len = l->nitems;
- for (i = 0; i < len; i++)
+ int len = l->nitems;
+ for (int i = 0; i < len; i++)
{
gdb_printf (outfile, " line %d at ", l->item[i].line);
gdb_puts (paddress (gdbarch, l->item[i].pc), outfile);
if (is_main_symtab_of_compunit_symtab (symtab))
{
gdb_printf (outfile, "\nBlockvector:\n\n");
- bv = symtab->compunit ()->blockvector ();
- len = BLOCKVECTOR_NBLOCKS (bv);
- for (i = 0; i < len; i++)
+ const blockvector *bv = symtab->compunit ()->blockvector ();
+ for (int i = 0; i < bv->num_blocks (); i++)
{
- b = BLOCKVECTOR_BLOCK (bv, i);
+ const block *b = bv->block (i);
depth = block_depth (b) * 2;
gdb_printf (outfile, "%*sblock #%03d, object at %s",
depth, "", i,
gdb_printf (outfile, "Compunit user: %s\n", addr);
}
if (cust->includes != nullptr)
- for (i = 0; ; ++i)
+ for (int i = 0; ; ++i)
{
struct compunit_symtab *include = cust->includes[i];
if (include == nullptr)
struct block_symbol result;
bv = cust->blockvector ();
- block = BLOCKVECTOR_BLOCK (bv, block_index);
+ block = bv->block (block_index);
result.symbol = block_lookup_symbol_primary (block, name, domain);
result.block = block;
if (result.symbol == NULL)
}
bv = cust->blockvector ();
- block = BLOCKVECTOR_BLOCK (bv, block_index);
+ block = bv->block (block_index);
result.symbol = block_lookup_symbol (block, name,
symbol_name_match_type::FULL, domain);
if (result.symbol == NULL)
return NULL;
bv = cust->blockvector ();
- block = BLOCKVECTOR_BLOCK (bv, block_index);
+ block = bv->block (block_index);
sym = block_find_symbol (block, name, STRUCT_DOMAIN,
block_find_non_opaque_type, NULL);
if (sym == NULL)
for (compunit_symtab *cust : objfile->compunits ())
{
bv = cust->blockvector ();
- block = BLOCKVECTOR_BLOCK (bv, block_index);
+ block = bv->block (block_index);
sym = block_find_symbol (block, name, STRUCT_DOMAIN,
block_find_non_opaque_type, NULL);
if (sym != NULL)
for (compunit_symtab *cust : obj_file->compunits ())
{
const struct blockvector *bv = cust->blockvector ();
- const struct block *global_block
- = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ const struct block *global_block = bv->global_block ();
CORE_ADDR start = global_block->start ();
CORE_ADDR end = global_block->end ();
bool in_range_p = start <= pc && pc < end;
b_index <= STATIC_BLOCK && sym == NULL;
++b_index)
{
- const struct block *b = BLOCKVECTOR_BLOCK (bv, b_index);
+ const struct block *b = bv->block (b_index);
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
fixup_symbol_section (sym, obj_file);
for (int i = GLOBAL_BLOCK; i <= STATIC_BLOCK; ++i)
{
- const struct block *b = BLOCKVECTOR_BLOCK (bv, i);
+ const struct block *b = bv->block (i);
struct block_iterator iter;
struct symbol *sym;
else if (alt)
val.end = alt->pc;
else
- val.end = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)->end ();
+ val.end = bv->global_block ()->end ();
}
val.section = section;
return val;
{
struct block_iterator iter;
struct symbol *sym;
- const struct block *b = BLOCKVECTOR_BLOCK (bv, block);
+ const struct block *b = bv->block (block);
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
enum type_code code)
{
struct symbol *sym;
- const struct block *b;
struct block_iterator iter;
int i;
for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
{
QUIT;
- b = BLOCKVECTOR_BLOCK (cust->blockvector (), i);
+
+ const struct block *b = cust->blockvector ()->block (i);
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
if (completion_skip_symbol (mode, sym))
m_dirname = dirname;
}
+ struct blockvector *blockvector ()
+ {
+ return m_blockvector;
+ }
+
const struct blockvector *blockvector () const
{
return m_blockvector;
}
- void set_blockvector (const struct blockvector *blockvector)
+ void set_blockvector (struct blockvector *blockvector)
{
m_blockvector = blockvector;
}
/* List of all symbol scope blocks for this symtab. It is shared among
all symtabs in a given compilation unit. */
- const struct blockvector *m_blockvector;
+ struct blockvector *m_blockvector;
/* Section in objfile->section_offsets for the blockvector and
the linetable. Probably always SECT_OFF_TEXT. */