gdb: remove BLOCK_SUPERBLOCK macro

Replace with equivalent methods.

Change-Id: I334a319909a50b5cc5570a45c38c70e10dc00630
This commit is contained in:
Simon Marchi 2022-01-28 11:41:38 -05:00 committed by Simon Marchi
parent 6c00f721c8
commit f135fe728e
26 changed files with 92 additions and 84 deletions

View File

@ -5334,7 +5334,7 @@ ada_add_local_symbols (std::vector<struct block_symbol> &result,
if (block->function () != nullptr && is_nonfunction (result))
return;
block = BLOCK_SUPERBLOCK (block);
block = block->superblock ();
}
}
@ -13040,7 +13040,7 @@ ada_add_exceptions_from_frame (compiled_regex *preg,
}
if (block->function () != NULL)
break;
block = BLOCK_SUPERBLOCK (block);
block = block->superblock ();
}
}
@ -13662,9 +13662,9 @@ public:
/* Search upwards from currently selected frame (so that we can
complete on local vars. */
for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b))
for (b = get_selected_block (0); b != NULL; b = b->superblock ())
{
if (!BLOCK_SUPERBLOCK (b))
if (!b->superblock ())
surrounding_static_block = b; /* For elmin of dups */
ALL_BLOCK_SYMBOLS (b, iter, sym)

View File

@ -82,7 +82,7 @@ contained_in (const struct block *a, const struct block *b,
except if A was inlined. */
if (!allow_nested && a->function () != NULL && !block_inlined_p (a))
return false;
a = BLOCK_SUPERBLOCK (a);
a = a->superblock ();
}
while (a != NULL);
@ -99,8 +99,8 @@ struct symbol *
block_linkage_function (const struct block *bl)
{
while ((bl->function () == NULL || block_inlined_p (bl))
&& BLOCK_SUPERBLOCK (bl) != NULL)
bl = BLOCK_SUPERBLOCK (bl);
&& bl->superblock () != NULL)
bl = bl->superblock ();
return bl->function ();
}
@ -113,8 +113,8 @@ block_linkage_function (const struct block *bl)
struct symbol *
block_containing_function (const struct block *bl)
{
while (bl->function () == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
bl = BLOCK_SUPERBLOCK (bl);
while (bl->function () == NULL && bl->superblock () != NULL)
bl = bl->superblock ();
return bl->function ();
}
@ -295,7 +295,7 @@ block_for_pc (CORE_ADDR pc)
const char *
block_scope (const struct block *block)
{
for (; block != NULL; block = BLOCK_SUPERBLOCK (block))
for (; block != NULL; block = block->superblock ())
{
if (BLOCK_NAMESPACE (block) != NULL
&& BLOCK_NAMESPACE (block)->scope != NULL)
@ -360,11 +360,11 @@ block_initialize_namespace (struct block *block, struct obstack *obstack)
const struct block *
block_static_block (const struct block *block)
{
if (block == NULL || BLOCK_SUPERBLOCK (block) == NULL)
if (block == NULL || block->superblock () == NULL)
return NULL;
while (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) != NULL)
block = BLOCK_SUPERBLOCK (block);
while (block->superblock ()->superblock () != NULL)
block = block->superblock ();
return block;
}
@ -378,8 +378,8 @@ block_global_block (const struct block *block)
if (block == NULL)
return NULL;
while (BLOCK_SUPERBLOCK (block) != NULL)
block = BLOCK_SUPERBLOCK (block);
while (block->superblock () != NULL)
block = block->superblock ();
return block;
}
@ -418,7 +418,7 @@ set_block_compunit_symtab (struct block *block, struct compunit_symtab *cu)
{
struct global_block *gb;
gdb_assert (BLOCK_SUPERBLOCK (block) == NULL);
gdb_assert (block->superblock () == NULL);
gb = (struct global_block *) block;
gdb_assert (gb->compunit_symtab == NULL);
gb->compunit_symtab = cu;
@ -446,7 +446,7 @@ get_block_compunit_symtab (const struct block *block)
{
struct global_block *gb;
gdb_assert (BLOCK_SUPERBLOCK (block) == NULL);
gdb_assert (block->superblock () == NULL);
gb = (struct global_block *) block;
gdb_assert (gb->compunit_symtab != NULL);
return gb->compunit_symtab;
@ -467,15 +467,15 @@ initialize_block_iterator (const struct block *block,
iter->idx = -1;
if (BLOCK_SUPERBLOCK (block) == NULL)
if (block->superblock () == NULL)
{
which = GLOBAL_BLOCK;
cu = get_block_compunit_symtab (block);
}
else if (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL)
else if (block->superblock ()->superblock () == NULL)
{
which = STATIC_BLOCK;
cu = get_block_compunit_symtab (BLOCK_SUPERBLOCK (block));
cu = get_block_compunit_symtab (block->superblock ());
}
else
{
@ -775,8 +775,8 @@ block_lookup_symbol_primary (const struct block *block, const char *name,
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
/* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */
gdb_assert (BLOCK_SUPERBLOCK (block) == NULL
|| BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL);
gdb_assert (block->superblock () == NULL
|| block->superblock ()->superblock () == NULL);
other = NULL;
for (sym
@ -838,8 +838,8 @@ block_find_symbol (const struct block *block, const char *name,
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
/* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */
gdb_assert (BLOCK_SUPERBLOCK (block) == NULL
|| BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL);
gdb_assert (block->superblock () == NULL
|| block->superblock ()->superblock () == NULL);
ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym)
{

View File

@ -114,6 +114,14 @@ struct block
void set_function (symbol *function)
{ m_function = function; }
/* Return this block's superblock. */
const block *superblock () const
{ return m_superblock; }
/* Set this block's superblock. */
void set_superblock (const block *superblock)
{ m_superblock = superblock; }
/* Addresses in the executable code that are in this block. */
CORE_ADDR m_start;
@ -130,7 +138,7 @@ struct block
case of C) is the STATIC_BLOCK. The superblock of the
STATIC_BLOCK is the GLOBAL_BLOCK. */
const struct block *superblock;
const struct block *m_superblock;
/* This is used to store the symbols in the block. */
@ -162,7 +170,6 @@ struct global_block
struct compunit_symtab *compunit_symtab;
};
#define BLOCK_SUPERBLOCK(bl) (bl)->superblock
#define BLOCK_MULTIDICT(bl) (bl)->multidict
#define BLOCK_NAMESPACE(bl) (bl)->namespace_info

View File

@ -75,7 +75,7 @@ get_frame_block (struct frame_info *frame, CORE_ADDR *addr_in_block)
if (block_inlined_p (bl))
inline_count--;
bl = BLOCK_SUPERBLOCK (bl);
bl = bl->superblock ();
gdb_assert (bl != NULL);
}
@ -122,8 +122,8 @@ get_frame_function (struct frame_info *frame)
if (bl == NULL)
return NULL;
while (bl->function () == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
bl = BLOCK_SUPERBLOCK (bl);
while (bl->function () == NULL && bl->superblock () != NULL)
bl = bl->superblock ();
return bl->function ();
}

View File

@ -331,7 +331,7 @@ buildsym_compunit::finish_block_internal
pblock && pblock != old_blocks;
pblock = pblock->next)
{
if (BLOCK_SUPERBLOCK (pblock->block) == NULL)
if (pblock->block->superblock () == NULL)
{
/* Check to be sure the blocks are nested as we receive
them. If the compiler/assembler/linker work, this just
@ -365,7 +365,7 @@ buildsym_compunit::finish_block_internal
if (pblock->block->end () > block->end ())
pblock->block->set_end (block->end ());
}
BLOCK_SUPERBLOCK (pblock->block) = block;
pblock->block->set_superblock (block);
}
opblock = pblock;
}

View File

@ -647,7 +647,7 @@ generate_c_for_variable_locations (compile_instance *compiler,
done. */
if (block->function () != NULL)
break;
block = BLOCK_SUPERBLOCK (block);
block = block->superblock ();
}
return registers_used;

View File

@ -444,13 +444,13 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
while (function_block != BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)
&& function_block != BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK))
{
function_block = BLOCK_SUPERBLOCK (function_block);
function_block = function_block->superblock ();
function = function_block->function ();
if (function != NULL)
break;
}
if (function != NULL
&& (BLOCK_SUPERBLOCK (function_block)
&& (function_block->superblock ()
== BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK))
&& symbol_matches_search_name (function, func_matcher))
break;

View File

@ -547,7 +547,7 @@ cp_lookup_symbol_imports_or_template (const char *scope,
struct type *context;
std::string name_copy (function->natural_name ());
const struct language_defn *lang = language_def (language_cplus);
const struct block *parent = BLOCK_SUPERBLOCK (block);
const struct block *parent = block->superblock ();
struct symbol *sym;
while (1)
@ -615,7 +615,7 @@ cp_lookup_symbol_via_all_imports (const char *scope, const char *name,
if (sym.symbol)
return sym;
block = BLOCK_SUPERBLOCK (block);
block = block->superblock ();
}
return {};

View File

@ -1400,7 +1400,7 @@ add_symbol_overload_list_using (const char *func_name,
for (block = get_selected_block (0);
block != NULL;
block = BLOCK_SUPERBLOCK (block))
block = block->superblock ())
for (current = block_using (block);
current != NULL;
current = current->next)
@ -1451,7 +1451,7 @@ 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 = BLOCK_SUPERBLOCK (b))
for (b = get_selected_block (0); b != NULL; b = b->superblock ())
add_symbol_overload_list_block (func_name, b, overload_list);
surrounding_static_block = block_static_block (get_selected_block (0));

View File

@ -491,7 +491,7 @@ d_lookup_symbol_module (const char *scope, const char *name,
if (sym.symbol != NULL)
return sym;
block = BLOCK_SUPERBLOCK (block);
block = block->superblock ();
}
return {};

View File

@ -690,7 +690,7 @@ info_common_command (const char *comname, int from_tty)
continue to its superblock, the block of per-file symbols. */
if (block->function ())
break;
block = BLOCK_SUPERBLOCK (block);
block = block->superblock ();
}
if (!values_printed)

View File

@ -559,7 +559,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
else
/* We must be in some function nested lexical block. Just get the
outer block: both must share the same frame. */
frame_block = BLOCK_SUPERBLOCK (frame_block);
frame_block = frame_block->superblock ();
}
/* Old compilers may not provide a static link, or they may provide an

View File

@ -433,7 +433,7 @@ go_block_package_name (const struct block *block)
return NULL;
}
block = BLOCK_SUPERBLOCK (block);
block = block->superblock ();
}
return NULL;

View File

@ -151,9 +151,9 @@ bkscm_print_block_smob (SCM self, SCM port, scm_print_state *pstate)
gdbscm_printf (port, "#<%s", block_smob_name);
if (BLOCK_SUPERBLOCK (b) == NULL)
if (b->superblock () == NULL)
gdbscm_printf (port, " global");
else if (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (b)) == NULL)
else if (b->superblock ()->superblock () == NULL)
gdbscm_printf (port, " static");
if (b->function () != NULL)
@ -421,7 +421,7 @@ gdbscm_block_superblock (SCM self)
const struct block *block = b_smob->block;
const struct block *super_block;
super_block = BLOCK_SUPERBLOCK (block);
super_block = block->superblock ();
if (super_block)
return bkscm_scm_from_block (super_block, b_smob->objfile);
@ -456,7 +456,7 @@ gdbscm_block_static_block (SCM self)
const struct block *block = b_smob->block;
const struct block *static_block;
if (BLOCK_SUPERBLOCK (block) == NULL)
if (block->superblock () == NULL)
return SCM_BOOL_F;
static_block = block_static_block (block);
@ -474,7 +474,7 @@ gdbscm_block_global_p (SCM self)
= bkscm_get_valid_block_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct block *block = b_smob->block;
return scm_from_bool (BLOCK_SUPERBLOCK (block) == NULL);
return scm_from_bool (block->superblock () == NULL);
}
/* (block-static? <gdb:block>) -> boolean
@ -487,8 +487,8 @@ gdbscm_block_static_p (SCM self)
= bkscm_get_valid_block_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct block *block = b_smob->block;
if (BLOCK_SUPERBLOCK (block) != NULL
&& BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL)
if (block->superblock () != NULL
&& block->superblock ()->superblock () == NULL)
return SCM_BOOL_T;
return SCM_BOOL_F;
}

View File

@ -612,7 +612,7 @@ gdbscm_frame_block (SCM self)
for (fn_block = block;
fn_block != NULL && fn_block->function () == NULL;
fn_block = BLOCK_SUPERBLOCK (fn_block))
fn_block = fn_block->superblock ())
continue;
if (block == NULL || fn_block == NULL || fn_block->function () == NULL)

View File

@ -226,14 +226,14 @@ inline_frame_sniffer (const struct frame_unwind *self,
location. */
depth = 0;
cur_block = frame_block;
while (BLOCK_SUPERBLOCK (cur_block))
while (cur_block->superblock ())
{
if (block_inlined_p (cur_block))
depth++;
else if (cur_block->function () != NULL)
break;
cur_block = BLOCK_SUPERBLOCK (cur_block);
cur_block = cur_block->superblock ();
}
/* Check how many inlined functions already have frames. */
@ -356,7 +356,7 @@ skip_inline_frames (thread_info *thread, bpstat *stop_chain)
if (frame_block != NULL)
{
cur_block = frame_block;
while (BLOCK_SUPERBLOCK (cur_block))
while (cur_block->superblock ())
{
if (block_inlined_p (cur_block))
{
@ -380,7 +380,7 @@ skip_inline_frames (thread_info *thread, bpstat *stop_chain)
else if (cur_block->function () != NULL)
break;
cur_block = BLOCK_SUPERBLOCK (cur_block);
cur_block = cur_block->superblock ();
}
}

View File

@ -620,7 +620,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
: allocate_block (&objfile->objfile_obstack));
BLOCK_MULTIDICT (new_block)
= mdict_create_linear (&objfile->objfile_obstack, NULL);
BLOCK_SUPERBLOCK (new_block) = block_iter;
new_block->set_superblock (block_iter);
block_iter = new_block;
new_block->set_start (begin);
@ -640,14 +640,15 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
{
/* If the plugin specifically mentioned a parent block, we
use that. */
BLOCK_SUPERBLOCK (gdb_block_iter.real_block) =
gdb_block_iter.parent->real_block;
gdb_block_iter.real_block->set_superblock
(gdb_block_iter.parent->real_block);
}
else
{
/* And if not, we set a default parent block. */
BLOCK_SUPERBLOCK (gdb_block_iter.real_block) =
BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
gdb_block_iter.real_block->set_superblock
(BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK));
}
}
}

