From: Simon Marchi Date: Mon, 7 Feb 2022 03:41:58 +0000 (-0500) Subject: gdb: remove BLOCK_ENTRY_PC macro X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6395b62847e581acc3e8fa179444b824d17b3d68;p=binutils-gdb.git gdb: remove BLOCK_ENTRY_PC macro Replace with equivalent method. Change-Id: I0e033095e7358799930775e61028b48246971a7d --- diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index e2e311f9d74..f8ea8adc626 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -571,7 +571,7 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var) break; case LOC_BLOCK: - ax_const_l (ax, BLOCK_ENTRY_PC (var->value_block ())); + ax_const_l (ax, var->value_block ()->entry_pc ()); value->kind = axs_rvalue; break; diff --git a/gdb/block.h b/gdb/block.h index 80b0616116d..d952430e6b1 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -171,6 +171,29 @@ struct block bool is_contiguous () const { return this->ranges ().size () <= 1; } + /* Return the "entry PC" of this block. + + The entry PC is the lowest (start) address for the block when all addresses + within the block are contiguous. If non-contiguous, then use the start + address for the first range in the block. + + At the moment, this almost matches what DWARF specifies as the entry + pc. (The missing bit is support for DW_AT_entry_pc which should be + preferred over range data and the low_pc.) + + Once support for DW_AT_entry_pc is added, I expect that an entry_pc + field will be added to one of these data structures. Once that's done, + the entry_pc field can be set from the dwarf reader (and other readers + too). ENTRY_PC can then be redefined to be less DWARF-centric. */ + + CORE_ADDR entry_pc () const + { + if (this->is_contiguous ()) + return this->start (); + else + return this->ranges ()[0].start (); + } + /* Addresses in the executable code that are in this block. */ CORE_ADDR m_start; @@ -219,24 +242,6 @@ struct global_block struct compunit_symtab *compunit_symtab; }; -/* Define the "entry pc" for a block BL to be the lowest (start) address - for the block when all addresses within the block are contiguous. If - non-contiguous, then use the start address for the first range in the - block. - - At the moment, this almost matches what DWARF specifies as the entry - pc. (The missing bit is support for DW_AT_entry_pc which should be - preferred over range data and the low_pc.) - - Once support for DW_AT_entry_pc is added, I expect that an entry_pc - field will be added to one of these data structures. Once that's done, - the entry_pc field can be set from the dwarf reader (and other readers - too). BLOCK_ENTRY_PC can then be redefined to be less DWARF-centric. */ - -#define BLOCK_ENTRY_PC(bl) (bl->is_contiguous () \ - ? bl->start () \ - : bl->ranges ()[0].start ()) - struct blockvector { /* Number of blocks in the list. */ diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 694cd047c75..47772f3b1a6 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -96,7 +96,7 @@ get_pc_function_start (CORE_ADDR pc) if (symbol) { bl = symbol->value_block (); - return BLOCK_ENTRY_PC (bl); + return bl->entry_pc (); } } @@ -254,7 +254,7 @@ find_pc_partial_function_sym (CORE_ADDR pc, f = find_pc_sect_function (mapped_pc, section); if (f != NULL && (msymbol.minsym == NULL - || (BLOCK_ENTRY_PC (f->value_block ()) + || (f->value_block ()->entry_pc () >= msymbol.value_address ()))) { const struct block *b = f->value_block (); @@ -392,7 +392,7 @@ find_function_entry_range_from_pc (CORE_ADDR pc, const char **name, if (status && block != nullptr && !block->is_contiguous ()) { - CORE_ADDR entry_pc = BLOCK_ENTRY_PC (block); + CORE_ADDR entry_pc = block->entry_pc (); for (const blockrange &range : block->ranges ()) { @@ -424,7 +424,7 @@ find_function_type (CORE_ADDR pc) { struct symbol *sym = find_pc_function (pc); - if (sym != NULL && BLOCK_ENTRY_PC (sym->value_block ()) == pc) + if (sym != NULL && sym->value_block ()->entry_pc () == pc) return sym->type (); return NULL; diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 4c30ae98c1c..e1f94ec2907 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -93,7 +93,7 @@ convert_one_symbol (compile_c_instance *context, case LOC_BLOCK: kind = GCC_C_SYMBOL_FUNCTION; - addr = BLOCK_ENTRY_PC (sym.symbol->value_block ()); + addr = sym.symbol->value_block ()->entry_pc (); if (is_global && sym.symbol->type ()->is_gnu_ifunc ()) addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr); break; @@ -404,7 +404,7 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context, gdb_printf (gdb_stdlog, "gcc_symbol_address \"%s\": full symbol\n", identifier); - result = BLOCK_ENTRY_PC (sym->value_block ()); + result = sym->value_block ()->entry_pc (); if (sym->type ()->is_gnu_ifunc ()) result = gnu_ifunc_resolve_addr (target_gdbarch (), result); found = 1; diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c index d5742a5880d..331ae35c5e9 100644 --- a/gdb/compile/compile-object-run.c +++ b/gdb/compile/compile-object-run.c @@ -145,7 +145,7 @@ compile_object_run (compile_module_up &&module) gdb_assert (func_type->code () == TYPE_CODE_FUNC); func_val = value_from_pointer (lookup_pointer_type (func_type), - BLOCK_ENTRY_PC (func_sym->value_block ())); + func_sym->value_block ()->entry_pc ()); vargs = XALLOCAVEC (struct value *, func_type->num_fields ()); if (func_type->num_fields () >= 1) diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index 5cbb341b383..1c3a618690b 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -487,10 +487,10 @@ get_expr_block_and_pc (CORE_ADDR *pc) block = BLOCKVECTOR_BLOCK (cursal.symtab->compunit ()->blockvector (), STATIC_BLOCK); if (block != NULL) - *pc = BLOCK_ENTRY_PC (block); + *pc = block->entry_pc (); } else - *pc = BLOCK_ENTRY_PC (block); + *pc = block->entry_pc (); return block; } diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index ea45475810e..f490b68adc3 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -453,7 +453,7 @@ dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton, if (pc_block) pc_func = block_linkage_function (pc_block); - if (pc_func && pc == BLOCK_ENTRY_PC (pc_func->value_block ())) + if (pc_func && pc == pc_func->value_block ()->entry_pc ()) { *locexpr_length = length; return loc_ptr; @@ -753,7 +753,7 @@ func_addr_to_tail_call_list (struct gdbarch *gdbarch, CORE_ADDR addr) struct symbol *sym = find_pc_function (addr); struct type *type; - if (sym == NULL || BLOCK_ENTRY_PC (sym->value_block ()) != addr) + if (sym == NULL || sym->value_block ()->entry_pc () != addr) throw_error (NO_ENTRY_VALUE_ERROR, _("DW_TAG_call_site resolving failed to find function " "name for address %s"), diff --git a/gdb/findvar.c b/gdb/findvar.c index bdc3d35c345..1f0317567cd 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -704,10 +704,10 @@ language_defn::read_var_value (struct symbol *var, case LOC_BLOCK: if (overlay_debugging) addr = symbol_overlayed_address - (BLOCK_ENTRY_PC (var->value_block ()), + (var->value_block ()->entry_pc (), var->obj_section (var->objfile ())); else - addr = BLOCK_ENTRY_PC (var->value_block ()); + addr = var->value_block ()->entry_pc (); break; case LOC_REGISTER: diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 5368fcd7157..53c9e3d0afe 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1345,7 +1345,7 @@ until_next_command (int from_tty) { sal = find_pc_line (pc, 0); - tp->control.step_range_start = BLOCK_ENTRY_PC (func->value_block ()); + tp->control.step_range_start = func->value_block ()->entry_pc (); tp->control.step_range_end = sal.end; /* By setting the step_range_end based on the current pc, we are diff --git a/gdb/infrun.c b/gdb/infrun.c index e0a5bde037b..acefd4f0bec 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -4687,8 +4687,8 @@ fill_in_stop_func (struct gdbarch *gdbarch, stop_func_start is NOT advanced when in a range of a non-contiguous block that does not contain the entry pc. */ if (block != nullptr - && ecs->stop_func_start <= BLOCK_ENTRY_PC (block) - && BLOCK_ENTRY_PC (block) < ecs->stop_func_end) + && ecs->stop_func_start <= block->entry_pc () + && block->entry_pc () < ecs->stop_func_end) { ecs->stop_func_start += gdbarch_deprecated_function_start_offset (gdbarch); diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c index bd173a1d21b..c502674b1d4 100644 --- a/gdb/inline-frame.c +++ b/gdb/inline-frame.c @@ -181,7 +181,7 @@ inline_frame_this_id (struct frame_info *this_frame, in the frame ID (and eventually, to set breakpoints). */ func = get_frame_function (this_frame); gdb_assert (func != NULL); - (*this_id).code_addr = BLOCK_ENTRY_PC (func->value_block ()); + (*this_id).code_addr = func->value_block ()->entry_pc (); (*this_id).artificial_depth++; } @@ -362,7 +362,7 @@ skip_inline_frames (thread_info *thread, bpstat *stop_chain) { /* See comments in inline_frame_this_id about this use of BLOCK_ENTRY_PC. */ - if (BLOCK_ENTRY_PC (cur_block) == this_pc + if (cur_block->entry_pc () == this_pc || block_starting_point_at (this_pc, cur_block)) { /* Do not skip the inlined frame if execution diff --git a/gdb/linespec.c b/gdb/linespec.c index fd3fba871c5..c424b33b522 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2224,7 +2224,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls) && sym.symbol->aclass () == LOC_BLOCK) { const CORE_ADDR addr - = BLOCK_ENTRY_PC (sym.symbol->value_block ()); + = sym.symbol->value_block ()->entry_pc (); for (const auto &elem : ls->minimal_symbols) { diff --git a/gdb/parse.c b/gdb/parse.c index 73669923890..52925db2189 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -454,7 +454,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc, if (!expression_context_block) expression_context_block = get_selected_block (&expression_context_pc); else if (pc == 0) - expression_context_pc = BLOCK_ENTRY_PC (expression_context_block); + expression_context_pc = expression_context_block->entry_pc (); else expression_context_pc = pc; @@ -468,7 +468,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc, = BLOCKVECTOR_BLOCK (cursal.symtab->compunit ()->blockvector (), STATIC_BLOCK); if (expression_context_block) - expression_context_pc = BLOCK_ENTRY_PC (expression_context_block); + expression_context_pc = expression_context_block->entry_pc (); } if (language_mode == language_mode_auto && block != NULL) diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 102058a8579..806c5d1b004 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -645,7 +645,7 @@ build_address_symbolic (struct gdbarch *gdbarch, pointer is . This matches the ISA behavior. */ addr = gdbarch_addr_bits_remove (gdbarch, addr); - name_location = BLOCK_ENTRY_PC (symbol->value_block ()); + name_location = symbol->value_block ()->entry_pc (); if (do_demangle || asm_demangle) name_temp = symbol->print_name (); else @@ -1778,7 +1778,7 @@ info_address_command (const char *exp, int from_tty) case LOC_BLOCK: gdb_printf (_("a function at address ")); - load_addr = BLOCK_ENTRY_PC (sym->value_block ()); + load_addr = sym->value_block ()->entry_pc (); fputs_styled (paddress (gdbarch, load_addr), address_style.style (), gdb_stdout); if (section_is_overlay (section)) diff --git a/gdb/symtab.c b/gdb/symtab.c index 63fa9ba3196..0367705576c 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1821,7 +1821,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile) addr = sym->value_address (); break; case LOC_BLOCK: - addr = BLOCK_ENTRY_PC (sym->value_block ()); + addr = sym->value_block ()->entry_pc (); break; default: @@ -3779,7 +3779,7 @@ find_function_start_sal (symbol *sym, bool funfirstline) { fixup_symbol_section (sym, NULL); symtab_and_line sal - = find_function_start_sal_1 (BLOCK_ENTRY_PC (sym->value_block ()), + = find_function_start_sal_1 (sym->value_block ()->entry_pc (), sym->obj_section (sym->objfile ()), funfirstline); sal.symbol = sym; @@ -3908,7 +3908,7 @@ skip_prologue_sal (struct symtab_and_line *sal) fixup_symbol_section (sym, NULL); objfile = sym->objfile (); - pc = BLOCK_ENTRY_PC (sym->value_block ()); + pc = sym->value_block ()->entry_pc (); section = sym->obj_section (objfile); name = sym->linkage_name (); } @@ -3984,7 +3984,7 @@ skip_prologue_sal (struct symtab_and_line *sal) /* Check if gdbarch_skip_prologue left us in mid-line, and the next line is still part of the same function. */ if (skip && start_sal.pc != pc - && (sym ? (BLOCK_ENTRY_PC (sym->value_block ()) <= start_sal.end + && (sym ? (sym->value_block ()->entry_pc () <= start_sal.end && start_sal.end < sym->value_block()->end ()) : (lookup_minimal_symbol_by_pc_section (start_sal.end, section).minsym == lookup_minimal_symbol_by_pc_section (pc, section).minsym))) @@ -4182,7 +4182,7 @@ find_function_alias_target (bound_minimal_symbol msymbol) symbol *sym = find_pc_function (func_addr); if (sym != NULL && sym->aclass () == LOC_BLOCK - && BLOCK_ENTRY_PC (sym->value_block ()) == func_addr) + && sym->value_block ()->entry_pc () == func_addr) return sym; return NULL; @@ -5791,7 +5791,7 @@ find_gnu_ifunc (const symbol *sym) symbol_name_match_type::SEARCH_NAME); struct objfile *objfile = sym->objfile (); - CORE_ADDR address = BLOCK_ENTRY_PC (sym->value_block ()); + CORE_ADDR address = sym->value_block ()->entry_pc (); minimal_symbol *ifunc = NULL; iterate_over_minimal_symbols (objfile, lookup_name, diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 64419436fd7..44d16b55bca 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2512,7 +2512,7 @@ info_scope_command (const char *args_in, int from_tty) if (SYMBOL_COMPUTED_OPS (sym) != NULL) SYMBOL_COMPUTED_OPS (sym)->describe_location (sym, - BLOCK_ENTRY_PC (block), + block->entry_pc (), gdb_stdout); else { @@ -2587,7 +2587,7 @@ info_scope_command (const char *args_in, int from_tty) gdb_printf ("a function at address "); gdb_printf ("%s", paddress (gdbarch, - BLOCK_ENTRY_PC (sym->value_block ()))); + sym->value_block ()->entry_pc ())); break; case LOC_UNRESOLVED: msym = lookup_minimal_symbol (sym->linkage_name (), diff --git a/gdb/value.c b/gdb/value.c index 08cccf711b2..022fca91a42 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -3184,7 +3184,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f, VALUE_LVAL (v) = lval_memory; if (sym) { - set_value_address (v, BLOCK_ENTRY_PC (sym->value_block ())); + set_value_address (v, sym->value_block ()->entry_pc ()); } else {