diff options
author | John Baldwin <jhb@FreeBSD.org> | 2022-08-17 17:22:52 -0700 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2022-09-01 16:47:42 -0700 |
commit | 9871dc5976ded0788d8fb69acd78f14e64751d2e (patch) | |
tree | b034f1cfec7841589078b2a0a460767b8313edcf | |
parent | c4b319952eab99f83d25fc63e5e90c85d12d4607 (diff) | |
download | fsf-binutils-gdb-9871dc5976ded0788d8fb69acd78f14e64751d2e.zip fsf-binutils-gdb-9871dc5976ded0788d8fb69acd78f14e64751d2e.tar.gz fsf-binutils-gdb-9871dc5976ded0788d8fb69acd78f14e64751d2e.tar.bz2 |
Use PIOD_READ_CHERI_CAP to read memory capabilities from running processes.
-rw-r--r-- | gdb/fbsd-nat.c | 23 | ||||
-rw-r--r-- | gdb/fbsd-nat.h | 4 |
2 files changed, 27 insertions, 0 deletions
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 9b2a7ed..992c138 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -54,6 +54,10 @@ #define PT_SETREGSET 43 /* Set a target register set */ #endif +#ifndef PIOD_READ_CHERI_CAP +#define PIOD_READ_CHERI_CAP 7 /* Read CHERI capabilities */ +#endif + /* Return the name of a file that can be opened to get the symbols for the child process identified by PID. */ @@ -1953,6 +1957,25 @@ fbsd_nat_target::supports_disable_randomization () #endif } +#if __has_feature(capabilities) +gdb::byte_vector +fbsd_nat_target::read_capability (CORE_ADDR addr) +{ + struct ptrace_io_desc piod; + gdb::byte_vector cap_vec (sizeof (uintcap_t) + 1); + + piod.piod_op = PIOD_READ_CHERI_CAP; + piod.piod_offs = (void *) (uintptr_t) addr; + piod.piod_addr = cap_vec.data (); + piod.piod_len = cap_vec.size (); + if (ptrace (PT_IO, get_ptrace_pid (inferior_ptid), (PTRACE_TYPE_ARG3) &piod, + 0) == -1) + return {}; + + return cap_vec; +} +#endif + /* See fbsd-nat.h. */ bool fbsd_nat_target::have_register_set (ptid_t ptid, int fetch_op, void *regs, diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h index b74be75..1fc4252 100644 --- a/gdb/fbsd-nat.h +++ b/gdb/fbsd-nat.h @@ -109,6 +109,10 @@ public: bool supports_disable_randomization () override; +#if __has_feature(capabilities) + gdb::byte_vector read_capability (CORE_ADDR addr) override; +#endif + /* Methods meant to be overridden by arch-specific target classes. */ |