2002-08-09 Andrew Cagney <cagney@redhat.com>
authorAndrew Cagney <cagney@redhat.com>
Sat, 10 Aug 2002 02:00:16 +0000 (02:00 +0000)
committerAndrew Cagney <cagney@redhat.com>
Sat, 10 Aug 2002 02:00:16 +0000 (02:00 +0000)
* regcache.c (regcache_dump): Compare the register offset
with REGISTER_BYTE.
* arch-utils.c (generic_register_byte): New function.
* arch-utils.h (generic_register_byte): Declare.
* gdbarch.sh (REGISTER_BYTE): Default to generic_register_byte.
* gdbarch.h, gdbarch.c: Regenerate.

gdb/ChangeLog
gdb/arch-utils.c
gdb/arch-utils.h
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/regcache.c

index 2546b4365bec6ad1c228be552b51034d72b7d178..53f5c66ec44861f20b75893e6f82f2ab8aa8b11e 100644 (file)
@@ -1,3 +1,12 @@
+2002-08-09  Andrew Cagney  <cagney@redhat.com>
+
+       * regcache.c (regcache_dump): Compare the register offset
+       with REGISTER_BYTE.
+       * arch-utils.c (generic_register_byte): New function.
+       * arch-utils.h (generic_register_byte): Declare.
+       * gdbarch.sh (REGISTER_BYTE): Default to generic_register_byte.
+       * gdbarch.h, gdbarch.c: Regenerate.
+
 2002-08-09  Andrew Cagney  <cagney@redhat.com>
 
        * regcache.c: Include "gdbcmd.h"
index a407f9e28be49f634ad427cca7bd0ed4ab107298..5497e83308be468e4009c1ca89a8826b33835b49 100644 (file)
@@ -444,6 +444,23 @@ generic_register_size (int regnum)
        (name && STREQ ("_sigtramp", name))
 #endif
 #endif
+
+/* Assume all registers are adjacent.  */
+
+int
+generic_register_byte (int regnum)
+{
+  int byte;
+  int i;
+  gdb_assert (regnum >= 0 && regnum < NUM_REGS + NUM_PSEUDO_REGS);
+  byte = 0;
+  for (i = 0; i < regnum; i++)
+    {
+      byte += TYPE_LENGTH (REGISTER_VIRTUAL_TYPE (i));
+    }
+  return byte;
+}
+
 \f
 int
 legacy_pc_in_sigtramp (CORE_ADDR pc, char *name)
index 7ceb8b70b845cb77921f1eb1ae1c25974d333661..a38272c9099710534fc9dc3bfa812f2f1e026507 100644 (file)
@@ -155,6 +155,9 @@ extern void default_print_float_info (struct gdbarch *gdbarch,
 
 extern int generic_register_size (int regnum);
 
+/* Assume that the world is sane, the registers are all adjacent.  */
+extern int generic_register_byte (int regnum);
+
 /* Prop up old targets that use various IN_SIGTRAMP() macros.  */
 extern int legacy_pc_in_sigtramp (CORE_ADDR pc, char *name);
 
index 93a5c0e5aff67eb400707e13e6b394eb1e9c9e97..e2e5b7b6b3339a5b33d08180507accfeb8a3ae39 100644 (file)
@@ -315,7 +315,7 @@ struct gdbarch startup_gdbarch =
   0,
   0,
   0,
-  0,
+  generic_register_byte,
   generic_register_size,
   0,
   generic_register_size,
@@ -484,6 +484,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
   current_gdbarch->register_name = legacy_register_name;
   current_gdbarch->register_size = -1;
   current_gdbarch->register_bytes = -1;
+  current_gdbarch->register_byte = generic_register_byte;
   current_gdbarch->register_raw_size = generic_register_size;
   current_gdbarch->max_register_raw_size = -1;
   current_gdbarch->register_virtual_size = generic_register_size;
@@ -623,9 +624,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
   if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
       && (gdbarch->register_bytes == -1))
     fprintf_unfiltered (log, "\n\tregister_bytes");
-  if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
-      && (gdbarch->register_byte == 0))
-    fprintf_unfiltered (log, "\n\tregister_byte");
+  /* Skip verify of register_byte, invalid_p == 0 */
   /* Skip verify of register_raw_size, invalid_p == 0 */
   if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
       && (gdbarch->max_register_raw_size == -1))
index 57fb0cf71f55aa66660eec2a977df24fee510b89..973f250b626dc78ac55e0a39e5dff5fe501e3965 100644 (file)
@@ -693,6 +693,11 @@ extern void set_gdbarch_register_bytes (struct gdbarch *gdbarch, int register_by
 #endif
 #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))
+#endif
+
 typedef int (gdbarch_register_byte_ftype) (int reg_nr);
 extern int gdbarch_register_byte (struct gdbarch *gdbarch, int reg_nr);
 extern void set_gdbarch_register_byte (struct gdbarch *gdbarch, gdbarch_register_byte_ftype *register_byte);
index 141eba31b91a24faa34ed4dc6c59fcb55e534147..f416aea174363133732bdefae422561ff21bebcc 100755 (executable)
@@ -461,7 +461,7 @@ f:2:DWARF2_REG_TO_REGNUM:int:dwarf2_reg_to_regnum:int dwarf2_regnr:dwarf2_regnr:
 f:2:REGISTER_NAME:const char *:register_name:int regnr:regnr:::legacy_register_name::0
 v:2:REGISTER_SIZE:int:register_size::::0:-1
 v:2:REGISTER_BYTES:int:register_bytes::::0:-1
-f:2:REGISTER_BYTE:int:register_byte:int reg_nr:reg_nr::0:0
+f:2:REGISTER_BYTE:int:register_byte:int reg_nr:reg_nr::generic_register_byte:generic_register_byte::0
 f:2:REGISTER_RAW_SIZE:int:register_raw_size:int reg_nr:reg_nr::generic_register_size:generic_register_size::0
 v:2:MAX_REGISTER_RAW_SIZE:int:max_register_raw_size::::0:-1
 f:2:REGISTER_VIRTUAL_SIZE:int:register_virtual_size:int reg_nr:reg_nr::generic_register_size:generic_register_size::0
index dcfe7aa8f4eada4454a53e8ac83708d378186369..c633d2dd944bd0f161fd2132e6e1a83fb959f418 100644 (file)
@@ -1279,7 +1279,8 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
        {
          fprintf_unfiltered (file, " %6ld",
                              regcache->descr->register_offset[regnum]);
-         if (register_offset != regcache->descr->register_offset[regnum])
+         if (register_offset != regcache->descr->register_offset[regnum]
+             || register_offset != REGISTER_BYTE (regnum))
            {
              if (!footnote_register_offset)
                footnote_register_offset = ++footnote_nr;