aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ada-exp.y3
-rw-r--r--gdb/ada-lang.c23
-rw-r--r--gdb/block.c14
-rw-r--r--gdb/block.h63
-rw-r--r--gdb/buildsym.c28
-rw-r--r--gdb/c-exp.y4
-rw-r--r--gdb/coffread.c3
-rw-r--r--gdb/compile/compile-object-load.c11
-rw-r--r--gdb/compile/compile.c4
-rw-r--r--gdb/cp-support.c12
-rw-r--r--gdb/guile/scm-symtab.c6
-rw-r--r--gdb/jit.c9
-rw-r--r--gdb/linespec.c7
-rw-r--r--gdb/maint.c2
-rw-r--r--gdb/mdebugread.c84
-rw-r--r--gdb/objfiles.c6
-rw-r--r--gdb/p-exp.y5
-rw-r--r--gdb/parse.c5
-rw-r--r--gdb/psymtab.c4
-rw-r--r--gdb/python/py-symbol.c3
-rw-r--r--gdb/python/py-symtab.c8
-rw-r--r--gdb/symfile-debug.c2
-rw-r--r--gdb/symmisc.c17
-rw-r--r--gdb/symtab.c23
-rw-r--r--gdb/symtab.h9
25 files changed, 194 insertions, 161 deletions
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 60a7c1b..8660205 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -1369,8 +1369,7 @@ block_lookup (const struct block *context, const char *raw_name)
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)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index c06dbc2..42f2851 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4711,12 +4711,13 @@ cache_symbol (const char *name, domain_enum domain, struct symbol *sym,
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);
@@ -5563,7 +5564,7 @@ map_matching_symbols (struct objfile *objfile,
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;
@@ -5592,7 +5593,7 @@ add_nonlocal_symbols (std::vector<struct block_symbol> &result,
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))
@@ -13099,7 +13100,7 @@ ada_add_global_exceptions (compiled_regex *preg,
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;
@@ -13687,7 +13688,7 @@ public:
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))
@@ -13706,7 +13707,7 @@ public:
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;
diff --git a/gdb/block.c b/gdb/block.c
index 2d28f9d..1c3a003 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -147,14 +147,14 @@ find_block_in_blockvector (const struct blockvector *bl, CORE_ADDR pc)
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
@@ -165,7 +165,7 @@ find_block_in_blockvector (const struct blockvector *bl, CORE_ADDR pc)
while (bot >= STATIC_BLOCK)
{
- b = BLOCKVECTOR_BLOCK (bl, bot);
+ b = bl->block (bot);
if (!(b->start () <= pc))
return NULL;
if (b->end () > pc)
@@ -543,8 +543,7 @@ block_iterator_step (struct block_iterator *iterator, int first)
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);
}
@@ -612,8 +611,7 @@ block_iter_match_step (struct block_iterator *iterator,
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);
}
diff --git a/gdb/block.h b/gdb/block.h
index d952430..b6b8b86 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -244,18 +244,71 @@ struct global_block
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. */
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index d0f00d4..48cd967 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -448,11 +448,9 @@ buildsym_compunit::make_blockvector ()
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 ();
@@ -470,15 +468,15 @@ buildsym_compunit::make_blockvector ()
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));
@@ -983,7 +981,7 @@ buildsym_compunit::end_compunit_symtab_with_blockvector
cu->set_blockvector (blockvector);
{
- struct block *b = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
+ struct block *b = blockvector->global_block ();
set_block_compunit_symtab (b, cu);
}
@@ -999,9 +997,9 @@ buildsym_compunit::end_compunit_symtab_with_blockvector
/* 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;
@@ -1130,7 +1128,7 @@ void
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"));
@@ -1143,7 +1141,7 @@ buildsym_compunit::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. */
@@ -1154,7 +1152,7 @@ buildsym_compunit::augment_type_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. */
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index d852b1e..517ab42 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -3110,8 +3110,8 @@ classify_name (struct parser_state *par_state, const struct block *block,
if (symtab)
{
yylval.bval
- = BLOCKVECTOR_BLOCK (symtab->compunit ()->blockvector (),
- STATIC_BLOCK);
+ = symtab->compunit ()->blockvector ()->static_block ();
+
return FILENAME;
}
}
diff --git a/gdb/coffread.c b/gdb/coffread.c
index da871d5..c5e9773 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1476,12 +1476,11 @@ patch_type (struct type *type, struct type *real_type)
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.
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 2835f2d..d393091 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -422,7 +422,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
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++)
@@ -430,7 +430,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
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,
@@ -441,8 +441,8 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
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 ();
@@ -450,8 +450,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
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;
}
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 1c3a618..2843f05 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -484,8 +484,8 @@ get_expr_block_and_pc (CORE_ADDR *pc)
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 ();
}
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 14fad2d..f520558 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1440,7 +1440,7 @@ static void
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. */
@@ -1451,7 +1451,9 @@ add_symbol_overload_list_qualified (const char *func_name,
/* 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));
@@ -1464,7 +1466,7 @@ add_symbol_overload_list_qualified (const char *func_name,
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);
}
}
@@ -1474,10 +1476,12 @@ add_symbol_overload_list_qualified (const char *func_name,
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);
}
}
diff --git a/gdb/guile/scm-symtab.c b/gdb/guile/scm-symtab.c
index 1ba5cb5..518ceea 100644
--- a/gdb/guile/scm-symtab.c
+++ b/gdb/guile/scm-symtab.c
@@ -361,10 +361,9 @@ gdbscm_symtab_global_block (SCM self)
= 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 ());
}
@@ -379,10 +378,9 @@ gdbscm_symtab_static_block (SCM self)
= 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 ());
}
diff --git a/gdb/jit.c b/gdb/jit.c
index 4ff180d..9f2df71 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -565,7 +565,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *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
@@ -598,7 +598,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
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 ())
@@ -626,7 +626,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
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);
@@ -647,8 +647,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
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 ());
}
}
}
diff --git a/gdb/linespec.c b/gdb/linespec.c
index c424b33..3cbb8f8 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1190,9 +1190,9 @@ iterate_over_all_matching_symtabs
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)
@@ -1231,8 +1231,7 @@ iterate_over_file_blocks
{
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);
diff --git a/gdb/maint.c b/gdb/maint.c
index 7b726c2..31b8fd8 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -943,7 +943,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 (cu->blockvector ());
+ nr_blocks += cu->blockvector ()->num_blocks ();
nr_symtabs += std::distance (cu->filetabs ().begin (),
cu->filetabs ().end ());
}
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index cd24296..ca7c15e 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -628,8 +628,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
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);
@@ -770,19 +769,19 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
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);
@@ -1144,12 +1143,11 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
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 */
@@ -1168,10 +1166,8 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
/* 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)
@@ -1967,8 +1963,7 @@ parse_procedure (PDR *pr, struct compunit_symtab *search_symtab,
#else
s = mylookup_symbol
(sh_name,
- BLOCKVECTOR_BLOCK (search_symtab->blockvector (),
- STATIC_BLOCK),
+ search_symtab->blockvector ()->static_block (),
VAR_DOMAIN,
LOC_BLOCK);
#endif
@@ -4099,8 +4094,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 (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;
@@ -4189,8 +4183,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
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;
@@ -4504,12 +4497,13 @@ add_block (struct block *b, struct symtab *s)
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.
@@ -4573,13 +4567,13 @@ sort_blocks (struct symtab *s)
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;
}
/*
@@ -4588,29 +4582,27 @@ sort_blocks (struct symtab *s)
* 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 ());
}
@@ -4635,10 +4627,9 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile)
/* 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");
@@ -4713,8 +4704,7 @@ new_bvect (int nblocks)
size = sizeof (struct blockvector) + nblocks * sizeof (struct block *);
bv = (struct blockvector *) xzalloc (size);
-
- BLOCKVECTOR_NBLOCKS (bv) = nblocks;
+ bv->set_num_blocks (nblocks);
return bv;
}
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index c4b054a..0fec523 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -664,19 +664,17 @@ objfile_relocate1 (struct objfile *objfile,
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]);
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index ffa82f6..7c88df6 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -619,9 +619,8 @@ block : BLOCKNAME
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 ());
diff --git a/gdb/parse.c b/gdb/parse.c
index 52925db..fb308be 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -463,10 +463,11 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
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 ();
}
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index ce29e19..402d608 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1798,7 +1798,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
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
@@ -1819,7 +1819,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
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 (),
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 414a310..02c35ac 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -569,10 +569,9 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
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)
{
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index 0a6ee01..7ed6271 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -176,13 +176,13 @@ static PyObject *
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 ());
}
@@ -192,13 +192,13 @@ static PyObject *
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 ());
}
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index efceef3..bbbcbca 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -246,7 +246,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
{
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,
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 3699e82..68b76bf 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -236,13 +236,9 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
{
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",
@@ -263,8 +259,8 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
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);
@@ -278,11 +274,10 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *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,
@@ -351,7 +346,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
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)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 0367705..31e7160 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2327,7 +2327,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
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)
@@ -2460,7 +2460,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
}
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)
@@ -2810,7 +2810,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
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)
@@ -2835,7 +2835,7 @@ basic_lookup_transparent_type_1 (struct objfile *objfile,
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)
@@ -2980,8 +2980,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
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;
@@ -3030,7 +3029,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
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);
@@ -3089,7 +3088,7 @@ find_symbol_at_address (CORE_ADDR address)
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;
@@ -3406,7 +3405,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
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;
@@ -4869,7 +4868,7 @@ global_symbol_searcher::add_matching_symbols
{
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)
{
@@ -5832,7 +5831,6 @@ add_symtab_completions (struct compunit_symtab *cust,
enum type_code code)
{
struct symbol *sym;
- const struct block *b;
struct block_iterator iter;
int i;
@@ -5842,7 +5840,8 @@ add_symtab_completions (struct compunit_symtab *cust,
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))
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 4028335..8c2837c 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1757,12 +1757,17 @@ struct compunit_symtab
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;
}
@@ -1860,7 +1865,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 *m_blockvector;
+ struct blockvector *m_blockvector;
/* Section in objfile->section_offsets for the blockvector and
the linetable. Probably always SECT_OFF_TEXT. */