View File

@ -1234,7 +1234,7 @@ iterate_over_file_blocks
for (block = BLOCKVECTOR_BLOCK (symtab->compunit ()->blockvector (),
STATIC_BLOCK);
block != NULL;
block = BLOCK_SUPERBLOCK (block))
block = block->superblock ())
current_language->iterate_over_symbols (block, name, domain, callback);
}
@ -3968,7 +3968,7 @@ find_label_symbols (struct linespec_state *self,
for (;
block && !block->function ();
block = BLOCK_SUPERBLOCK (block))
block = block->superblock ())
;
if (!block)

View File

@ -800,7 +800,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
b->set_function (s);
b->set_start (sh->value);
b->set_end (sh->value);
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
b->set_superblock (top_stack->cur_block);
add_block (b, top_stack->cur_st);
/* Not if we only have partial info. */
@ -1128,7 +1128,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
top_stack->blocktype = stBlock;
b = new_block (NON_FUNCTION_BLOCK, psymtab_language);
b->set_start (sh->value + top_stack->procadr);
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
b->set_superblock (top_stack->cur_block);
top_stack->cur_block = b;
add_block (b, top_stack->cur_st);
break;
@ -1172,7 +1172,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
{
struct block *b_bad = BLOCKVECTOR_BLOCK (bv, i);
if (BLOCK_SUPERBLOCK (b_bad) == cblock
if (b_bad->superblock () == cblock
&& b_bad->start () == top_stack->procadr
&& b_bad->end () == top_stack->procadr)
{
@ -4476,7 +4476,7 @@ mylookup_symbol (const char *name, const struct block *block,
return sym;
}
block = BLOCK_SUPERBLOCK (block);
block = block->superblock ();
if (block)
return mylookup_symbol (name, block, domain, theclass);
return 0;
@ -4637,8 +4637,8 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile)
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);
BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
BLOCKVECTOR_BLOCK(bv, STATIC_BLOCK)->set_superblock
(BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK));
cust->set_blockvector (bv);
cust->set_debugformat ("ECOFF");

