public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: John Baldwin <jhb@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] fbsd-nat: Return a bool from fetch_register_set and store_register_set.
Date: Fri, 28 Jan 2022 19:16:39 +0000 (GMT)	[thread overview]
Message-ID: <20220128191639.F2CAD3948462@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b95a31ed5d2b34f1a4072d701f5cd51075e61c01

commit b95a31ed5d2b34f1a4072d701f5cd51075e61c01
Author: John Baldwin <jhb@FreeBSD.org>
Date:   Fri Jan 28 11:14:37 2022 -0800

    fbsd-nat: Return a bool from fetch_register_set and store_register_set.
    
    Change these helper functions to return true if they did any work.

Diff:
---
 gdb/fbsd-nat.c |  8 ++++++--
 gdb/fbsd-nat.h | 21 ++++++++++++---------
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 9a945576a94..bf606ec1f76 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -1611,7 +1611,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)
@@ -1627,12 +1627,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,
@@ -1652,7 +1654,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 6f8b206dcd5..b32cabb21c3 100644
--- a/gdb/fbsd-nat.h
+++ b/gdb/fbsd-nat.h
@@ -120,12 +120,15 @@ private:
      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:
@@ -133,21 +136,21 @@ protected:
      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));
   }
 };


                 reply	other threads:[~2022-01-28 19:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220128191639.F2CAD3948462@sourceware.org \
    --to=jhb@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).