gdb: remove BLOCK_FUNCTION macro

Replace with equivalent methods.

Change-Id: I31ec00f5bf85335c8b23d306ca0fe0b84d489101
This commit is contained in:
Simon Marchi 2022-01-28 11:19:50 -05:00 committed by Simon Marchi
parent 4b8791e10e
commit 6c00f721c8
24 changed files with 74 additions and 69 deletions

View File

@ -5331,7 +5331,7 @@ ada_add_local_symbols (std::vector<struct block_symbol> &result,
/* If we found a non-function match, assume that's the one. We
only check this when finding a function boundary, so that we
can accumulate all results from intervening blocks first. */
if (BLOCK_FUNCTION (block) != nullptr && is_nonfunction (result))
if (block->function () != nullptr && is_nonfunction (result))
return;
block = BLOCK_SUPERBLOCK (block);
@ -13038,7 +13038,7 @@ ada_add_exceptions_from_frame (compiled_regex *preg,
}
}
}
if (BLOCK_FUNCTION (block) != NULL)
if (block->function () != NULL)
break;
block = BLOCK_SUPERBLOCK (block);
}

View File

@ -47,8 +47,8 @@ block_objfile (const struct block *block)
{
const struct global_block *global_block;
if (BLOCK_FUNCTION (block) != NULL)
return BLOCK_FUNCTION (block)->objfile ();
if (block->function () != nullptr)
return block->function ()->objfile ();
global_block = (struct global_block *) block_global_block (block);
return global_block->compunit_symtab->objfile ();
@ -59,8 +59,8 @@ block_objfile (const struct block *block)
struct gdbarch *
block_gdbarch (const struct block *block)
{
if (BLOCK_FUNCTION (block) != NULL)
return BLOCK_FUNCTION (block)->arch ();
if (block->function () != nullptr)
return block->function ()->arch ();
return block_objfile (block)->arch ();
}
@ -80,7 +80,7 @@ contained_in (const struct block *a, const struct block *b,
return true;
/* If A is a function block, then A cannot be contained in B,
except if A was inlined. */
if (!allow_nested && BLOCK_FUNCTION (a) != NULL && !block_inlined_p (a))
if (!allow_nested && a->function () != NULL && !block_inlined_p (a))
return false;
a = BLOCK_SUPERBLOCK (a);
}
@ -98,11 +98,11 @@ contained_in (const struct block *a, const struct block *b,
struct symbol *
block_linkage_function (const struct block *bl)
{
while ((BLOCK_FUNCTION (bl) == NULL || block_inlined_p (bl))
while ((bl->function () == NULL || block_inlined_p (bl))
&& BLOCK_SUPERBLOCK (bl) != NULL)
bl = BLOCK_SUPERBLOCK (bl);
return BLOCK_FUNCTION (bl);
return bl->function ();
}
/* Return the symbol for the function which contains a specified
@ -113,10 +113,10 @@ block_linkage_function (const struct block *bl)
struct symbol *
block_containing_function (const struct block *bl)
{
while (BLOCK_FUNCTION (bl) == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
while (bl->function () == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
bl = BLOCK_SUPERBLOCK (bl);
return BLOCK_FUNCTION (bl);
return bl->function ();
}
/* Return one if BL represents an inlined function. */
@ -124,7 +124,7 @@ block_containing_function (const struct block *bl)
int
block_inlined_p (const struct block *bl)
{
return BLOCK_FUNCTION (bl) != NULL && BLOCK_FUNCTION (bl)->is_inlined ();
return bl->function () != NULL && bl->function ()->is_inlined ();
}
/* A helper function that checks whether PC is in the blockvector BL.
@ -433,7 +433,7 @@ block_static_link (const struct block *block)
/* Only objfile-owned blocks that materialize top function scopes can have
static links. */
if (objfile == NULL || BLOCK_FUNCTION (block) == NULL)
if (objfile == NULL || block->function () == NULL)
return NULL;
return (struct dynamic_prop *) objfile_lookup_static_link (objfile, block);
@ -714,7 +714,7 @@ block_lookup_symbol (const struct block *block, const char *name,
lookup_name_info lookup_name (name, match_type);
if (!BLOCK_FUNCTION (block))
if (!block->function ())
{
struct symbol *other = NULL;

View File

@ -106,6 +106,14 @@ struct block
void set_end (CORE_ADDR end)
{ m_end = end; }
/* Return this block's function symbol. */
symbol *function () const
{ return m_function; }
/* Set this block's function symbol. */
void set_function (symbol *function)
{ m_function = function; }
/* Addresses in the executable code that are in this block. */
CORE_ADDR m_start;
@ -114,7 +122,7 @@ struct block
/* The symbol that names this block, if the block is the body of a
function (real or inlined); otherwise, zero. */
struct symbol *function;
struct symbol *m_function;
/* The `struct block' for the containing block, or 0 if none.
@ -154,7 +162,6 @@ struct global_block
struct compunit_symtab *compunit_symtab;
};
#define BLOCK_FUNCTION(bl) (bl)->function
#define BLOCK_SUPERBLOCK(bl) (bl)->superblock
#define BLOCK_MULTIDICT(bl) (bl)->multidict
#define BLOCK_NAMESPACE(bl) (bl)->namespace_info

View File

@ -122,10 +122,10 @@ get_frame_function (struct frame_info *frame)
if (bl == NULL)
return NULL;
while (BLOCK_FUNCTION (bl) == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
while (bl->function () == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
bl = BLOCK_SUPERBLOCK (bl);
return BLOCK_FUNCTION (bl);
return bl->function ();
}

View File

@ -244,7 +244,7 @@ buildsym_compunit::finish_block_internal
struct type *ftype = symbol->type ();
struct mdict_iterator miter;
symbol->set_value_block (block);
BLOCK_FUNCTION (block) = symbol;
block->set_function (symbol);
if (ftype->num_fields () <= 0)
{
@ -287,9 +287,7 @@ buildsym_compunit::finish_block_internal
}
}
else
{
BLOCK_FUNCTION (block) = NULL;
}
block->set_function (nullptr);
if (static_link != NULL)
objfile_register_static_link (m_objfile, block, static_link);
@ -342,7 +340,7 @@ buildsym_compunit::finish_block_internal
Skip blocks which correspond to a function; they're not
physically nested inside this other blocks, only
lexically nested. */
if (BLOCK_FUNCTION (pblock->block) == NULL
if (pblock->block->function () == NULL
&& (pblock->block->start () < block->start ()
|| pblock->block->end () > block->end ()))
{
@ -1008,9 +1006,9 @@ buildsym_compunit::end_compunit_symtab_with_blockvector
/* Inlined functions may have symbols not in the global or
static symbol lists. */
if (BLOCK_FUNCTION (block) != NULL)
if (BLOCK_FUNCTION (block)->symtab () == NULL)
BLOCK_FUNCTION (block)->set_symtab (symtab);
if (block->function () != nullptr
&& block->function ()->symtab () == nullptr)
block->function ()->set_symtab (symtab);
/* Note that we only want to fix up symbols from the local
blocks, not blocks coming from included symtabs. That is why

View File

@ -645,7 +645,7 @@ generate_c_for_variable_locations (compile_instance *compiler,
/* If we just finished the outermost block of a function, we're
done. */
if (BLOCK_FUNCTION (block) != NULL)
if (block->function () != NULL)
break;
block = BLOCK_SUPERBLOCK (block);
}

View File

@ -431,7 +431,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
const struct block *function_block;
block = BLOCKVECTOR_BLOCK (bv, block_loop);
if (BLOCK_FUNCTION (block) != NULL)
if (block->function () != NULL)
continue;
gdb_val_sym = block_lookup_symbol (block,
COMPILE_I_EXPR_VAL,
@ -445,7 +445,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
&& function_block != BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK))
{
function_block = BLOCK_SUPERBLOCK (function_block);
function = BLOCK_FUNCTION (function_block);
function = function_block->function ();
if (function != NULL)
break;
}

View File

@ -504,7 +504,7 @@ cp_lookup_symbol_imports_or_template (const char *scope,
const struct block *block,
const domain_enum domain)
{
struct symbol *function = BLOCK_FUNCTION (block);
struct symbol *function = block->function ();
struct block_symbol result;
if (symbol_lookup_debug)

View File

@ -688,7 +688,7 @@ info_common_command (const char *comname, int from_tty)
info_common_command_for_block (block, comname, &values_printed);
/* After handling the function's top-level block, stop. Don't
continue to its superblock, the block of per-file symbols. */
if (BLOCK_FUNCTION (block))
if (block->function ())
break;
block = BLOCK_SUPERBLOCK (block);
}

View File

@ -534,7 +534,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
/* Assuming we have a block for this frame: if we are at the function
level, the immediate upper lexical block is in an outer function:
follow the static link. */
else if (BLOCK_FUNCTION (frame_block))
else if (frame_block->function ())
{
const struct dynamic_prop *static_link
= block_static_link (frame_block);
@ -571,11 +571,11 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
frame = block_innermost_frame (var_block);
if (frame == NULL)
{
if (BLOCK_FUNCTION (var_block)
if (var_block->function ()
&& !block_inlined_p (var_block)
&& BLOCK_FUNCTION (var_block)->print_name ())
&& var_block->function ()->print_name ())
error (_("No frame is currently executing in block %s."),
BLOCK_FUNCTION (var_block)->print_name ());
var_block->function ()->print_name ());
else
error (_("No frame is currently executing in specified"
" block"));

View File

@ -418,7 +418,7 @@ go_block_package_name (const struct block *block)
{
while (block != NULL)
{
struct symbol *function = BLOCK_FUNCTION (block);
struct symbol *function = block->function ();
if (function != NULL)
{

View File

@ -156,8 +156,8 @@ bkscm_print_block_smob (SCM self, SCM port, scm_print_state *pstate)
else if (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (b)) == NULL)
gdbscm_printf (port, " static");
if (BLOCK_FUNCTION (b) != NULL)
gdbscm_printf (port, " %s", BLOCK_FUNCTION (b)->print_name ());
if (b->function () != NULL)
gdbscm_printf (port, " %s", b->function ()->print_name ());
gdbscm_printf (port, " %s-%s",
hex_string (b->start ()), hex_string (b->end ()));
@ -404,7 +404,7 @@ gdbscm_block_function (SCM self)
const struct block *block = b_smob->block;
struct symbol *sym;
sym = BLOCK_FUNCTION (block);
sym = block->function ();
if (sym != NULL)
return syscm_scm_from_symbol (sym);

View File

@ -611,11 +611,11 @@ gdbscm_frame_block (SCM self)
}
for (fn_block = block;
fn_block != NULL && BLOCK_FUNCTION (fn_block) == NULL;
fn_block != NULL && fn_block->function () == NULL;
fn_block = BLOCK_SUPERBLOCK (fn_block))
continue;
if (block == NULL || fn_block == NULL || BLOCK_FUNCTION (fn_block) == NULL)
if (block == NULL || fn_block == NULL || fn_block->function () == NULL)
{
scm_misc_error (FUNC_NAME, _("cannot find block for frame"),
scm_list_1 (self));
@ -624,7 +624,7 @@ gdbscm_frame_block (SCM self)
if (block != NULL)
{
return bkscm_scm_from_block
(block, BLOCK_FUNCTION (fn_block)->objfile ());
(block, fn_block->function ()->objfile ());
}
return SCM_BOOL_F;

View File

@ -230,7 +230,7 @@ inline_frame_sniffer (const struct frame_unwind *self,
{
if (block_inlined_p (cur_block))
depth++;
else if (BLOCK_FUNCTION (cur_block) != NULL)
else if (cur_block->function () != NULL)
break;
cur_block = BLOCK_SUPERBLOCK (cur_block);
@ -372,12 +372,12 @@ skip_inline_frames (thread_info *thread, bpstat *stop_chain)
break;
skip_count++;
skipped_syms.push_back (BLOCK_FUNCTION (cur_block));
skipped_syms.push_back (cur_block->function ());
}
else
break;
}
else if (BLOCK_FUNCTION (cur_block) != NULL)
else if (cur_block->function () != NULL)
break;
cur_block = BLOCK_SUPERBLOCK (cur_block);

View File

@ -596,7 +596,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
block_name->m_name = obstack_strdup (&objfile->objfile_obstack,
gdb_block_iter.name.get ());
BLOCK_FUNCTION (new_block) = block_name;
new_block->set_function (block_name);
BLOCKVECTOR_BLOCK (bv, block_idx) = new_block;
if (begin > new_block->start ())

View File

@ -3967,14 +3967,14 @@ find_label_symbols (struct linespec_state *self,
block = get_current_search_block ();
for (;
block && !BLOCK_FUNCTION (block);
block && !block->function ();
block = BLOCK_SUPERBLOCK (block))
;
if (!block)
return {};
fn_sym = BLOCK_FUNCTION (block);
fn_sym = block->function ();
find_label_symbols_in_block (block, name, fn_sym, completion_mode,
&result, label_funcs_ret);

View File

@ -797,7 +797,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
/* Create and enter a new lexical context. */
b = new_block (FUNCTION_BLOCK, s->language ());
s->set_value_block (b);
BLOCK_FUNCTION (b) = s;
b->set_function (s);
b->set_start (sh->value);
b->set_end (sh->value);
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;

View File

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

View File

@ -130,7 +130,7 @@ blpy_get_function (PyObject *self, void *closure)
BLPY_REQUIRE_VALID (self, block);
sym = BLOCK_FUNCTION (block);
sym = block->function ();
if (sym)
return symbol_to_symbol_object (sym);

View File

@ -292,11 +292,11 @@ frapy_block (PyObject *self, PyObject *args)
}
for (fn_block = block;
fn_block != NULL && BLOCK_FUNCTION (fn_block) == NULL;
fn_block != NULL && fn_block->function () == NULL;
fn_block = BLOCK_SUPERBLOCK (fn_block))
;
if (block == NULL || fn_block == NULL || BLOCK_FUNCTION (fn_block) == NULL)
if (block == NULL || fn_block == NULL || fn_block->function () == NULL)
{
PyErr_SetString (PyExc_RuntimeError,
_("Cannot locate block for frame."));
@ -306,7 +306,7 @@ frapy_block (PyObject *self, PyObject *args)
if (block)
{
return block_to_block_object
(block, BLOCK_FUNCTION (fn_block)->objfile ());
(block, fn_block->function ()->objfile ());
}
Py_RETURN_NONE;

View File

@ -2273,7 +2273,7 @@ iterate_over_block_local_vars (const struct block *block,
/* After handling the function's top-level block, stop. Don't
continue to its superblock, the block of per-file
symbols. */
if (BLOCK_FUNCTION (block))
if (block->function ())
break;
block = BLOCK_SUPERBLOCK (block);
}

View File

@ -298,14 +298,14 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
gdb_puts (paddress (gdbarch, b->start ()), outfile);
gdb_printf (outfile, "..");
gdb_puts (paddress (gdbarch, b->end ()), outfile);
if (BLOCK_FUNCTION (b))
if (b->function ())
{
gdb_printf (outfile, ", function %s",
BLOCK_FUNCTION (b)->linkage_name ());
if (BLOCK_FUNCTION (b)->demangled_name () != NULL)
b->function ()->linkage_name ());
if (b->function ()->demangled_name () != NULL)
{
gdb_printf (outfile, ", %s",
BLOCK_FUNCTION (b)->demangled_name ());
b->function ()->demangled_name ());
}
}
gdb_printf (outfile, "\n");

View File

@ -2024,7 +2024,7 @@ lookup_language_this (const struct language_defn *lang,
}
return (struct block_symbol) {sym, block};
}
if (BLOCK_FUNCTION (block))
if (block->function ())
break;
block = BLOCK_SUPERBLOCK (block);
}
@ -2227,7 +2227,7 @@ lookup_local_symbol (const char *name,
return blocksym;
}
if (BLOCK_FUNCTION (block) != NULL && block_inlined_p (block))
if (block->function () != NULL && block_inlined_p (block))
break;
block = BLOCK_SUPERBLOCK (block);
}
@ -4042,17 +4042,17 @@ skip_prologue_sal (struct symtab_and_line *sal)
function_block = NULL;
while (b != NULL)
{
if (BLOCK_FUNCTION (b) != NULL && block_inlined_p (b))
if (b->function () != NULL && block_inlined_p (b))
function_block = b;
else if (BLOCK_FUNCTION (b) != NULL)
else if (b->function () != NULL)
break;
b = BLOCK_SUPERBLOCK (b);
}
if (function_block != NULL
&& BLOCK_FUNCTION (function_block)->line () != 0)
&& function_block->function ()->line () != 0)
{
sal->line = BLOCK_FUNCTION (function_block)->line ();
sal->symtab = BLOCK_FUNCTION (function_block)->symtab ();
sal->line = function_block->function ()->line ();
sal->symtab = function_block->function ()->symtab ();
}
}
@ -4140,7 +4140,7 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr)
{
if (block_inlined_p (bl))
break;
if (BLOCK_FUNCTION (bl))
if (bl->function ())
{
bl = NULL;
break;
@ -6011,7 +6011,7 @@ default_collect_symbol_completion_matches_break_on
/* Stop when we encounter an enclosing function. Do not stop for
non-inlined functions - the locals of the enclosing function
are in scope for a nested function. */
if (BLOCK_FUNCTION (b) != NULL && block_inlined_p (b))
if (b->function () != NULL && block_inlined_p (b))
break;
b = BLOCK_SUPERBLOCK (b);
}

View File

@ -2615,7 +2615,7 @@ info_scope_command (const char *args_in, int from_tty)
gdb_printf (", length %s.\n", pulongest (TYPE_LENGTH (t)));
}
}
if (BLOCK_FUNCTION (block))
if (block->function ())
break;
else
block = BLOCK_SUPERBLOCK (block);