From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1936) id E4CA23858D32; Mon, 23 May 2022 18:05:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E4CA23858D32 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: John Baldwin To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix loongarch_iterate_over_regset_sections for non-native targets. X-Act-Checkin: binutils-gdb X-Git-Author: John Baldwin X-Git-Refname: refs/heads/master X-Git-Oldrev: a6b446b22270b52dd4739e9ab094e11b307ff0b5 X-Git-Newrev: d9b6e047f60ce2129eff28ad1c6690949293366b Message-Id: <20220523180514.E4CA23858D32@sourceware.org> Date: Mon, 23 May 2022 18:05:14 +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, 23 May 2022 18:05:15 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd9b6e047f60c= e2129eff28ad1c6690949293366b commit d9b6e047f60ce2129eff28ad1c6690949293366b Author: John Baldwin Date: Mon May 23 10:59:13 2022 -0700 Fix loongarch_iterate_over_regset_sections for non-native targets. =20 Define a constant for the number of registers stored in a register set and use this with register_size to compute the size of the general-purpose register set in core dumps. =20 This also fixes the build on hosts such as FreeBSD that do not define an elf_gregset_t type. Diff: --- gdb/loongarch-linux-tdep.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gdb/loongarch-linux-tdep.c b/gdb/loongarch-linux-tdep.c index f13756dd003..bbb43abe13f 100644 --- a/gdb/loongarch-linux-tdep.c +++ b/gdb/loongarch-linux-tdep.c @@ -29,6 +29,11 @@ #include "trad-frame.h" #include "tramp-frame.h" =20 +/* The general-purpose regset consists of 32 R registers, plus PC, + and BADV registers. */ + +#define LOONGARCH_LINUX_NUM_GREGSET (34) + /* Unpack an elf_gregset_t into GDB's register cache. */ =20 static void @@ -172,8 +177,13 @@ loongarch_iterate_over_regset_sections (struct gdbarch= *gdbarch, void *cb_data, const struct regcache *regcache) { - cb (".reg", sizeof (elf_gregset_t), sizeof (elf_gregset_t), - &loongarch_gregset, NULL, cb_data); + loongarch_gdbarch_tdep *tdep + =3D (loongarch_gdbarch_tdep *) gdbarch_tdep (gdbarch); + auto regs =3D tdep->regs; + int regsize =3D register_size (gdbarch, regs.r); + + cb (".reg", LOONGARCH_LINUX_NUM_GREGSET * regsize, + LOONGARCH_LINUX_NUM_GREGSET * regsize, &loongarch_gregset, NULL, cb_= data); } =20 /* Initialize LoongArch Linux ABI info. */