View File

@ -674,7 +674,7 @@ list_args_or_locals (const frame_print_options &fp_opts,
if (block->function ())
break;
else
block = BLOCK_SUPERBLOCK (block);
block = block->superblock ();
}
}

View File

@ -146,7 +146,7 @@ blpy_get_superblock (PyObject *self, void *closure)
BLPY_REQUIRE_VALID (self, block);
super_block = BLOCK_SUPERBLOCK (block);
super_block = block->superblock ();
if (super_block)
return block_to_block_object (super_block, self_obj->objfile);
@ -183,7 +183,7 @@ blpy_get_static_block (PyObject *self, void *closure)
BLPY_REQUIRE_VALID (self, block);
if (BLOCK_SUPERBLOCK (block) == NULL)
if (block->superblock () == NULL)
Py_RETURN_NONE;
static_block = block_static_block (block);
@ -201,7 +201,7 @@ blpy_is_global (PyObject *self, void *closure)
BLPY_REQUIRE_VALID (self, block);
if (BLOCK_SUPERBLOCK (block))
if (block->superblock ())
Py_RETURN_FALSE;
Py_RETURN_TRUE;
@ -217,8 +217,8 @@ blpy_is_static (PyObject *self, void *closure)
BLPY_REQUIRE_VALID (self, block);
if (BLOCK_SUPERBLOCK (block) != NULL
&& BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL)
if (block->superblock () != NULL
&& block->superblock ()->superblock () == NULL)
Py_RETURN_TRUE;
Py_RETURN_FALSE;

