aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2022-10-12 15:18:53 -0700
committerJohn Baldwin <jhb@FreeBSD.org>2022-10-13 11:25:32 -0700
commit8ff1bd02227d35386cbcff210be686c68e1865c8 (patch)
treee75cf7203336ff09420daa4d3c9c673d951547d0
parentd16bdb3d994a9d40f728892511a42f9cd5c71e6a (diff)
downloadgdb-8ff1bd02227d35386cbcff210be686c68e1865c8.zip
gdb-8ff1bd02227d35386cbcff210be686c68e1865c8.tar.gz
gdb-8ff1bd02227d35386cbcff210be686c68e1865c8.tar.bz2
Native support for FreeBSD CHERI-RISC-V.
-rw-r--r--gdb/riscv-fbsd-nat.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gdb/riscv-fbsd-nat.c b/gdb/riscv-fbsd-nat.c
index 40cb40d..ad89a19 100644
--- a/gdb/riscv-fbsd-nat.c
+++ b/gdb/riscv-fbsd-nat.c
@@ -19,6 +19,7 @@
#include "defs.h"
#include "regcache.h"
+#include "inferior.h"
#include "target.h"
#include <sys/types.h>
@@ -34,6 +35,9 @@ struct riscv_fbsd_nat_target final : public fbsd_nat_target
{
void fetch_registers (struct regcache *, int) override;
void store_registers (struct regcache *, int) override;
+#if __has_feature(capabilities)
+ const struct target_desc *read_description () override;
+#endif
};
static riscv_fbsd_nat_target the_riscv_fbsd_nat_target;
@@ -51,6 +55,11 @@ riscv_fbsd_nat_target::fetch_registers (struct regcache *regcache,
&riscv_fbsd_gregset);
fetch_register_set<struct fpreg> (regcache, regnum, PT_GETFPREGS,
&riscv_fbsd_fpregset);
+#if __has_feature(capabilities)
+ if (riscv_isa_clen (regcache->arch ()) != 0)
+ fetch_register_set<struct capreg> (regcache, regnum, PT_GETCAPREGS,
+ &riscv_fbsd_capregset);
+#endif
}
/* Store register REGNUM back into the inferior. If REGNUM is -1, do
@@ -64,8 +73,31 @@ riscv_fbsd_nat_target::store_registers (struct regcache *regcache,
&riscv_fbsd_gregset);
store_register_set<struct fpreg> (regcache, regnum, PT_GETFPREGS,
PT_SETFPREGS, &riscv_fbsd_fpregset);
+#ifdef notyet
+ if (riscv_isa_clen (regcache->arch ()) != 0)
+ store_register_set<struct capreg> (regcache, regnum, PT_GETCAPREGS,
+ PT_SETCAPREGS, &riscv_fbsd_capregset);
+#endif
}
+#if __has_feature(capabilities)
+/* Implement the read_description method. */
+
+const struct target_desc *
+riscv_fbsd_nat_target::read_description ()
+{
+ struct riscv_gdbarch_features features;
+ struct reg *reg;
+
+ features.xlen = sizeof (reg->ra);
+ features.flen = sizeof (uint64_t);
+ if (have_register_set<struct capreg> (inferior_ptid, PT_GETCAPREGS))
+ features.clen = sizeof (uintcap_t);
+
+ return riscv_lookup_target_description (features);
+}
+#endif
+
void _initialize_riscv_fbsd_nat ();
void
_initialize_riscv_fbsd_nat ()