+2018-06-11 Alan Hayward <alan.hayward@arm.com>
+
+ * common/common-regcache.h (raw_compare): New function.
+ * regcache.c (regcache::raw_compare): Likewise.
+ * regcache.h (regcache::raw_compare): New declaration.
+
2018-06-11 Alan Hayward <alan.hayward@arm.com>
* common/common-regcache.h (reg_buffer_common): New structure.
/* Collect register REGNUM from REGCACHE and store its contents in BUF. */
virtual void raw_collect (int regnum, void *buf) const = 0;
+
+ /* Compare the contents of the register stored in the regcache (ignoring the
+ first OFFSET bytes) to the contents of BUF (without any offset). Returns
+ true if the same. */
+ virtual bool raw_compare (int regnum, const void *buf, int offset) const = 0;
};
#endif /* COMMON_REGCACHE_H */
+2018-06-11 Alan Hayward <alan.hayward@arm.com>
+
+ * regcache.c (regcache::raw_compare): New function.
+ * regcache.h (regcache::raw_compare): New declaration.
+
2018-06-11 Alan Hayward <alan.hayward@arm.com>
* regcache.c (new_register_cache): Use new.
return REG_VALID;
#endif
}
+
+/* See common/common-regcache.h. */
+
+bool
+regcache::raw_compare (int regnum, const void *buf, int offset) const
+{
+ gdb_assert (buf != NULL);
+
+ const unsigned char *regbuf = register_data (this, regnum, 1);
+ int size = register_size (tdesc, regnum);
+ gdb_assert (size >= offset);
+
+ return (memcmp (buf, regbuf + offset, size - offset) == 0);
+}
/* See common/common-regcache.h. */
void raw_collect (int regnum, void *buf) const override;
+
+ /* See common/common-regcache.h. */
+ bool raw_compare (int regnum, const void *buf, int offset) const override;
};
struct regcache *init_register_cache (struct regcache *regcache,
transfer_regset (regset, NULL, regnum, NULL, buf, size);
}
+/* See common/common-regcache.h. */
+
+bool
+reg_buffer::raw_compare (int regnum, const void *buf, int offset) const
+{
+ gdb_assert (buf != NULL);
+ assert_regnum (regnum);
+
+ const char *regbuf = (const char *) register_buffer (regnum);
+ size_t size = m_descr->sizeof_register[regnum];
+ gdb_assert (size >= offset);
+
+ return (memcmp (buf, regbuf + offset, size - offset) == 0);
+}
/* Special handling for register PC. */
virtual ~reg_buffer () = default;
+ /* See common/common-regcache.h. */
+ bool raw_compare (int regnum, const void *buf, int offset) const override;
+
protected:
/* Assert on the range of REGNUM. */
void assert_regnum (int regnum) const;