From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 76F273858036; Mon, 28 Mar 2022 19:56:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76F273858036 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Make call_site_target members private X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 7eb21cc702249b4fb1beecee25c0c8ccbd9edd15 X-Git-Newrev: 797662d7ef6705f9c300cb3e9a78f17f0f2aedad Message-Id: <20220328195608.76F273858036@sourceware.org> Date: Mon, 28 Mar 2022 19:56:08 +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: Mon, 28 Mar 2022 19:56:08 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D797662d7ef67= 05f9c300cb3e9a78f17f0f2aedad commit 797662d7ef6705f9c300cb3e9a78f17f0f2aedad Author: Tom Tromey Date: Thu Nov 18 12:26:02 2021 -0700 Make call_site_target members private =20 This makes the data members of call_site_target 'private'. This lets us remove most of its public API. call_site_to_target_addr is changed to be a method of this type. This is a preparatory refactoring for the fix at the end of this series. Diff: --- gdb/dwarf2/loc.c | 26 ++++++++++++-------------- gdb/gdbtypes.h | 44 +++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 16c42a5fdb5..acb7b863145 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -632,16 +632,14 @@ show_entry_values_debug (struct ui_file *file, int fr= om_tty, value); } =20 -/* Find DW_TAG_call_site's DW_AT_call_target address. - CALLER_FRAME (for registers) can be NULL if it is not known. This func= tion - always returns valid address or it throws NO_ENTRY_VALUE_ERROR. */ +/* See gdbtypes.h. */ =20 -static CORE_ADDR -call_site_to_target_addr (struct gdbarch *call_site_gdbarch, - struct call_site *call_site, - struct frame_info *caller_frame) +CORE_ADDR +call_site_target::address (struct gdbarch *call_site_gdbarch, + const struct call_site *call_site, + struct frame_info *caller_frame) const { - switch (call_site->target.loc_kind ()) + switch (m_loc_kind) { case call_site_target::DWARF_BLOCK: { @@ -650,7 +648,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdb= arch, struct type *caller_core_addr_type; struct gdbarch *caller_arch; =20 - dwarf_block =3D call_site->target.loc_dwarf_block (); + dwarf_block =3D m_loc.dwarf_block; if (dwarf_block =3D=3D NULL) { struct bound_minimal_symbol msym; @@ -695,7 +693,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdb= arch, const char *physname; struct bound_minimal_symbol msym; =20 - physname =3D call_site->target.loc_physname (); + physname =3D m_loc.physname; =20 /* Handle both the mangled and demangled PHYSNAME. */ msym =3D lookup_minimal_symbol (physname, NULL, NULL); @@ -720,7 +718,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdb= arch, int sect_idx =3D cust->block_line_section (); CORE_ADDR delta =3D per_objfile->objfile->section_offsets[sect_idx]; =20 - return call_site->target.loc_physaddr () + delta; + return m_loc.physaddr + delta; } =20 default: @@ -790,7 +788,7 @@ func_verify_no_selftailcall (struct gdbarch *gdbarch, C= ORE_ADDR verify_addr) =20 /* CALLER_FRAME with registers is not available for tail-call jumped frames. */ - target_addr =3D call_site_to_target_addr (gdbarch, call_site, NULL); + target_addr =3D call_site->address (gdbarch, nullptr); =20 if (target_addr =3D=3D verify_addr) { @@ -968,7 +966,7 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_A= DDR caller_pc, =20 /* CALLER_FRAME with registers is not available for tail-call jumped frames. */ - target_func_addr =3D call_site_to_target_addr (gdbarch, call_site, N= ULL); + target_func_addr =3D call_site->address (gdbarch, nullptr); =20 if (target_func_addr =3D=3D callee_pc) { @@ -1159,7 +1157,7 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info = *frame, caller_pc =3D get_frame_pc (caller_frame); call_site =3D call_site_for_pc (gdbarch, caller_pc); =20 - target_addr =3D call_site_to_target_addr (gdbarch, call_site, caller_fra= me); + target_addr =3D call_site->address (gdbarch, caller_frame); if (target_addr !=3D func_addr) { struct minimal_symbol *target_msym, *func_msym; diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 122cb355ab1..0e14203aca7 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1835,47 +1835,35 @@ struct call_site_target DWARF_BLOCK, }; =20 - kind loc_kind () const - { - return m_loc_kind; - } - - CORE_ADDR loc_physaddr () const - { - gdb_assert (m_loc_kind =3D=3D PHYSADDR); - return m_loc.physaddr; - } - void set_loc_physaddr (CORE_ADDR physaddr) { m_loc_kind =3D PHYSADDR; m_loc.physaddr =3D physaddr; } =20 - const char *loc_physname () const - { - gdb_assert (m_loc_kind =3D=3D PHYSNAME); - return m_loc.physname; - } - void set_loc_physname (const char *physname) { m_loc_kind =3D PHYSNAME; m_loc.physname =3D physname; } =20 - dwarf2_locexpr_baton *loc_dwarf_block () const - { - gdb_assert (m_loc_kind =3D=3D DWARF_BLOCK); - return m_loc.dwarf_block; - } - void set_loc_dwarf_block (dwarf2_locexpr_baton *dwarf_block) { m_loc_kind =3D DWARF_BLOCK; m_loc.dwarf_block =3D dwarf_block; } =20 + /* Find DW_TAG_call_site's DW_AT_call_target address. CALLER_FRAME + (for registers) can be NULL if it is not known. This function + always returns valid address or it throws + NO_ENTRY_VALUE_ERROR. */ + + CORE_ADDR address (struct gdbarch *call_site_gdbarch, + const struct call_site *call_site, + struct frame_info *caller_frame) const; + +private: + union { /* Address. */ @@ -1967,6 +1955,16 @@ struct call_site =20 CORE_ADDR pc () const; =20 + /* Find the target address. CALLER_FRAME (for registers) can be + NULL if it is not known. This function always returns valid + address or it throws NO_ENTRY_VALUE_ERROR. */ + + CORE_ADDR address (struct gdbarch *call_site_gdbarch, + struct frame_info *caller_frame) const + { + return target.address (call_site_gdbarch, this, caller_frame); + } + /* * List successor with head in FUNC_TYPE.TAIL_CALL_LIST. */ =20 struct call_site *tail_call_next =3D nullptr;