aboutsummaryrefslogtreecommitdiff
path: root/gdb/regcache.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2002-08-19 00:43:41 +0000
committerAndrew Cagney <cagney@redhat.com>2002-08-19 00:43:41 +0000
commit06c0b04e1c76a02e8aba3a590f65acdd30011dba (patch)
treef66e0f45746dc73679c7d9e298490e79e41e20ae /gdb/regcache.c
parent0c528862c525f4158d36efc55c37ccc49b9e8cff (diff)
downloadgdb-06c0b04e1c76a02e8aba3a590f65acdd30011dba.zip
gdb-06c0b04e1c76a02e8aba3a590f65acdd30011dba.tar.gz
gdb-06c0b04e1c76a02e8aba3a590f65acdd30011dba.tar.bz2
2002-08-18 Andrew Cagney <ac131313@redhat.com>
* regcache.c (regcache_xfer_part): New function. (regcache_raw_read_part): New function. (regcache_raw_write_part): New function. (regcache_cooked_read_part): New function. (regcache_cooked_write_part): New function. * regcache.h (regcache_raw_read_part): Declare. (regcache_raw_write_part): Declare. (regcache_cooked_read_part): Declare. (regcache_cooked_write_part): Declare.
Diffstat (limited to 'gdb/regcache.c')
-rw-r--r--gdb/regcache.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/gdb/regcache.c b/gdb/regcache.c
index e46f082..e483de0 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -916,6 +916,86 @@ write_register_bytes (int myregstart, char *myaddr, int inlen)
}
}
+/* Perform a partial register transfer using a read, modify, write
+ operation. */
+
+typedef void (regcache_read_ftype) (struct regcache *regcache, int regnum,
+ void *buf);
+typedef void (regcache_write_ftype) (struct regcache *regcache, int regnum,
+ const void *buf);
+
+void
+regcache_xfer_part (struct regcache *regcache, int regnum,
+ int offset, int len, void *in, const void *out,
+ regcache_read_ftype *read, regcache_write_ftype *write)
+{
+ struct regcache_descr *descr = regcache->descr;
+ bfd_byte *reg = alloca (descr->max_register_size);
+ gdb_assert (offset >= 0 && offset <= descr->sizeof_register[regnum]);
+ gdb_assert (len >= 0 && offset + len <= descr->sizeof_register[regnum]);
+ /* Something to do? */
+ if (offset + len == 0)
+ return;
+ /* Read (when needed) ... */
+ if (in != NULL
+ || offset > 0
+ || offset + len < descr->sizeof_register[regnum])
+ {
+ gdb_assert (read != NULL);
+ read (regcache, regnum, reg);
+ }
+ /* ... modify ... */
+ if (in != NULL)
+ memcpy (in, reg + offset, len);
+ if (out != NULL)
+ memcpy (reg + offset, out, len);
+ /* ... write (when needed). */
+ if (out != NULL)
+ {
+ gdb_assert (write != NULL);
+ write (regcache, regnum, reg);
+ }
+}
+
+void
+regcache_raw_read_part (struct regcache *regcache, int regnum,
+ int offset, int len, void *buf)
+{
+ struct regcache_descr *descr = regcache->descr;
+ gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
+ regcache_xfer_part (regcache, regnum, offset, len, buf, NULL,
+ regcache_raw_read, regcache_raw_write);
+}
+
+void
+regcache_raw_write_part (struct regcache *regcache, int regnum,
+ int offset, int len, const void *buf)
+{
+ struct regcache_descr *descr = regcache->descr;
+ gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
+ regcache_xfer_part (regcache, regnum, offset, len, NULL, buf,
+ regcache_raw_read, regcache_raw_write);
+}
+
+void
+regcache_cooked_read_part (struct regcache *regcache, int regnum,
+ int offset, int len, void *buf)
+{
+ struct regcache_descr *descr = regcache->descr;
+ gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
+ regcache_xfer_part (regcache, regnum, offset, len, buf, NULL,
+ regcache_cooked_read, regcache_cooked_write);
+}
+
+void
+regcache_cooked_write_part (struct regcache *regcache, int regnum,
+ int offset, int len, const void *buf)
+{
+ struct regcache_descr *descr = regcache->descr;
+ gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
+ regcache_xfer_part (regcache, regnum, offset, len, NULL, buf,
+ regcache_cooked_read, regcache_cooked_write);
+}
/* Return the contents of register REGNUM as an unsigned integer. */