Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Alan Hayward <alan.hayward@arm.com>
To: gdb-patches@sourceware.org
Cc: nd@arm.com,	Alan Hayward <alan.hayward@arm.com>
Subject: [PATCH v2 04/10] Add regcache raw_compare method
Date: Wed, 06 Jun 2018 15:17:00 -0000	[thread overview]
Message-ID: <20180606151629.36602-5-alan.hayward@arm.com> (raw)
In-Reply-To: <20180606151629.36602-1-alan.hayward@arm.com>

raw_compare returns the same as a memcmp (0 for success,
the diff otherwise). Kept with tristate return as this
feels potentally more useful than a simple true/false return.
(Happy to change if not).

2018-06-06  Alan Hayward  <alan.hayward@arm.com>

gdb/
	* common/common-regcache.h (raw_compare): New function.
	* regcache.c (regcache::raw_compare): Likewise.
	* regcache.h (regcache::raw_compare): New declaration.

gdbserver/
	* regcache.c (regcache::raw_compare): New function.
	* regcache.h (regcache::raw_compare): New declaration.
---
 gdb/common/common-regcache.h |  1 +
 gdb/gdbserver/regcache.c     | 10 ++++++++++
 gdb/gdbserver/regcache.h     |  5 +++++
 gdb/regcache.c               | 15 +++++++++++++++
 gdb/regcache.h               | 11 +++++++++++
 5 files changed, 42 insertions(+)

diff --git a/gdb/common/common-regcache.h b/gdb/common/common-regcache.h
index 487da0a7fb..e91439bec5 100644
--- a/gdb/common/common-regcache.h
+++ b/gdb/common/common-regcache.h
@@ -67,6 +67,7 @@ struct reg_buffer_common
   virtual ~reg_buffer_common () = default;
   virtual void raw_supply (int regnum, const void *buf) = 0;
   virtual void raw_collect (int regnum, void *buf) const = 0;
+  virtual int raw_compare (int regnum, const void *buf, int offset) const = 0;
   virtual register_status get_register_status (int regnum) const = 0;
 };
 
diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c
index 857721ee3d..9648428349 100644
--- a/gdb/gdbserver/regcache.c
+++ b/gdb/gdbserver/regcache.c
@@ -501,3 +501,13 @@ regcache::get_register_status (int regnum) const
   return REG_VALID;
 #endif
 }
+
+/* See gdbserver/regcache.h.  */
+
+int
+regcache::raw_compare (int regnum, const void *buf, int offset) const
+{
+  gdb_assert (register_size (tdesc, regnum) > offset);
+  return memcmp (buf, register_data (this, regnum, 1) + offset,
+		 register_size (tdesc, regnum) - offset);
+}
diff --git a/gdb/gdbserver/regcache.h b/gdb/gdbserver/regcache.h
index 1842f1d9cf..b26f39a8ad 100644
--- a/gdb/gdbserver/regcache.h
+++ b/gdb/gdbserver/regcache.h
@@ -50,6 +50,11 @@ struct regcache : public reg_buffer_common
 
   void raw_collect (int regnum, void *buf) const override;
 
+  /* Compare the contents of the register stored in the regcache (ignoring the
+     first OFFSET bytes) to the contents of BUF (without any offset).  Returns
+     the same result as memcmp.  */
+  int raw_compare (int regnum, const void *buf, int offset) const override;
+
   enum register_status get_register_status (int regnum) const override;
 };
 
diff --git a/gdb/regcache.c b/gdb/regcache.c
index a914b548ca..383e355e9f 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -1082,6 +1082,21 @@ regcache::collect_regset (const struct regset *regset,
   transfer_regset (regset, NULL, regnum, NULL, buf, size);
 }
 
+/* See regcache.h.  */
+
+int
+regcache::raw_compare (int regnum, const void *buf, int offset) const
+{
+  const char *regbuf;
+  size_t size;
+
+  gdb_assert (buf != NULL);
+  assert_regnum (regnum);
+
+  regbuf = (const char *) register_buffer (regnum);
+  size = m_descr->sizeof_register[regnum];
+  return memcmp (buf, regbuf + offset, size - offset);
+}
 
 /* Special handling for register PC.  */
 
diff --git a/gdb/regcache.h b/gdb/regcache.h
index b559a10752..03fb4f2452 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -169,6 +169,12 @@ public:
     gdb_assert (false);
   }
 
+  virtual int raw_compare (int regnum, const void *buf,
+			   int offset) const override
+  {
+    gdb_assert (false);
+  }
+
 protected:
   /* Assert on the range of REGNUM.  */
   void assert_regnum (int regnum) const;
@@ -325,6 +331,11 @@ public:
   void collect_regset (const struct regset *regset, int regnum,
 		       void *buf, size_t size) const;
 
