+2003-05-04 Andrew Cagney <cagney@redhat.com>
+
+ * sentinel-frame.c (sentinel_frame_prev_register): Replace
+ REGISTER_BYTE with register_offset_hack.
+ * regcache.c (init_regcache_descr): When REGISTER_BYTE_P, check
+ that REGISTER_BYTE is consistent with the regcache.
+ * gdbarch.sh (REGISTER_BYTE): Add a predicate.
+ * gdbarch.h, gdbarch.c: Regenerate.
+
2003-05-04 Mark Kettenis <kettenis@gnu.org>
* i387-tdep.c (fxsave_offset): Add entries for %xmm8-%xmm15.
/* Skip verify of sdb_reg_to_regnum, invalid_p == 0 */
/* Skip verify of dwarf2_reg_to_regnum, invalid_p == 0 */
/* Skip verify of register_name, invalid_p == 0 */
- /* Skip verify of register_byte, invalid_p == 0 */
+ /* Skip verify of register_byte, has predicate */
/* Skip verify of register_raw_size, invalid_p == 0 */
/* Skip verify of deprecated_max_register_raw_size, has predicate */
/* Skip verify of register_virtual_size, invalid_p == 0 */
fprintf_unfiltered (file,
"gdbarch_dump: push_dummy_code = 0x%08lx\n",
(long) current_gdbarch->push_dummy_code);
+#ifdef REGISTER_BYTE_P
+ fprintf_unfiltered (file,
+ "gdbarch_dump: %s # %s\n",
+ "REGISTER_BYTE_P()",
+ XSTRING (REGISTER_BYTE_P ()));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: REGISTER_BYTE_P() = %d\n",
+ REGISTER_BYTE_P ());
+#endif
#ifdef REGISTER_BYTE
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
gdbarch->register_bytes = register_bytes;
}
+int
+gdbarch_register_byte_p (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ return gdbarch->register_byte != generic_register_byte;
+}
+
int
gdbarch_register_byte (struct gdbarch *gdbarch, int reg_nr)
{
if (gdbarch->register_byte == 0)
internal_error (__FILE__, __LINE__,
"gdbarch: gdbarch_register_byte invalid");
+ /* Ignore predicate (gdbarch->register_byte != generic_register_byte). */
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_register_byte called\n");
return gdbarch->register_byte (reg_nr);
#define REGISTER_BYTES (gdbarch_register_bytes (current_gdbarch))
#endif
+/* NOTE: cagney/2002-05-02: This function with predicate has a valid
+ (callable) initial value. As a consequence, even when the predicate
+ is false, the corresponding function works. This simplifies the
+ migration process - old code, calling REGISTER_BYTE, doesn't need to
+ be modified. */
+
+#if defined (REGISTER_BYTE)
+/* Legacy for systems yet to multi-arch REGISTER_BYTE */
+#if !defined (REGISTER_BYTE_P)
+#define REGISTER_BYTE_P() (1)
+#endif
+#endif
+
+/* Default predicate for non- multi-arch targets. */
+#if (!GDB_MULTI_ARCH) && !defined (REGISTER_BYTE_P)
+#define REGISTER_BYTE_P() (0)
+#endif
+
+extern int gdbarch_register_byte_p (struct gdbarch *gdbarch);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (REGISTER_BYTE_P)
+#error "Non multi-arch definition of REGISTER_BYTE"
+#endif
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (REGISTER_BYTE_P)
+#define REGISTER_BYTE_P() (gdbarch_register_byte_p (current_gdbarch))
+#endif
+
/* Default (function) for non- multi-arch platforms. */
#if (!GDB_MULTI_ARCH) && !defined (REGISTER_BYTE)
#define REGISTER_BYTE(reg_nr) (generic_register_byte (reg_nr))
f:2:REGISTER_NAME:const char *:register_name:int regnr:regnr:::legacy_register_name::0
v::REGISTER_SIZE:int:register_size
v::REGISTER_BYTES:int:register_bytes
-f:2:REGISTER_BYTE:int:register_byte:int reg_nr:reg_nr::generic_register_byte:generic_register_byte::0
+# NOTE: cagney/2002-05-02: This function with predicate has a valid
+# (callable) initial value. As a consequence, even when the predicate
+# is false, the corresponding function works. This simplifies the
+# migration process - old code, calling REGISTER_BYTE, doesn't need to
+# be modified.
+F::REGISTER_BYTE:int:register_byte:int reg_nr:reg_nr::generic_register_byte:generic_register_byte
# The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
# MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
# REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE are all being replaced
&& !gdbarch_pseudo_register_write_p (gdbarch)
&& !gdbarch_register_type_p (gdbarch))
{
+ /* NOTE: cagney/2003-05-02: Don't add a test for REGISTER_BYTE_P
+ to the above. Doing that would cause all the existing
+ architectures to revert back to the legacy regcache
+ mechanisms, and that is not a good thing. Instead just,
+ later, check that the register cache's layout is consistent
+ with REGISTER_BYTE. */
descr->legacy_p = 1;
init_legacy_regcache_descr (gdbarch, descr);
return descr;
buffer. Ulgh! */
descr->sizeof_raw_registers = descr->sizeof_cooked_registers;
-#if 0
- /* Sanity check. Confirm that the assumptions about gdbarch are
- true. The REGCACHE_DESCR_HANDLE is set before doing the checks
- so that targets using the generic methods supplied by regcache
- don't go into infinite recursion trying to, again, create the
- regcache. */
- set_gdbarch_data (gdbarch, regcache_descr_handle, descr);
+ /* Sanity check. Confirm that there is agreement between the
+ regcache and the target's redundant REGISTER_BYTE (new targets
+ should not even be defining it). */
for (i = 0; i < descr->nr_cooked_registers; i++)
{
+ if (REGISTER_BYTE_P ())
+ gdb_assert (descr->register_offset[i] == REGISTER_BYTE (i));
+#if 0
gdb_assert (descr->sizeof_register[i] == REGISTER_RAW_SIZE (i));
gdb_assert (descr->sizeof_register[i] == REGISTER_VIRTUAL_SIZE (i));
- gdb_assert (descr->register_offset[i] == REGISTER_BYTE (i));
+#endif
}
/* gdb_assert (descr->sizeof_raw_registers == REGISTER_BYTES (i)); */
-#endif
return descr;
}
onto the corresponding hardware register. */
*optimized = 0;
*lvalp = lval_register;
- *addrp = REGISTER_BYTE (regnum);
+ *addrp = register_offset_hack (current_gdbarch, regnum);
*realnum = regnum;
/* If needed, find and return the value of the register. */