From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [66.216.25.90]) by sourceware.org (Postfix) with ESMTPS id 619323858D32 for ; Mon, 23 May 2022 18:17:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 619323858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from ralph.com (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 4E3FB1A84C75; Mon, 23 May 2022 14:17:03 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PUSHED OBV] Fix loongarch_iterate_over_regset_sections for non-native targets. Date: Mon, 23 May 2022 11:15:59 -0700 Message-Id: <20220523181559.54764-1-jhb@FreeBSD.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Mon, 23 May 2022 14:17:03 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_STATUS, KHOP_HELO_FCRDNS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2022 18:17:09 -0000 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. This also fixes the build on hosts such as FreeBSD that do not define an elf_gregset_t type. --- 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" +/* 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. */ 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 + = (loongarch_gdbarch_tdep *) gdbarch_tdep (gdbarch); + auto regs = tdep->regs; + int regsize = register_size (gdbarch, regs.r); + + cb (".reg", LOONGARCH_LINUX_NUM_GREGSET * regsize, + LOONGARCH_LINUX_NUM_GREGSET * regsize, &loongarch_gregset, NULL, cb_data); } /* Initialize LoongArch Linux ABI info. */ -- 2.36.1