Add the cooked register interface.
authorAndrew Cagney <cagney@redhat.com>
Fri, 2 Aug 2002 18:08:31 +0000 (18:08 +0000)
committerAndrew Cagney <cagney@redhat.com>
Fri, 2 Aug 2002 18:08:31 +0000 (18:08 +0000)
gdb/ChangeLog
gdb/regcache.c
gdb/regcache.h

index 97b6d5b7ceb75b7923dfee865e379c01e6aaa468..69282443349538241b8063fd70fad9d4ee88d1aa 100644 (file)
@@ -1,3 +1,13 @@
+2002-08-02  Andrew Cagney  <ac131313@redhat.com>
+
+       * regcache.c (regcache_cooked_read): New function.
+       (regcache_cooked_write): New function.
+       (read_register_gen): Rewrite using regcache_cooked_read.
+       (write_register_gen): Rewrite using regcache_cooked_write.
+
+       * regcache.h (regcache_cooked_read, regcache_cooked_write):
+       Declare.
+
 2002-08-02  Andrew Cagney  <cagney@redhat.com>
 
        * gdbarch.sh (pseudo_register_read, pseudo_register_write):
index 7d4a8d6de2e5f8b53932d5b1e38d48cbbd6fc359..70af8f093bdaa2a21db2c30e96c0bc0da1ad5e89 100644 (file)
@@ -719,16 +719,21 @@ read_register_gen (int regnum, char *buf)
       legacy_read_register_gen (regnum, buf);
       return;
     }
+  regcache_cooked_read (current_regcache, regnum, buf);
+}
+
+void
+regcache_cooked_read (struct regcache *regcache, int rawnum, void *buf)
+{
   gdb_assert (regnum >= 0);
-  gdb_assert (regnum < current_regcache->descr->nr_cooked_registers);
-  if (regnum < current_regcache->descr->nr_raw_registers)
-    regcache_raw_read (current_regcache, regnum, buf);
+  gdb_assert (regnum < regcache->descr->nr_cooked_registers);
+  if (regnum < regcache->descr->nr_raw_registers)
+    regcache_raw_read (regcache, regnum, buf);
   else
-    gdbarch_pseudo_register_read (current_gdbarch, current_regcache,
-                                 regnum, buf);
+    gdbarch_pseudo_register_read (regcache->descr->gdbarch, regcache,
+                                 regnum, buf);
 }
 
-
 /* Write register REGNUM at MYADDR to the target.  MYADDR points at
    REGISTER_RAW_BYTES(REGNUM), which must be in target byte-order.  */
 
@@ -834,12 +839,19 @@ write_register_gen (int regnum, char *buf)
       legacy_write_register_gen (regnum, buf);
       return;
     }
+  regcache_cooked_write (current_regcache, regnum, buf);
+}
+
+void
+regcache_cooked_write (struct regcache *regcache, int rawnum,
+                      const void *buf)
+{
   gdb_assert (regnum >= 0);
-  gdb_assert (regnum < current_regcache->descr->nr_cooked_registers);
-  if (regnum < current_regcache->descr->nr_raw_registers)
-    regcache_raw_write (current_regcache, regnum, buf);
+  gdb_assert (regnum < regcache->descr->nr_cooked_registers);
+  if (regnum < regcache->descr->nr_raw_registers)
+    regcache_raw_write (regcache, regnum, buf);
   else
-    gdbarch_pseudo_register_write (current_gdbarch, current_regcache,
+    gdbarch_pseudo_register_write (regcache->descr->gdbarch, regcache,
                                   regnum, buf);
 }
 
index cd5bb83ee300941cd5f0904d3dcb0f29e0e353aa..5ca7babad67e8ad4a6c1993037ae32e58151a9bd 100644 (file)
@@ -41,6 +41,11 @@ void regcache_raw_write (struct regcache *regcache, int rawnum,
 int regcache_valid_p (struct regcache *regcache, int regnum);
 CORE_ADDR regcache_raw_read_as_address (struct regcache *regcache, int rawnum);
 
+/* Transfer a cooked register [0..NUM_REGS+NUM_PSEUDO_REGS).  */
+void regcache_cooked_read (struct regcache *regcache, int rawnum, void *buf);
+void regcache_cooked_write (struct regcache *regcache, int rawnum,
+                           const void *buf);
+
 /* Transfer a raw register [0..NUM_REGS) between the regcache and the
    target.  These functions are called by the target in response to a
    target_fetch_registers() or target_store_registers().  */