From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7882) id EE7893830801; Tue, 12 Jul 2022 01:59:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE7893830801 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jiangshuai Li To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/csky complete csky_dwarf_reg_to_regnum X-Act-Checkin: binutils-gdb X-Git-Author: Jiangshuai Li X-Git-Refname: refs/heads/master X-Git-Oldrev: 242f3484dba6ae27a8fb6b673c37179fd42091e5 X-Git-Newrev: d5ffc11fcbd43cb72e3ba55a52bb8df6374a8745 Message-Id: <20220712015941.EE7893830801@sourceware.org> Date: Tue, 12 Jul 2022 01:59:41 +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: Tue, 12 Jul 2022 01:59:42 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd5ffc11fcbd4= 3cb72e3ba55a52bb8df6374a8745 commit d5ffc11fcbd43cb72e3ba55a52bb8df6374a8745 Author: Jiangshuai Li Date: Tue Jul 12 09:54:58 2022 +0800 gdb/csky complete csky_dwarf_reg_to_regnum =20 For csky arch, the correspondence between Dwarf registers and GDB registers are as follows: dwarf regnos 0~31 =3D=3D> gdb regs r0~r31 dwarf regno CSKY_HI_REGNUM(36) =3D=3D> gdb reg hi dwarf regno CSKY_LO_REGNUM(37) =3D=3D> gdb reg hi dwarf regno CSKY_PC_REGNUM(72) =3D=3D> gdb reg pc dwarf regnos FV_PSEUDO_REGNO_FIRST(74)~FV_PSEUDO_REGNO_LAST(201) =3D=3D> gdb regs s0~s127 (pseudo regs for float and vector regs) =20 other dwarf regnos have no corresponding gdb regs to them. Diff: --- gdb/csky-tdep.c | 25 ++++++++++++++++++++++--- gdb/csky-tdep.h | 4 ++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c index b63ff7ccd44..502b01e33e1 100644 --- a/gdb/csky-tdep.c +++ b/gdb/csky-tdep.c @@ -2556,9 +2556,28 @@ csky_register_reggroup_p (struct gdbarch *gdbarch, i= nt regnum, static int csky_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int dw_reg) { - if (dw_reg < 0 || dw_reg >=3D CSKY_NUM_REGS) - return -1; - return dw_reg; + /* For GPRs. */ + if (dw_reg >=3D CSKY_R0_REGNUM && dw_reg <=3D (CSKY_R0_REGNUM + 31)) + return dw_reg; + + /* For Hi, Lo, PC. */ + if ((dw_reg =3D=3D CSKY_HI_REGNUM) || (dw_reg =3D=3D CSKY_LO_REGNUM) + || (dw_reg =3D=3D CSKY_PC_REGNUM)) + return dw_reg; + + /* For Float and Vector pseudo registers. */ + if ((dw_reg >=3D FV_PSEUDO_REGNO_FIRST) && (dw_reg <=3D FV_PSEUDO_REGNO= _LAST)) + { + char name_buf[4]; + + xsnprintf (name_buf, sizeof (name_buf), "s%d", + dw_reg - FV_PSEUDO_REGNO_FIRST); + return user_reg_map_name_to_regnum (gdbarch, name_buf, + strlen (name_buf)); + } + + /* Others, unknown. */ + return -1; } =20 /* Override interface for command: info register. */ diff --git a/gdb/csky-tdep.h b/gdb/csky-tdep.h index 4ff8a6b8613..4cfc0a5d086 100644 --- a/gdb/csky-tdep.h +++ b/gdb/csky-tdep.h @@ -108,6 +108,10 @@ enum csky_regnum /* For fr0~fr15, fr16~fr31, vr0~vr15 check. */ #define CSKY_FULL16_ONEHOT_VALUE 0xffff =20 +/* Define for CSKY FV pseudo regs for dwarf regs. */ +#define FV_PSEUDO_REGNO_FIRST 74 +#define FV_PSEUDO_REGNO_LAST 201 + /* Number of processor registers w/o ICE registers. */ #define CSKY_NUM_REGS (CSKY_MAX_REGS - CSKY_CRBANK_NUM_REGS)