2003-03-01 Andrew Cagney <cagney@redhat.com>
authorAndrew Cagney <cagney@redhat.com>
Sat, 1 Mar 2003 17:59:12 +0000 (17:59 +0000)
committerAndrew Cagney <cagney@redhat.com>
Sat, 1 Mar 2003 17:59:12 +0000 (17:59 +0000)
* gdbarch.sh (register_type): New function with predicate.
(REGISTER_VIRTUAL_TYPE): Change to function with predicate.
* gdbarch.h, gdbarch.c: Re-generate.
* arch-utils.c (generic_register_byte): Use generic_register_size.
(generic_register_size): When available, use
gdbarch_register_type.
* regcache.c (init_regcache_descr): When available, initialize the
register type array using gdbarch_register_type.  If the
architecture supplies gdbarch_register_type, do not use the legacy
regcache layout.
* d10v-tdep.c (d10v_register_type): Replace
d10v_register_virtual_type.
(d10v_gdbarch_init): Set register_type instead of
register_virtual_type.

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

index 6048ffb2ff25832a8d10403030678207c8bd65a7..30945a96e190ed74d3af3056f149ad3b9509a08c 100644 (file)
@@ -1,3 +1,20 @@
+2003-03-01  Andrew Cagney  <cagney@redhat.com>
+
+       * gdbarch.sh (register_type): New function with predicate.
+       (REGISTER_VIRTUAL_TYPE): Change to function with predicate.
+       * gdbarch.h, gdbarch.c: Re-generate.
+       * arch-utils.c (generic_register_byte): Use generic_register_size.
+       (generic_register_size): When available, use
+       gdbarch_register_type.
+       * regcache.c (init_regcache_descr): When available, initialize the
+       register type array using gdbarch_register_type.  If the
+       architecture supplies gdbarch_register_type, do not use the legacy
+       regcache layout.
+       * d10v-tdep.c (d10v_register_type): Replace
+       d10v_register_virtual_type.
+       (d10v_gdbarch_init): Set register_type instead of
+       register_virtual_type.
+
 2003-03-01  Andrew Cagney  <cagney@redhat.com>
 
        * Makefile.in (ax-gdb.o): Update dependencies.
index 1202df980ce95783bfb031f54fb55c1fd09231b6..d1d49fd68d61ccfac76b333f1f6e8f1c2e33eeed 100644 (file)
@@ -440,7 +440,13 @@ int
 generic_register_size (int regnum)
 {
   gdb_assert (regnum >= 0 && regnum < NUM_REGS + NUM_PSEUDO_REGS);
-  return TYPE_LENGTH (REGISTER_VIRTUAL_TYPE (regnum));
+  if (gdbarch_register_type_p (current_gdbarch))
+    return TYPE_LENGTH (gdbarch_register_type (current_gdbarch, regnum));
+  else
+    /* FIXME: cagney/2003-03-01: Once all architectures implement
+       gdbarch_register_type(), this entire function can go away.  It
+       is made obsolete by register_size().  */
+    return TYPE_LENGTH (REGISTER_VIRTUAL_TYPE (regnum)); /* OK */
 }
 
 /* Assume all registers are adjacent.  */
@@ -454,7 +460,7 @@ generic_register_byte (int regnum)
   byte = 0;
   for (i = 0; i < regnum; i++)
     {
-      byte += TYPE_LENGTH (REGISTER_VIRTUAL_TYPE (i));
+      byte += generic_register_size (regnum);
     }
   return byte;
 }
index da491b70bf9a5db465b3c6dbefa80f91716395f4..3c1852a256bf2c5e320dc207f5239ff687c90fa3 100644 (file)
@@ -348,7 +348,7 @@ d10v_register_raw_size (int reg_nr)
    of data in register N.  */
 
 static struct type *
