2002-08-12 Andrew Cagney <cagney@redhat.com>
authorAndrew Cagney <cagney@redhat.com>
Tue, 13 Aug 2002 13:58:50 +0000 (13:58 +0000)
committerAndrew Cagney <cagney@redhat.com>
Tue, 13 Aug 2002 13:58:50 +0000 (13:58 +0000)
* regcache.c (regcache_raw_read_as_address): Delete function.
(regcache_cooked_read_signed): New function.
(regcache_cooked_read_unsigned): New function.
* regcache.h (regcache_cooked_read_signed): Declare.
(regcache_cooked_read_unsigned): Declare.
(regcache_raw_read_as_address): Delete declaration.
* blockframe.c (generic_read_register_dummy): Use
regcache_cooked_read_unsigned.
* i386-tdep.c (i386_extract_struct_value_address): Use
regcache_cooked_read_unsigned.

gdb/ChangeLog
gdb/blockframe.c
gdb/i386-tdep.c
gdb/regcache.c
gdb/regcache.h

index ef871a5fa334220e5070f75d733215c0d9ea9d7f..97a5bab1e1b86234d93676c507e02d96042f2a42 100644 (file)
@@ -1,3 +1,17 @@
+2002-08-13  Andrew Cagney  <cagney@redhat.com>
+
+       * regcache.c (regcache_raw_read_as_address): Delete function.
+       (regcache_cooked_read_signed): New function.
+       (regcache_cooked_read_unsigned): New function.
+       * regcache.h (regcache_cooked_read_signed): Declare.
+       (regcache_cooked_read_unsigned): Declare.
+       (regcache_raw_read_as_address): Delete declaration.
+
+       * blockframe.c (generic_read_register_dummy): Use
+       regcache_cooked_read_unsigned.
+       * i386-tdep.c (i386_extract_struct_value_address): Use
+       regcache_cooked_read_unsigned.
+
 2002-08-13  Stephane Carrez  <stcarrez@nerim.fr>
 
        * m68hc11-tdep.c (m68hc11_gdbarch_init): Set int, double and long
index d255beecc1fd0d41783eb0d3283454009c57dd56..d83586cd536340ee91239d532535c653ed22e7d0 100644 (file)
@@ -1215,7 +1215,20 @@ generic_read_register_dummy (CORE_ADDR pc, CORE_ADDR fp, int regno)
   struct regcache *dummy_regs = generic_find_dummy_frame (pc, fp);
 
   if (dummy_regs)
-    return regcache_raw_read_as_address (dummy_regs, regno);
+    {
+      /* NOTE: cagney/2002-08-12: Replaced a call to
+        regcache_raw_read_as_address() with a call to
+        regcache_cooked_read_unsigned().  The old, ...as_address
+        function was eventually calling extract_unsigned_integer (via
+        extract_address) to unpack the registers value.  The below is
+        doing an unsigned extract so that it is functionally
+        equivalent.  The read needs to be cooked as, otherwise, it
+        will never correctly return the value of a register in the
+        [NUM_REGS .. NUM_REGS+NUM_PSEUDO_REGS) range.  */
+      ULONGEST val;
+      regcache_cooked_read_unsigned (dummy_regs, regno, &val);
+      return val;
+    }
   else
     return 0;
 }
index 2968c318c01339cc8db0780e1c72cc08c46f0a71..ad196918984352ea42bb8fe4e8bb5d2f2b0af884 100644 (file)
@@ -1028,7 +1028,18 @@ i386_store_return_value (struct type *type, char *valbuf)
 static CORE_ADDR
 i386_extract_struct_value_address (struct regcache *regcache)
 {
-  return regcache_raw_read_as_address (regcache, LOW_RETURN_REGNUM);
+  /* NOTE: cagney/2002-08-12: Replaced a call to
+     regcache_raw_read_as_address() with a call to
+     regcache_cooked_read_unsigned().  The old, ...as_address function
+     was eventually calling extract_unsigned_integer (via
+     extract_address) to unpack the registers value.  The below is
+     doing an unsigned extract so that it is functionally equivalent.
+     The read needs to be cooked as, otherwise, it will never
+     correctly return the value of a register in the [NUM_REGS
+     .. NUM_REGS+NUM_PSEUDO_REGS) range.  */
+  ULONGEST val;
+  regcache_cooked_read_unsigned (regcache, LOW_RETURN_REGNUM, &val);
+  return val;
 }
 \f
 
index c633d2dd944bd0f161fd2132e6e1a83fb959f418..6878b52bb4649a482424f2e0543690a2e217ab12 100644 (file)
@@ -366,17 +366,6 @@ regcache_valid_p (struct regcache *regcache, int regnum)
   return regcache->raw_register_valid_p[regnum];
 }
 
-CORE_ADDR
-regcache_raw_read_as_address (struct regcache *regcache, int regnum)
-{
-  char *buf;
-  gdb_assert (regcache != NULL);
-  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
-  buf = alloca (regcache->descr->sizeof_register[regnum]);
-  regcache_raw_read (regcache, regnum, buf);
-  return extract_address (buf, regcache->descr->sizeof_register[regnum]);
-}
-
 char *
 deprecated_grub_regcache_for_registers (struct regcache *regcache)
 {
@@ -696,6 +685,32 @@ regcache_cooked_read (struct regcache *regcache, int regnum, void *buf)
                                  regnum, buf);
 }
 
+void
+regcache_cooked_read_signed (struct regcache *regcache, int regnum,
+                            LONGEST *val)
+{
+  char *buf;
+  gdb_assert (regcache != NULL);
+  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
+  buf = alloca (regcache->descr->sizeof_register[regnum]);
+  regcache_cooked_read (regcache, regnum, buf);
+  (*val) = extract_signed_integer (buf,
+                                  regcache->descr->sizeof_register[regnum]);
+}
+
+void
+regcache_cooked_read_unsigned (struct regcache *regcache, int regnum,
+                              ULONGEST *val)
+{
+  char *buf;
+  gdb_assert (regcache != NULL);
+  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
+  buf = alloca (regcache->descr->sizeof_register[regnum]);
+  regcache_cooked_read (regcache, regnum, buf);
+  (*val) = extract_unsigned_integer (buf,
+                                    regcache->descr->sizeof_register[regnum]);
+}
+
 /* Write register REGNUM at MYADDR to the target.  MYADDR points at
    REGISTER_RAW_BYTES(REGNUM), which must be in target byte-order.  */
 
index 5ca7babad67e8ad4a6c1993037ae32e58151a9bd..117b088c44b88adde0b9b40c9c3dfbc5bd351c2c 100644 (file)
@@ -39,13 +39,26 @@ void regcache_raw_read (struct regcache *regcache, int rawnum, void *buf);
 void regcache_raw_write (struct regcache *regcache, int rawnum,
                         const void *buf);
 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);
 
+/* NOTE: cagney/2002-08-13: At present GDB has no reliable mechanism
+   for indicating when a ``cooked'' register was constructed from
+   invalid or unavailable ``raw'' registers.  One fairly easy way of
+   adding such a mechanism would be for the cooked functions to return
+   a register valid indication.  Given the possibility of such a
+   change, the extract functions below use a reference parameter,
+   rather than a function result.  */
+
+/* Read a register as a signed/unsigned quantity.  */
+extern void regcache_cooked_read_signed (struct regcache *regcache,
+                                        int regnum, LONGEST *val);
+extern void regcache_cooked_read_unsigned (struct regcache *regcache,
+                                          int regnum, ULONGEST *val);
+
 /* 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().  */
This page took 0.033811 seconds and 4 git commands to generate.