diff options
author | John Baldwin <jhb@FreeBSD.org> | 2022-08-02 10:46:01 -0700 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2022-09-01 16:47:42 -0700 |
commit | 4339421da94cf8cdf9557a4b5ec307b870a9d362 (patch) | |
tree | baaf185ebed224f36271c896895146ced14a30a8 | |
parent | fa4c1b42280912a1196322c9155475278de5b035 (diff) | |
download | fsf-binutils-gdb-4339421da94cf8cdf9557a4b5ec307b870a9d362.zip fsf-binutils-gdb-4339421da94cf8cdf9557a4b5ec307b870a9d362.tar.gz fsf-binutils-gdb-4339421da94cf8cdf9557a4b5ec307b870a9d362.tar.bz2 |
fbsd-nat: Add a have_register_set helper function.
This is similar to have_regset but is used for older register sets that
pre-date PT_GETREGSET and use separate fetch and store ptrace operations.
-rw-r--r-- | gdb/fbsd-nat.c | 10 | ||||
-rw-r--r-- | gdb/fbsd-nat.h | 14 |
2 files changed, 24 insertions, 0 deletions
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 32e8f77..9b2a7ed 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -1954,6 +1954,16 @@ fbsd_nat_target::supports_disable_randomization () } /* See fbsd-nat.h. */ +bool +fbsd_nat_target::have_register_set (ptid_t ptid, int fetch_op, void *regs, + size_t size) +{ + pid_t pid = get_ptrace_pid (ptid); + + return ptrace (fetch_op, pid, (PTRACE_TYPE_ARG3) regs, 0) == 0; +} + +/* See fbsd-nat.h. */ bool fbsd_nat_target::fetch_register_set (struct regcache *regcache, int regnum, diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h index c0ab1be..b74be75 100644 --- a/gdb/fbsd-nat.h +++ b/gdb/fbsd-nat.h @@ -130,6 +130,13 @@ protected: private: ptid_t wait_1 (ptid_t, struct target_waitstatus *, target_wait_flags); + /* Helper routine for use in read_description in subclasses. This + routine checks if the register set fetched via FETCH_OP is + present for a given PTID and returns a bool indicating success or + failure. */ + + bool have_register_set (ptid_t ptid, int fetch_op, void *regs, size_t size); + /* Helper routines for use in fetch_registers and store_registers in subclasses. These routines fetch and store a single set of registers described by REGSET. The REGSET's 'regmap' field must @@ -171,6 +178,13 @@ protected: type such as 'struct reg' or 'struct fpreg'. */ template <class Regset> + bool have_register_set (ptid_t ptid, int fetch_op) + { + Regset regs; + return have_register_set (ptid, fetch_op, ®s, sizeof (regs)); + } + + template <class Regset> bool fetch_register_set (struct regcache *regcache, int regnum, int fetch_op, const struct regset *regset, int regbase = 0) { |