From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7873) id C550F3858D1E; Sat, 2 Mar 2024 11:08:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C550F3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1709377705; bh=G3Q39N4DDbLkYGzlcIfWfc5TZ3o2Vx+73sDQnXfeM9s=; h=From:To:Subject:Date:From; b=AsJ88GRk/1Fd8mEk+aLGWhX6CiemntIbVv83Ihi9dPAGxRkNIYzi+d7SuwU2R5i7s EbVEeWO6NfNLlxKv+kR4HNvK3AWilcLal1xYTi6u7Pkl1EA22CafLgBRAHhwOPohe7 Gl2kJXdATCsbjCveWcAfk7/1nuUjlTmz4FKxw6q0= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tiezhu Yang To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: LoongArch: Change LOONGARCH_FIRST_FP_REGNUM to 35 X-Act-Checkin: binutils-gdb X-Git-Author: Hui Li X-Git-Refname: refs/heads/master X-Git-Oldrev: a6a3b67fa9052bba81ed91a38569c11ecb95baf1 X-Git-Newrev: 1304f47d02bfd0b41ebf4c1c6758a6251c29d8a1 Message-Id: <20240302110825.C550F3858D1E@sourceware.org> Date: Sat, 2 Mar 2024 11:08:25 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D1304f47d02bf= d0b41ebf4c1c6758a6251c29d8a1 commit 1304f47d02bfd0b41ebf4c1c6758a6251c29d8a1 Author: Hui Li Date: Tue Feb 27 09:18:10 2024 +0800 gdb: LoongArch: Change LOONGARCH_FIRST_FP_REGNUM to 35 =20 There is an assertion error "gdb_assert (n < tdesc->reg_defs.size ())" in find_register_by_number() when gdb connects to gdbserver, this is because the value of LOONGARCH_LINUX_NUM_GREGSET (45, which contains 10 reserved regs) is different with the number of regs (35, which not contains 10 reserved regs) in file gdb/features/loongarch/base64.xml. Add a new macro LOONGARCH_USED_NUM_GREGSET which is defined as 35 to keep consistent with the gdb/features/loongarch/base64.xml, and then define LOONGARCH_FIRST_FP_REGNUM as LOONGARCH_USED_NUM_GREGSET so that all the reg numbers in regcache are consistent with tdesc reg numbers. =20 without this patch: =20 Execute on the target machine: =20 $ gdbserver 192.168.1.123:5678 ./test =20 Execute on the host machine: =20 $ gdb ./test (gdb) target remote 192.168.1.123:5678 =20 Output on the target machine: =20 Process ./test created; pid =3D 67683 Listening on port 5678 Remote debugging from host 192.168.1.136, port 6789 gdbserver/regcache.cc:205: A problem internal to GDBserver has been d= etected. find_register_by_number: Assertion 'n < tdesc->reg_defs.size ()' fail= ed. =20 Output on the host machine: =20 Remote debugging using 192.168.1.123:5678 Remote connection closed =20 Signed-off-by: Hui Li Approved-By: John Baldwin Signed-off-by: Tiezhu Yang Diff: --- gdb/arch/loongarch.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gdb/arch/loongarch.h b/gdb/arch/loongarch.h index 4b7ab054ea0..7056d506bf4 100644 --- a/gdb/arch/loongarch.h +++ b/gdb/arch/loongarch.h @@ -33,10 +33,11 @@ enum loongarch_regnum LOONGARCH_ORIG_A0_REGNUM =3D 32, /* Syscall's original arg0. */ LOONGARCH_PC_REGNUM =3D 33, /* Program Counter. */ LOONGARCH_BADV_REGNUM =3D 34, /* Bad Vaddr for Addressing Exception. */ + LOONGARCH_USED_NUM_GREGSET =3D 35, /* 32 GPR, ORIG_A0, PC, BADV. */ LOONGARCH_LINUX_NUM_GREGSET =3D 45, /* 32 GPR, ORIG_A0, PC, BADV, RESERV= ED 10. */ LOONGARCH_ARG_REGNUM =3D 8, /* r4-r11: general-purpose argume= nt registers. f0-f7: floating-point argument registers. */ - LOONGARCH_FIRST_FP_REGNUM =3D LOONGARCH_LINUX_NUM_GREGSET, + LOONGARCH_FIRST_FP_REGNUM =3D LOONGARCH_USED_NUM_GREGSET, LOONGARCH_LINUX_NUM_FPREGSET =3D 32, LOONGARCH_FIRST_FCC_REGNUM =3D LOONGARCH_FIRST_FP_REGNUM + LOONGARCH_LIN= UX_NUM_FPREGSET, LOONGARCH_LINUX_NUM_FCC =3D 8,