From 6c00f721c834e2c622eb995a58f02900b6d98574 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 28 Jan 2022 11:19:50 -0500 Subject: [PATCH] gdb: remove BLOCK_FUNCTION macro Replace with equivalent methods. Change-Id: I31ec00f5bf85335c8b23d306ca0fe0b84d489101 --- gdb/ada-lang.c | 4 ++-- gdb/block.c | 24 ++++++++++++------------ gdb/block.h | 11 +++++++++-- gdb/blockframe.c | 4 ++-- gdb/buildsym.c | 14 ++++++-------- gdb/compile/compile-c-symbols.c | 2 +- gdb/compile/compile-object-load.c | 4 ++-- gdb/cp-namespace.c | 2 +- gdb/f-valprint.c | 2 +- gdb/findvar.c | 8 ++++---- gdb/go-lang.c | 2 +- gdb/guile/scm-block.c | 6 +++--- gdb/guile/scm-frame.c | 6 +++--- gdb/inline-frame.c | 6 +++--- gdb/jit.c | 2 +- gdb/linespec.c | 4 ++-- gdb/mdebugread.c | 2 +- gdb/mi/mi-cmd-stack.c | 2 +- gdb/python/py-block.c | 2 +- gdb/python/py-frame.c | 6 +++--- gdb/stack.c | 2 +- gdb/symmisc.c | 8 ++++---- gdb/symtab.c | 18 +++++++++--------- gdb/tracepoint.c | 2 +- 24 files changed, 74 insertions(+), 69 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index bb9a16f8fe0..dfcaf12104a 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5331,7 +5331,7 @@ ada_add_local_symbols (std::vector &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); } diff --git a/gdb/block.c b/gdb/block.c index a4678ca6a84..b70b8e22a91 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -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; diff --git a/gdb/block.h b/gdb/block.h index 7fe982407f8..0330b6de4d2 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -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 diff --git a/gdb/blockframe.c b/gdb/blockframe.c index fec7f053057..aaf76953648 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -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 (); } diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 7db9f344177..f761444fff4 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -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 diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index d49ecdab92f..9e13d7650dd 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -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); } diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index 2303381b49a..89a47859c22 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -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; } diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index b0fa33705ee..d84486e8bf7 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -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) diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 4f95b224d73..f977d8cad96 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -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); } diff --git a/gdb/findvar.c b/gdb/findvar.c index 067fb3f6757..2e2b10bb625 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -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")); diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 74b8b214abb..b4d85b06dd9 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -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) { diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c index 921225dcf47..1683ed1ac8a 100644 --- a/gdb/guile/scm-block.c +++ b/gdb/guile/scm-block.c @@ -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); diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c index e53c8602322..f0de7c368f9 100644 --- a/gdb/guile/scm-frame.c +++ b/gdb/guile/scm-frame.c @@ -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; diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c index bcdf36cd067..95cc80b7a1c 100644 --- a/gdb/inline-frame.c +++ b/gdb/inline-frame.c @@ -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); diff --git a/gdb/jit.c b/gdb/jit.c index 49db391f80c..17dfdd9ef24 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -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 ()) diff --git a/gdb/linespec.c b/gdb/linespec.c index 61ad69dd882..90e4c813e4e 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -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); diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 1565a86bad0..87d2fb1d477 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -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; diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index e894411765a..9ae64f092a8 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -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); diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c index aa8f3df7af9..7ab98687387 100644 --- a/gdb/python/py-block.c +++ b/gdb/python/py-block.c @@ -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); diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index d07158a5ec6..c4225c84aff 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -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; diff --git a/gdb/stack.c b/gdb/stack.c index 1229ee6b492..35726b71398 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -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); } diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 097dc2dd355..1dd747d5386 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -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"); diff --git a/gdb/symtab.c b/gdb/symtab.c index 993b1962c8c..58a2033f1ff 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -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); } diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 18c3803ac19..76da71df038 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -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); -- 2.30.2