-d10v_register_virtual_type (int reg_nr)
+d10v_register_type (struct gdbarch *gdbarch, int reg_nr)
 {
   if (reg_nr == PC_REGNUM)
     return builtin_type_void_func_ptr;
@@ -1652,7 +1652,7 @@ d10v_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_max_register_raw_size (gdbarch, 8);
   set_gdbarch_register_virtual_size (gdbarch, generic_register_size);
   set_gdbarch_max_register_virtual_size (gdbarch, 8);
-  set_gdbarch_register_virtual_type (gdbarch, d10v_register_virtual_type);
+  set_gdbarch_register_type (gdbarch, d10v_register_type);
 
   set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
   set_gdbarch_addr_bit (gdbarch, 32);
index c8e296ca6e4ce0161b1bb17c92d086d56eb94d3c..bf168548f3451c9303dd66a87563570dcc32f52a 100644 (file)
@@ -174,6 +174,7 @@ struct gdbarch
   gdbarch_register_virtual_size_ftype *register_virtual_size;
   int max_register_virtual_size;
   gdbarch_register_virtual_type_ftype *register_virtual_type;
+  gdbarch_register_type_ftype *register_type;
   gdbarch_deprecated_do_registers_info_ftype *deprecated_do_registers_info;
   gdbarch_print_registers_info_ftype *print_registers_info;
   gdbarch_print_float_info_ftype *print_float_info;
@@ -339,6 +340,7 @@ struct gdbarch startup_gdbarch =
   0,
   0,
   0,
+  0,
   default_print_registers_info,
   0,
   0,
@@ -666,9 +668,8 @@ verify_gdbarch (struct gdbarch *gdbarch)
   if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
       && (gdbarch->max_register_virtual_size == -1))
     fprintf_unfiltered (log, "\n\tmax_register_virtual_size");
-  if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
-      && (gdbarch->register_virtual_type == 0))
-    fprintf_unfiltered (log, "\n\tregister_virtual_type");
+  /* Skip verify of register_virtual_type, has predicate */
+  /* Skip verify of register_type, has predicate */
   /* Skip verify of deprecated_do_registers_info, has predicate */
   /* Skip verify of print_registers_info, invalid_p == 0 */
   /* Skip verify of print_float_info, has predicate */
@@ -2031,6 +2032,14 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
                         (long) current_gdbarch->register_to_value
                         /*REGISTER_TO_VALUE ()*/);
 #endif
+  if (GDB_MULTI_ARCH)
+    fprintf_unfiltered (file,
+                        "gdbarch_dump: gdbarch_register_type_p() = %d\n",
+                        gdbarch_register_type_p (current_gdbarch));
+  if (GDB_MULTI_ARCH)
+    fprintf_unfiltered (file,
+                        "gdbarch_dump: register_type = 0x%08lx\n",
+                        (long) current_gdbarch->register_type);
 #ifdef REGISTER_VIRTUAL_SIZE
   fprintf_unfiltered (file,
                       "gdbarch_dump: %s # %s\n",
@@ -2042,6 +2051,15 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
                         (long) current_gdbarch->register_virtual_size
                         /*REGISTER_VIRTUAL_SIZE ()*/);
 #endif
