From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: gdb-patches@sourceware.org
Subject: [COMMITTED PATCH 2/2] gdbserver: LoongArch: Add floating-point support
Date: Tue, 12 Jul 2022 20:21:59 +0800 [thread overview]
Message-ID: <20220712122159.5840-2-yangtiezhu@loongson.cn> (raw)
In-Reply-To: <20220712122159.5840-1-yangtiezhu@loongson.cn>
This commit adds floating-point support for LoongArch gdbserver.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
gdbserver/linux-loongarch-low.cc | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/gdbserver/linux-loongarch-low.cc b/gdbserver/linux-loongarch-low.cc
index 91826b42361..7180f315b11 100644
--- a/gdbserver/linux-loongarch-low.cc
+++ b/gdbserver/linux-loongarch-low.cc
@@ -120,10 +120,42 @@ loongarch_store_gregset (struct regcache *regcache, const void *buf)
supply_register (regcache, LOONGARCH_BADV_REGNUM, *regset + LOONGARCH_BADV_REGNUM);
}
+/* Collect FPRs from REGCACHE into BUF. */
+
+static void
+loongarch_fill_fpregset (struct regcache *regcache, void *buf)
+{
+ gdb_byte *regbuf = nullptr;
+ int fprsize = register_size (regcache->tdesc, LOONGARCH_FIRST_FP_REGNUM);
+
+ for (int i = 0; i < LOONGARCH_LINUX_NUM_FPREGSET; i++)
+ {
+ regbuf = (gdb_byte *)buf + fprsize * i;
+ collect_register (regcache, LOONGARCH_FIRST_FP_REGNUM + i, regbuf);
+ }
+}
+
+/* Supply FPRs from BUF into REGCACHE. */
+
+static void
+loongarch_store_fpregset (struct regcache *regcache, const void *buf)
+{
+ const gdb_byte *regbuf = nullptr;
+ int fprsize = register_size (regcache->tdesc, LOONGARCH_FIRST_FP_REGNUM);
+
+ for (int i = 0; i < LOONGARCH_LINUX_NUM_FPREGSET; i++)
+ {
+ regbuf = (const gdb_byte *)buf + fprsize * i;
+ supply_register (regcache, LOONGARCH_FIRST_FP_REGNUM + i, regbuf);
+ }
+}
+
/* LoongArch/Linux regsets. */
static struct regset_info loongarch_regsets[] = {
{ PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS, sizeof (elf_gregset_t),
GENERAL_REGS, loongarch_fill_gregset, loongarch_store_gregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_FPREGSET, sizeof (elf_fpregset_t),
+ FP_REGS, loongarch_fill_fpregset, loongarch_store_fpregset },
NULL_REGSET
};
--
2.27.0
next prev parent reply other threads:[~2022-07-12 12:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-12 12:21 [COMMITTED PATCH 1/2] gdb: " Tiezhu Yang
2022-07-12 12:21 ` Tiezhu Yang [this message]
2022-07-12 17:48 ` Pedro Alves
2022-07-13 6:40 ` Tiezhu Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220712122159.5840-2-yangtiezhu@loongson.cn \
--to=yangtiezhu@loongson.cn \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).