From: John Baldwin Date: Tue, 2 Aug 2022 17:46:01 +0000 (-0700) Subject: fbsd-nat: Add a have_register_set helper function. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4339421da94cf8cdf9557a4b5ec307b870a9d362;p=thirdparty%2Fbinutils-gdb.git 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. --- diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 32e8f77ead7..9b2a7eda647 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -1953,6 +1953,16 @@ fbsd_nat_target::supports_disable_randomization () #endif } +/* 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 diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h index c0ab1be5d58..b74be75d66c 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 @@ -170,6 +177,13 @@ protected: /* Wrapper versions of the above helpers which accept a register set type such as 'struct reg' or 'struct fpreg'. */ + template + bool have_register_set (ptid_t ptid, int fetch_op) + { + Regset regs; + return have_register_set (ptid, fetch_op, ®s, sizeof (regs)); + } + template bool fetch_register_set (struct regcache *regcache, int regnum, int fetch_op, const struct regset *regset, int regbase = 0)