+#ifdef REGISTER_VIRTUAL_TYPE_P
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: %s # %s\n",
+                      "REGISTER_VIRTUAL_TYPE_P()",
+                      XSTRING (REGISTER_VIRTUAL_TYPE_P ()));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: REGISTER_VIRTUAL_TYPE_P() = %d\n",
+                      REGISTER_VIRTUAL_TYPE_P ());
+#endif
 #ifdef REGISTER_VIRTUAL_TYPE
   fprintf_unfiltered (file,
                       "gdbarch_dump: %s # %s\n",
@@ -3344,6 +3362,13 @@ set_gdbarch_max_register_virtual_size (struct gdbarch *gdbarch,
   gdbarch->max_register_virtual_size = max_register_virtual_size;
 }
 
+int
+gdbarch_register_virtual_type_p (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  return gdbarch->register_virtual_type != 0;
+}
+
 struct type *
 gdbarch_register_virtual_type (struct gdbarch *gdbarch, int reg_nr)
 {
@@ -3363,6 +3388,32 @@ set_gdbarch_register_virtual_type (struct gdbarch *gdbarch,
   gdbarch->register_virtual_type = register_virtual_type;
 }
 
+int
+gdbarch_register_type_p (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  return gdbarch->register_type != 0;
+}
+
+struct type *
+gdbarch_register_type (struct gdbarch *gdbarch, int reg_nr)
+{
+  gdb_assert (gdbarch != NULL);
+  if (gdbarch->register_type == 0)
+    internal_error (__FILE__, __LINE__,
+                    "gdbarch: gdbarch_register_type invalid");
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_register_type called\n");
+  return gdbarch->register_type (gdbarch, reg_nr);
+}
+
+void
+set_gdbarch_register_type (struct gdbarch *gdbarch,
+                           gdbarch_register_type_ftype register_type)
+{
+  gdbarch->register_type = register_type;
+}
+
 int
 gdbarch_deprecated_do_registers_info_p (struct gdbarch *gdbarch)
 {
index 606511bc86323cb1175df7f2235b55236993e733..641db5f416562a7f059e018e518b6fb601139711 100644 (file)
@@ -721,6 +721,11 @@ extern void set_gdbarch_register_byte (struct gdbarch *gdbarch, gdbarch_register
 #endif
 #endif
 
+/* 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
+   by REGISTER_TYPE. */
+
 /* Default (function) for non- multi-arch platforms. */
 #if (!GDB_MULTI_ARCH) && !defined (REGISTER_RAW_SIZE)
 #define REGISTER_RAW_SIZE(reg_nr) (generic_register_size (reg_nr))
@@ -738,6 +743,11 @@ extern void set_gdbarch_register_raw_size (struct gdbarch *gdbarch, gdbarch_regi
 #endif
 #endif
 
+/* 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
+   by REGISTER_TYPE. */
+
 extern int gdbarch_max_register_raw_size (struct gdbarch *gdbarch);
 extern void set_gdbarch_max_register_raw_size (struct gdbarch *gdbarch, int max_register_raw_size);
 #if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (MAX_REGISTER_RAW_SIZE)
@@ -749,6 +759,11 @@ extern void set_gdbarch_max_register_raw_size (struct gdbarch *gdbarch, int max_
 #endif
 #endif
 
+/* 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
+   by REGISTER_TYPE. */
+
 /* Default (function) for non- multi-arch platforms. */
 #if (!GDB_MULTI_ARCH) && !defined (REGISTER_VIRTUAL_SIZE)
 #define REGISTER_VIRTUAL_SIZE(reg_nr) (generic_register_size (reg_nr))
@@ -766,6 +781,11 @@ extern void set_gdbarch_register_virtual_size (struct gdbarch *gdbarch, gdbarch_
 #endif
 #endif
 
+/* 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
+   by REGISTER_TYPE. */
+
 extern int gdbarch_max_register_virtual_size (struct gdbarch *gdbarch);
 extern void set_gdbarch_max_register_virtual_size (struct gdbarch *gdbarch, int max_register_virtual_size);
 #if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (MAX_REGISTER_VIRTUAL_SIZE)
@@ -777,6 +797,36 @@ extern void set_gdbarch_max_register_virtual_size (struct gdbarch *gdbarch, int
 #endif
 #endif
 
+/* The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
+   MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
+   REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE have all being replaced
+   by REGISTER_TYPE. */
+
+#if defined (REGISTER_VIRTUAL_TYPE)
+/* Legacy for systems yet to multi-arch REGISTER_VIRTUAL_TYPE */
+#if !defined (REGISTER_VIRTUAL_TYPE_P)
+#define REGISTER_VIRTUAL_TYPE_P() (1)
+#endif
+#endif
+
+/* Default predicate for non- multi-arch targets. */
+#if (!GDB_MULTI_ARCH) && !defined (REGISTER_VIRTUAL_TYPE_P)
+#define REGISTER_VIRTUAL_TYPE_P() (0)
+#endif
+
+extern int gdbarch_register_virtual_type_p (struct gdbarch *gdbarch);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (REGISTER_VIRTUAL_TYPE_P)
+#error "Non multi-arch definition of REGISTER_VIRTUAL_TYPE"
+#endif
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (REGISTER_VIRTUAL_TYPE_P)
+#define REGISTER_VIRTUAL_TYPE_P() (gdbarch_register_virtual_type_p (current_gdbarch))
+#endif
+
+/* Default (function) for non- multi-arch platforms. */
+#if (!GDB_MULTI_ARCH) && !defined (REGISTER_VIRTUAL_TYPE)
+#define REGISTER_VIRTUAL_TYPE(reg_nr) (internal_error (__FILE__, __LINE__, "REGISTER_VIRTUAL_TYPE"), 0)
+#endif
+
 typedef struct type * (gdbarch_register_virtual_type_ftype) (int reg_nr);
 extern struct type * gdbarch_register_virtual_type (struct gdbarch *gdbarch, int reg_nr);
 extern void set_gdbarch_register_virtual_type (struct gdbarch *gdbarch, gdbarch_register_virtual_type_ftype *register_virtual_type);
@@ -789,6 +839,12 @@ extern void set_gdbarch_register_virtual_type (struct gdbarch *gdbarch, gdbarch_
 #endif
 #endif
 
+extern int gdbarch_register_type_p (struct gdbarch *gdbarch);
+
+typedef struct type * (gdbarch_register_type_ftype) (struct gdbarch *gdbarch, int reg_nr);
+extern struct type * gdbarch_register_type (struct gdbarch *gdbarch, int reg_nr);
+extern void set_gdbarch_register_type (struct gdbarch *gdbarch, gdbarch_register_type_ftype *register_type);
+
 #if defined (DEPRECATED_DO_REGISTERS_INFO)
 /* Legacy for systems yet to multi-arch DEPRECATED_DO_REGISTERS_INFO */
 #if !defined (DEPRECATED_DO_REGISTERS_INFO_P)
index fe3ba39a967c02fb6982b9759e4b6c2267023f11..06db6d7135ecb4dfbbe805d6d603da5a88c65457 100755 (executable)
@@ -470,11 +470,32 @@ f:2:REGISTER_NAME:const char *:register_name:int regnr:regnr:::legacy_register_n
 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::generic_register_byte:generic_register_byte::0
+# 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
+# by REGISTER_TYPE.
 f:2:REGISTER_RAW_SIZE:int:register_raw_size:int reg_nr:reg_nr::generic_register_size:generic_register_size::0
+# 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
+# by REGISTER_TYPE.
 v:2:MAX_REGISTER_RAW_SIZE:int:max_register_raw_size::::0:-1
+# 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
+# by REGISTER_TYPE.
 f:2:REGISTER_VIRTUAL_SIZE:int:register_virtual_size:int reg_nr:reg_nr::generic_register_size:generic_register_size::0
+# 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
+# by REGISTER_TYPE.
 v:2:MAX_REGISTER_VIRTUAL_SIZE:int:max_register_virtual_size::::0:-1
-f:2:REGISTER_VIRTUAL_TYPE:struct type *:register_virtual_type:int reg_nr:reg_nr::0:0
+# The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
+# MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
+# REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE have all being replaced
+# by REGISTER_TYPE.
+F:2:REGISTER_VIRTUAL_TYPE:struct type *:register_virtual_type:int reg_nr:reg_nr::0:0
+M:2:REGISTER_TYPE:struct type *:register_type:int reg_nr:reg_nr::0:
 #
 F:2:DEPRECATED_DO_REGISTERS_INFO:void:deprecated_do_registers_info:int reg_nr, int fpregs:reg_nr, fpregs
 m:2:PRINT_REGISTERS_INFO:void:print_registers_info:struct ui_file *file, struct frame_info *frame, int regnum, int all:file, frame, regnum, all:::default_print_registers_info::0
index b84020e073b224482edcb1c18eaaa3a0bbbf7811..871af1f98514418ae8f9df01cafabf500a0503a6 100644 (file)
@@ -172,13 +172,20 @@ init_regcache_descr (struct gdbarch *gdbarch)
                                  struct type *);
   for (i = 0; i < descr->nr_cooked_registers; i++)
     {
-      descr->register_type[i] = REGISTER_VIRTUAL_TYPE (i);
+      if (gdbarch_register_type_p (gdbarch))
+       {
+         gdb_assert (!REGISTER_VIRTUAL_TYPE_P ()); /* OK */
+         descr->register_type[i] = gdbarch_register_type (gdbarch, i);
+       }
+      else
+       descr->register_type[i] = REGISTER_VIRTUAL_TYPE (i); /* OK */
     }
 
   /* If an old style architecture, fill in the remainder of the
      register cache descriptor using the register macros.  */
   if (!gdbarch_pseudo_register_read_p (gdbarch)
-      && !gdbarch_pseudo_register_write_p (gdbarch))
+      && !gdbarch_pseudo_register_write_p (gdbarch)
+      && !gdbarch_register_type_p (gdbarch))
     {
       descr->legacy_p = 1;
       init_legacy_regcache_descr (gdbarch, descr);