+  /* Compare the contents of the register stored in the regcache (ignoring the
+     first OFFSET bytes) to the contents of BUF (without any offset).  Returns
+     the same result as memcmp.  */
+  int raw_compare (int regnum, const void *buf, int offset) const override;
+
   /* Return REGCACHE's ptid.  */
 
   ptid_t ptid () const
-- 
2.15.1 (Apple Git-101)


  parent reply	other threads:[~2018-06-06 15:17 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-06 15:16 [PATCH v2 00/10] gdb/gdbserver support for aarch64 SVE Alan Hayward
2018-06-06 15:17 ` [PATCH v2 07/10] Increase gdbsever PBUFSIZ Alan Hayward
2018-06-11  0:46   ` Simon Marchi
2018-06-06 15:17 ` [PATCH v2 09/10] Ptrace support for AArch64 SVE gdbsever Alan Hayward
2018-06-11  2:43   ` Simon Marchi
2018-06-11  2:44   ` Simon Marchi
2018-06-06 15:17 ` [PATCH v2 05/10] Ptrace support for Aarch64 SVE Alan Hayward
2018-06-10 22:52   ` Simon Marchi
2018-06-06 15:17 ` [PATCH v2 01/10] Aarch64 SVE pseudo register support Alan Hayward
2018-06-06 22:17   ` Simon Marchi
2018-06-07  9:34     ` Alan Hayward
2018-06-06 15:17 ` [PATCH v2 10/10] Remove reg2 section from Aarch64 SVE cores Alan Hayward
2018-06-11  2:47   ` Simon Marchi
2018-06-11 16:37     ` Alan Hayward
2018-06-06 15:17 ` Alan Hayward [this message]
2018-06-07 20:56   ` [PATCH v2 04/10] Add regcache raw_compare method Simon Marchi
2018-06-08 15:16     ` Alan Hayward
2018-06-10 22:26       ` Simon Marchi
2018-06-06 15:17 ` [PATCH v2 06/10] Add Aarch64 SVE dwarf regnums Alan Hayward
2018-06-11  0:43   ` Simon Marchi
2018-06-06 15:17 ` [PATCH v2 02/10] Add Aarch64 SVE Linux headers Alan Hayward
2018-06-08 14:13   ` Alan Hayward
2018-06-08 14:37     ` Simon Marchi
2018-06-08 15:27       ` Alan Hayward
     [not found]       ` <82743c0795488492486076685b9f8828@polymtl.ca>
2018-06-12 14:37         ` Alan Hayward
2018-06-12 14:51           ` Simon Marchi
2018-06-12 16:34             ` Sergio Durigan Junior
2018-06-12 17:51               ` Alan Hayward
     [not found]                 ` <8736xr4ukx.fsf@redhat.com>
2018-06-15  9:45                   ` Ramana Radhakrishnan
2018-06-15 17:14                     ` Alan Hayward
2018-09-20 21:16                       ` Status of the AArch* builders (was: Re: [PATCH v2 02/10] Add Aarch64 SVE Linux headers) Sergio Durigan Junior
2018-09-24 14:16                         ` Alan Hayward
     [not found]                           ` <87a7o7ot6r.fsf@redhat.com>
2018-10-11  9:23                             ` Status of the AArch* builders Alan Hayward
2018-10-12 19:06                               ` Sergio Durigan Junior
2018-10-15 10:16                                 ` Alan Hayward
2018-10-15 12:42                                   ` Sergio Durigan Junior
2018-10-15 14:02                                     ` Alan Hayward
2018-10-15 15:32                                       ` Sergio Durigan Junior
2018-10-17 18:46                                         ` Sergio Durigan Junior
2018-10-24  9:56                                           ` Alan Hayward
2018-10-25 16:26                                             ` Sergio Durigan Junior
     [not found]           ` <8f6d2b87-707a-3e34-325c-ed9338e9c1f6@redhat.com>
2018-06-12 15:06             ` [PATCH v2 02/10] Add Aarch64 SVE Linux headers Simon Marchi
     [not found]               ` <0f4bd1b7-897f-b42a-3067-2397a1b4c58c@redhat.com>
2018-06-12 15:21                 ` Simon Marchi
2018-06-12 15:09             ` Alan Hayward
2018-06-06 15:17 ` [PATCH v2 03/10] Add reg_buffer_common Alan Hayward
2018-06-07 20:19   ` Simon Marchi
2018-06-07 20:42     ` Simon Marchi
     [not found]     ` <CEE89B18-4FE7-4171-9BBF-0FD17AECFBED@arm.com>
2018-06-10 22:21       ` Simon Marchi
2018-06-06 15:17 ` [PATCH v2 08/10] Enable Aarch64 SVE for gdbserver Alan Hayward
2018-06-11  0:49   ` Simon Marchi

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=20180606151629.36602-5-alan.hayward@arm.com \
    --to=alan.hayward@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.com \
    /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