aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2003-03-01 17:59:12 +0000
committerAndrew Cagney <cagney@redhat.com>2003-03-01 17:59:12 +0000
commit35cac7cfea5ce05bfb0516b9ca11e3cf6561c1d4 (patch)
treefd02efded8c8c4461b78a7a556fc594e0bc60194
parent7b83296f2249f4252acecdc5af64595d66daadbd (diff)
downloadgdb-35cac7cfea5ce05bfb0516b9ca11e3cf6561c1d4.zip
gdb-35cac7cfea5ce05bfb0516b9ca11e3cf6561c1d4.tar.gz
gdb-35cac7cfea5ce05bfb0516b9ca11e3cf6561c1d4.tar.bz2
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.
-rw-r--r--gdb/ChangeLog17
-rw-r--r--gdb/arch-utils.c10
-rw-r--r--gdb/d10v-tdep.c4
-rw-r--r--gdb/gdbarch.c57
-rw-r--r--gdb/gdbarch.h56
-rwxr-xr-xgdb/gdbarch.sh23
-rw-r--r--gdb/regcache.c11
7 files changed, 168 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6048ffb..30945a9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,22 @@
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.
* ax-gdb.c: Include "regcache.h".
(gen_expr): Use register_type instead of REGISTER_VIRTUAL_TYPE.
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 1202df9..d1d49fd 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -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;
}
diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c
index da491b7..3c1852a 100644
--- a/gdb/d10v-tdep.c
+++ b/gdb/d10v-tdep.c
@@ -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);
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index c8e296c..bf16854 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -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)
{
@@ -3364,6 +3389,32 @@ set_gdbarch_register_virtual_type (struct gdbarch *gdbarch,
}
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)
{
gdb_assert (gdbarch != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 606511b..641db5f 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -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)
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index fe3ba39..06db6d7 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -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
diff --git a/gdb/regcache.c b/gdb/regcache.c
index b84020e..871af1f 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -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);