[7/8] fbsd-nat: Return a bool from fetch_register_set and store_register_set.

Message ID 20210714140741.6460-8-jhb@FreeBSD.org
State New
Headers show
Series
  • Switch FreeBSD x86 to using register maps for GP registers
Related show

Commit Message

John Baldwin July 14, 2021, 2:07 p.m.
Change these helper functions to return true if they did any work.
---
 gdb/fbsd-nat.c |  8 ++++++--
 gdb/fbsd-nat.h | 21 ++++++++++++---------
 2 files changed, 18 insertions(+), 11 deletions(-)

-- 
2.31.1

Patch

diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 33eddb5f22..aa6abecec1 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -1603,7 +1603,7 @@  fbsd_nat_target::supports_disable_randomization ()
 
 /* See fbsd-nat.h.  */
 
-void
+bool
 fbsd_nat_target::fetch_register_set (struct regcache *regcache, int regnum,
 				     int fetch_op, const struct regset *regset,
 				     void *regs, size_t size)
@@ -1619,12 +1619,14 @@  fbsd_nat_target::fetch_register_set (struct regcache *regcache, int regnum,
 	perror_with_name (_("Couldn't get registers"));
 
       regcache->supply_regset (regset, regnum, regs, size);
+      return true;
     }
+  return false;
 }
 
 /* See fbsd-nat.h.  */
 
-void
+bool
 fbsd_nat_target::store_register_set (struct regcache *regcache, int regnum,
 				     int fetch_op, int store_op,
 				     const struct regset *regset, void *regs,
@@ -1644,7 +1646,9 @@  fbsd_nat_target::store_register_set (struct regcache *regcache, int regnum,
 
       if (ptrace (store_op, pid, (PTRACE_TYPE_ARG3) regs, 0) == -1)
 	perror_with_name (_("Couldn't write registers"));
+      return true;
     }
+  return false;
 }
 
 void _initialize_fbsd_nat ();
diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h
index a59065415b..292542bf8e 100644
--- a/gdb/fbsd-nat.h
+++ b/gdb/fbsd-nat.h
@@ -117,12 +117,15 @@  class fbsd_nat_target : public inf_ptrace_target
      of registers to a native thread.
 
      The caller must provide storage for the set of registers in REGS,
-     and SIZE is the size of the storage.  */
+     and SIZE is the size of the storage.
 
-  void fetch_register_set (struct regcache *regcache, int regnum, int fetch_op,
+     Returns true if the register set was transferred due to a
+     matching REGNUM.*/
+
+  bool fetch_register_set (struct regcache *regcache, int regnum, int fetch_op,
 			   const struct regset *regset, void *regs, size_t size);
 
-  void store_register_set (struct regcache *regcache, int regnum, int fetch_op,
+  bool store_register_set (struct regcache *regcache, int regnum, int fetch_op,
 			   int store_op, const struct regset *regset,
 			   void *regs, size_t size);
 protected:
@@ -130,21 +133,21 @@  class fbsd_nat_target : public inf_ptrace_target
      type such as 'struct reg' or 'struct fpreg'.  */
 
   template <class Regset>
-  void fetch_register_set (struct regcache *regcache, int regnum, int fetch_op,
+  bool fetch_register_set (struct regcache *regcache, int regnum, int fetch_op,
 			   const struct regset *regset)
   {
     Regset regs;
-    fetch_register_set (regcache, regnum, fetch_op, regset, &regs,
-			sizeof (regs));
+    return fetch_register_set (regcache, regnum, fetch_op, regset, &regs,
+			       sizeof (regs));
   }
 
   template <class Regset>
-  void store_register_set (struct regcache *regcache, int regnum, int fetch_op,
+  bool store_register_set (struct regcache *regcache, int regnum, int fetch_op,
 			   int store_op, const struct regset *regset)
   {
     Regset regs;
-    store_register_set (regcache, regnum, fetch_op, store_op, regset, &regs,
-			sizeof (regs));
+    return store_register_set (regcache, regnum, fetch_op, store_op, regset,
+			       &regs, sizeof (regs));
   }
 };