View File

@ -293,7 +293,7 @@ frapy_block (PyObject *self, PyObject *args)
for (fn_block = block;
fn_block != NULL && fn_block->function () == NULL;
fn_block = BLOCK_SUPERBLOCK (fn_block))
fn_block = fn_block->superblock ())
;
if (block == NULL || fn_block == NULL || fn_block->function () == NULL)

View File

@ -2275,7 +2275,7 @@ iterate_over_block_local_vars (const struct block *block,
symbols. */
if (block->function ())
break;
block = BLOCK_SUPERBLOCK (block);
block = block->superblock ();
}
}

View File

@ -287,9 +287,9 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
gdb_printf (outfile, "%*sblock #%03d, object at %s",
depth, "", i,
host_address_to_string (b));
if (BLOCK_SUPERBLOCK (b))
if (b->superblock ())
gdb_printf (outfile, " under %s",
host_address_to_string (BLOCK_SUPERBLOCK (b)));
host_address_to_string (b->superblock ()));
/* drow/2002-07-10: We could save the total symbols count
even if we're using a hashtable, but nothing else but this message
wants it. */
@ -939,7 +939,7 @@ block_depth (const struct block *block)
{
int i = 0;
while ((block = BLOCK_SUPERBLOCK (block)) != NULL)
while ((block = block->superblock ()) != NULL)
{
i++;
}

View File

@ -2026,7 +2026,7 @@ lookup_language_this (const struct language_defn *lang,
}
if (block->function ())
break;
block = BLOCK_SUPERBLOCK (block);
block = block->superblock ();
}
if (symbol_lookup_debug > 1)
@ -2229,7 +2229,7 @@ lookup_local_symbol (const char *name,
if (block->function () != NULL && block_inlined_p (block))
break;
block = BLOCK_SUPERBLOCK (block);
block = block->superblock ();
}
/* We've reached the end of the function without finding a result. */
@ -4046,7 +4046,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
function_block = b;
else if (b->function () != NULL)
break;
b = BLOCK_SUPERBLOCK (b);
b = b->superblock ();
}
if (function_block != NULL
&& function_block->function ()->line () != 0)
@ -4145,7 +4145,7 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr)
bl = NULL;
break;
}
bl = BLOCK_SUPERBLOCK (bl);
bl = bl->superblock ();
}
if (bl != NULL)
break;
@ -6013,7 +6013,7 @@ default_collect_symbol_completion_matches_break_on
are in scope for a nested function. */
if (b->function () != NULL && block_inlined_p (b))
break;
b = BLOCK_SUPERBLOCK (b);
b = b->superblock ();
}
/* Add fields from the file's types; symbols will be added below. */

View File

@ -2618,7 +2618,7 @@ info_scope_command (const char *args_in, int from_tty)
if (block->function ())
break;
else
block = BLOCK_SUPERBLOCK (block);
block = block->superblock ();
}
if (count <= 0)
gdb_printf ("Scope for %s contains no locals or arguments.\n",