From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 6601F3858C51; Mon, 28 Mar 2022 19:56:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6601F3858C51 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] Change call_site_target to use custom type and enum X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: b8e92c571baed4e794bd62b7bf417fa8bbaf5c95 X-Git-Newrev: 7eb21cc702249b4fb1beecee25c0c8ccbd9edd15 Message-Id: <20220328195603.6601F3858C51@sourceware.org> Date: Mon, 28 Mar 2022 19:56:03 +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:03 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D7eb21cc70224= 9b4fb1beecee25c0c8ccbd9edd15 commit 7eb21cc702249b4fb1beecee25c0c8ccbd9edd15 Author: Tom Tromey Date: Thu Nov 18 11:25:29 2021 -0700 Change call_site_target to use custom type and enum =20 call_site_target reuses field_loc_kind and field_location. However, it has never used the full range of the field_loc_kind enum. In a subsequent patch, I plan to add a new 'kind' here, so it seemed best to avoid this reuse and instead introduce new types here. Diff: --- gdb/dwarf2/loc.c | 6 +++--- gdb/gdbtypes.h | 38 ++++++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index d7863841a69..16c42a5fdb5 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -643,7 +643,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdb= arch, { switch (call_site->target.loc_kind ()) { - case FIELD_LOC_KIND_DWARF_BLOCK: + case call_site_target::DWARF_BLOCK: { struct dwarf2_locexpr_baton *dwarf_block; struct value *val; @@ -690,7 +690,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdb= arch, return value_as_address (val); } =20 - case FIELD_LOC_KIND_PHYSNAME: + case call_site_target::PHYSNAME: { const char *physname; struct bound_minimal_symbol msym; @@ -713,7 +713,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdb= arch, return BMSYMBOL_VALUE_ADDRESS (msym); } =20 - case FIELD_LOC_KIND_PHYSADDR: + case call_site_target::PHYSADDR: { dwarf2_per_objfile *per_objfile =3D call_site->per_objfile; compunit_symtab *cust =3D per_objfile->get_symtab (call_site->per_cu); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index bd192da4b4b..122cb355ab1 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1824,52 +1824,70 @@ enum call_site_parameter_kind =20 struct call_site_target { - field_loc_kind loc_kind () const + /* The kind of location held by this call site target. */ + enum kind + { + /* An address. */ + PHYSADDR, + /* A name. */ + PHYSNAME, + /* A DWARF block. */ + DWARF_BLOCK, + }; + + kind loc_kind () const { return m_loc_kind; } =20 CORE_ADDR loc_physaddr () const { - gdb_assert (m_loc_kind =3D=3D FIELD_LOC_KIND_PHYSADDR); + gdb_assert (m_loc_kind =3D=3D PHYSADDR); return m_loc.physaddr; } =20 void set_loc_physaddr (CORE_ADDR physaddr) { - m_loc_kind =3D FIELD_LOC_KIND_PHYSADDR; + m_loc_kind =3D PHYSADDR; m_loc.physaddr =3D physaddr; } =20 const char *loc_physname () const { - gdb_assert (m_loc_kind =3D=3D FIELD_LOC_KIND_PHYSNAME); + gdb_assert (m_loc_kind =3D=3D PHYSNAME); return m_loc.physname; } =20 void set_loc_physname (const char *physname) { - m_loc_kind =3D FIELD_LOC_KIND_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 FIELD_LOC_KIND_DWARF_BLOCK); + gdb_assert (m_loc_kind =3D=3D DWARF_BLOCK); return m_loc.dwarf_block; } =20 void set_loc_dwarf_block (dwarf2_locexpr_baton *dwarf_block) { - m_loc_kind =3D FIELD_LOC_KIND_DWARF_BLOCK; + m_loc_kind =3D DWARF_BLOCK; m_loc.dwarf_block =3D dwarf_block; } =20 - union field_location m_loc; + union + { + /* Address. */ + CORE_ADDR physaddr; + /* Mangled name. */ + const char *physname; + /* DWARF block. */ + struct dwarf2_locexpr_baton *dwarf_block; + } m_loc; =20 /* * Discriminant for union field_location. */ - - ENUM_BITFIELD(field_loc_kind) m_loc_kind : 3; + enum kind m_loc_kind; }; =20 union call_site_parameter_u