diff options
author | Alan Hayward <alan.hayward@arm.com> | 2018-06-11 10:09:30 +0100 |
---|---|---|
committer | Alan Hayward <alan.hayward@arm.com> | 2018-06-11 10:09:30 +0100 |
commit | f868386e72baad6f35d4288f433266e03ed2753d (patch) | |
tree | b82c89d28fcca4f7e8fdcbc82acfae391f1222af /gdb | |
parent | 9c861883169cb9eec4581ab6db3a1b711e79ee10 (diff) | |
download | gdb-f868386e72baad6f35d4288f433266e03ed2753d.zip gdb-f868386e72baad6f35d4288f433266e03ed2753d.tar.gz gdb-f868386e72baad6f35d4288f433266e03ed2753d.tar.bz2 |
Add regcache raw_compare method
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.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/common/common-regcache.h | 5 | ||||
-rw-r--r-- | gdb/gdbserver/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/gdbserver/regcache.c | 14 | ||||
-rw-r--r-- | gdb/gdbserver/regcache.h | 3 | ||||
-rw-r--r-- | gdb/regcache.c | 14 | ||||
-rw-r--r-- | gdb/regcache.h | 3 |
7 files changed, 50 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9fddd6f..3e51f87 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 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. * regcache.c (reg_buffer::invalidate): Move from detached_regcache. (reg_buffer::raw_supply): Likewise. diff --git a/gdb/common/common-regcache.h b/gdb/common/common-regcache.h index 4e6bdde..18080b2 100644 --- a/gdb/common/common-regcache.h +++ b/gdb/common/common-regcache.h @@ -75,6 +75,11 @@ struct reg_buffer_common /* 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 */ diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index d11ce5d..475a1aa 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,10 @@ 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. (free_register_cache): Use delete. (register_data): Use const. diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c index 8383752..735ce7b 100644 --- a/gdb/gdbserver/regcache.c +++ b/gdb/gdbserver/regcache.c @@ -502,3 +502,17 @@ regcache::get_register_status (int regnum) const 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); +} diff --git a/gdb/gdbserver/regcache.h b/gdb/gdbserver/regcache.h index 352c1df..b4c4c20 100644 --- a/gdb/gdbserver/regcache.h +++ b/gdb/gdbserver/regcache.h @@ -54,6 +54,9 @@ struct regcache : public reg_buffer_common /* 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, diff --git a/gdb/regcache.c b/gdb/regcache.c index c10c588..750ea2a 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1079,6 +1079,20 @@ regcache::collect_regset (const struct regset *regset, 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. */ diff --git a/gdb/regcache.h b/gdb/regcache.h index 3b72986..41465fb 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -188,6 +188,9 @@ public: 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; |