From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 7F2FF3857823; Thu, 28 Apr 2022 02:39:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F2FF3857823 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: remove BLOCK_ENTRY_PC macro X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 086d03c91ec1487ed3cc96554d29b2120dd37b5b X-Git-Newrev: 6395b62847e581acc3e8fa179444b824d17b3d68 Message-Id: <20220428023958.7F2FF3857823@sourceware.org> Date: Thu, 28 Apr 2022 02:39:58 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Apr 2022 02:39:58 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D6395b62847e5= 81acc3e8fa179444b824d17b3d68 commit 6395b62847e581acc3e8fa179444b824d17b3d68 Author: Simon Marchi Date: Sun Feb 6 22:41:58 2022 -0500 gdb: remove BLOCK_ENTRY_PC macro =20 Replace with equivalent method. =20 Change-Id: I0e033095e7358799930775e61028b48246971a7d Diff: --- gdb/ax-gdb.c | 2 +- gdb/block.h | 41 ++++++++++++++++++++++--------------= ---- gdb/blockframe.c | 8 ++++---- gdb/compile/compile-c-symbols.c | 4 ++-- gdb/compile/compile-object-run.c | 2 +- gdb/compile/compile.c | 4 ++-- gdb/dwarf2/loc.c | 4 ++-- gdb/findvar.c | 4 ++-- gdb/infcmd.c | 2 +- gdb/infrun.c | 4 ++-- gdb/inline-frame.c | 4 ++-- gdb/linespec.c | 2 +- gdb/parse.c | 4 ++-- gdb/printcmd.c | 4 ++-- gdb/symtab.c | 12 ++++++------ gdb/tracepoint.c | 4 ++-- gdb/value.c | 2 +- 17 files changed, 56 insertions(+), 51 deletions(-) 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 *v= alue, struct symbol *var) break; =20 case LOC_BLOCK: - ax_const_l (ax, BLOCK_ENTRY_PC (var->value_block ())); + ax_const_l (ax, var->value_block ()->entry_pc ()); value->kind =3D axs_rvalue; break; =20 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 () <=3D 1; } =20 + /* Return the "entry PC" of this block. + + The entry PC is the lowest (start) address for the block when all add= resses + within the block are contiguous. If non-contiguous, then use the sta= rt + 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 don= e, + 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. */ =20 CORE_ADDR m_start; @@ -219,24 +242,6 @@ struct global_block struct compunit_symtab *compunit_symtab; }; =20 -/* 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 =3D symbol->value_block (); - return BLOCK_ENTRY_PC (bl); + return bl->entry_pc (); } } =20 @@ -254,7 +254,7 @@ find_pc_partial_function_sym (CORE_ADDR pc, f =3D find_pc_sect_function (mapped_pc, section); if (f !=3D NULL && (msymbol.minsym =3D=3D NULL - || (BLOCK_ENTRY_PC (f->value_block ()) + || (f->value_block ()->entry_pc () >=3D msymbol.value_address ()))) { const struct block *b =3D f->value_block (); @@ -392,7 +392,7 @@ find_function_entry_range_from_pc (CORE_ADDR pc, const = char **name, =20 if (status && block !=3D nullptr && !block->is_contiguous ()) { - CORE_ADDR entry_pc =3D BLOCK_ENTRY_PC (block); + CORE_ADDR entry_pc =3D block->entry_pc (); =20 for (const blockrange &range : block->ranges ()) { @@ -424,7 +424,7 @@ find_function_type (CORE_ADDR pc) { struct symbol *sym =3D find_pc_function (pc); =20 - if (sym !=3D NULL && BLOCK_ENTRY_PC (sym->value_block ()) =3D=3D pc) + if (sym !=3D NULL && sym->value_block ()->entry_pc () =3D=3D pc) return sym->type (); =20 return NULL; diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbol= s.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, =20 case LOC_BLOCK: kind =3D GCC_C_SYMBOL_FUNCTION; - addr =3D BLOCK_ENTRY_PC (sym.symbol->value_block ()); + addr =3D sym.symbol->value_block ()->entry_pc (); if (is_global && sym.symbol->type ()->is_gnu_ifunc ()) addr =3D 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 =3D BLOCK_ENTRY_PC (sym->value_block ()); + result =3D sym->value_block ()->entry_pc (); if (sym->type ()->is_gnu_ifunc ()) result =3D gnu_ifunc_resolve_addr (target_gdbarch (), result); found =3D 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) =20 gdb_assert (func_type->code () =3D=3D TYPE_CODE_FUNC); func_val =3D value_from_pointer (lookup_pointer_type (func_type), - BLOCK_ENTRY_PC (func_sym->value_block ())); + func_sym->value_block ()->entry_pc ()); =20 vargs =3D XALLOCAVEC (struct value *, func_type->num_fields ()); if (func_type->num_fields () >=3D 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 =3D BLOCKVECTOR_BLOCK (cursal.symtab->compunit ()->blockvector (), STATIC_BLOCK); if (block !=3D NULL) - *pc =3D BLOCK_ENTRY_PC (block); + *pc =3D block->entry_pc (); } else - *pc =3D BLOCK_ENTRY_PC (block); + *pc =3D block->entry_pc (); =20 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 =3D block_linkage_function (pc_block); =20 - if (pc_func && pc =3D=3D BLOCK_ENTRY_PC (pc_func->value_block ())) + if (pc_func && pc =3D=3D pc_func->value_block ()->entry_pc ()) { *locexpr_length =3D length; return loc_ptr; @@ -753,7 +753,7 @@ func_addr_to_tail_call_list (struct gdbarch *gdbarch, C= ORE_ADDR addr) struct symbol *sym =3D find_pc_function (addr); struct type *type; =20 - if (sym =3D=3D NULL || BLOCK_ENTRY_PC (sym->value_block ()) !=3D addr) + if (sym =3D=3D NULL || sym->value_block ()->entry_pc () !=3D 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 =3D symbol_overlayed_address - (BLOCK_ENTRY_PC (var->value_block ()), + (var->value_block ()->entry_pc (), var->obj_section (var->objfile ())); else - addr =3D BLOCK_ENTRY_PC (var->value_block ()); + addr =3D var->value_block ()->entry_pc (); break; =20 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 =3D find_pc_line (pc, 0); =20 - tp->control.step_range_start =3D BLOCK_ENTRY_PC (func->value_block (= )); + tp->control.step_range_start =3D func->value_block ()->entry_pc (); tp->control.step_range_end =3D sal.end; =20 /* 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 !=3D nullptr - && ecs->stop_func_start <=3D BLOCK_ENTRY_PC (block) - && BLOCK_ENTRY_PC (block) < ecs->stop_func_end) + && ecs->stop_func_start <=3D block->entry_pc () + && block->entry_pc () < ecs->stop_func_end) { ecs->stop_func_start +=3D 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 =3D get_frame_function (this_frame); gdb_assert (func !=3D NULL); - (*this_id).code_addr =3D BLOCK_ENTRY_PC (func->value_block ()); + (*this_id).code_addr =3D func->value_block ()->entry_pc (); (*this_id).artificial_depth++; } =20 @@ -362,7 +362,7 @@ skip_inline_frames (thread_info *thread, bpstat *stop_c= hain) { /* See comments in inline_frame_this_id about this use of BLOCK_ENTRY_PC. */ - if (BLOCK_ENTRY_PC (cur_block) =3D=3D this_pc + if (cur_block->entry_pc () =3D=3D 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 *stat= e, linespec *ls) && sym.symbol->aclass () =3D=3D LOC_BLOCK) { const CORE_ADDR addr - =3D BLOCK_ENTRY_PC (sym.symbol->value_block ()); + =3D sym.symbol->value_block ()->entry_pc (); =20 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 =3D get_selected_block (&expression_context_p= c); else if (pc =3D=3D 0) - expression_context_pc =3D BLOCK_ENTRY_PC (expression_context_block); + expression_context_pc =3D expression_context_block->entry_pc (); else expression_context_pc =3D pc; =20 @@ -468,7 +468,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR= pc, =3D BLOCKVECTOR_BLOCK (cursal.symtab->compunit ()->blockvector (), STATIC_BLOCK); if (expression_context_block) - expression_context_pc =3D BLOCK_ENTRY_PC (expression_context_block); + expression_context_pc =3D expression_context_block->entry_pc (); } =20 if (language_mode =3D=3D language_mode_auto && block !=3D 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 =3D gdbarch_addr_bits_remove (gdbarch, addr); =20 - name_location =3D BLOCK_ENTRY_PC (symbol->value_block ()); + name_location =3D symbol->value_block ()->entry_pc (); if (do_demangle || asm_demangle) name_temp =3D symbol->print_name (); else @@ -1778,7 +1778,7 @@ info_address_command (const char *exp, int from_tty) =20 case LOC_BLOCK: gdb_printf (_("a function at address ")); - load_addr =3D BLOCK_ENTRY_PC (sym->value_block ()); + load_addr =3D 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 objf= ile *objfile) addr =3D sym->value_address (); break; case LOC_BLOCK: - addr =3D BLOCK_ENTRY_PC (sym->value_block ()); + addr =3D sym->value_block ()->entry_pc (); break; =20 default: @@ -3779,7 +3779,7 @@ find_function_start_sal (symbol *sym, bool funfirstli= ne) { fixup_symbol_section (sym, NULL); symtab_and_line sal - =3D find_function_start_sal_1 (BLOCK_ENTRY_PC (sym->value_block ()), + =3D find_function_start_sal_1 (sym->value_block ()->entry_pc (), sym->obj_section (sym->objfile ()), funfirstline); sal.symbol =3D sym; @@ -3908,7 +3908,7 @@ skip_prologue_sal (struct symtab_and_line *sal) fixup_symbol_section (sym, NULL); =20 objfile =3D sym->objfile (); - pc =3D BLOCK_ENTRY_PC (sym->value_block ()); + pc =3D sym->value_block ()->entry_pc (); section =3D sym->obj_section (objfile); name =3D 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 !=3D pc - && (sym ? (BLOCK_ENTRY_PC (sym->value_block ()) <=3D start_sal.end + && (sym ? (sym->value_block ()->entry_pc () <=3D start_sal.end && start_sal.end < sym->value_block()->end ()) : (lookup_minimal_symbol_by_pc_section (start_sal.end, section).min= sym =3D=3D lookup_minimal_symbol_by_pc_section (pc, section).minsym))) @@ -4182,7 +4182,7 @@ find_function_alias_target (bound_minimal_symbol msym= bol) symbol *sym =3D find_pc_function (func_addr); if (sym !=3D NULL && sym->aclass () =3D=3D LOC_BLOCK - && BLOCK_ENTRY_PC (sym->value_block ()) =3D=3D func_addr) + && sym->value_block ()->entry_pc () =3D=3D func_addr) return sym; =20 return NULL; @@ -5791,7 +5791,7 @@ find_gnu_ifunc (const symbol *sym) symbol_name_match_type::SEARCH_NAME); struct objfile *objfile =3D sym->objfile (); =20 - CORE_ADDR address =3D BLOCK_ENTRY_PC (sym->value_block ()); + CORE_ADDR address =3D sym->value_block ()->entry_pc (); minimal_symbol *ifunc =3D NULL; =20 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) =20 if (SYMBOL_COMPUTED_OPS (sym) !=3D 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 =3D 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) =3D lval_memory; if (sym) { - set_value_address (v, BLOCK_ENTRY_PC (sym->value_block ())); + set_value_address (v, sym->value_block ()->entry_pc ()); } else {