From dadd712e2163158cb9ae3a56099a4d36d78bcbc6 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Thu, 3 Jul 2003 14:34:29 +0000 Subject: [PATCH] 2003-07-03 Andrew Cagney * gdbarch.sh (REGISTER_RAW_SIZE, REGISTER_VIRTUAL_SIZE): Add predicate. * gdbarch.h, gdbarch.c: Re-generate. * regcache.c (init_regcache_descr): Use legacy code when either REGISTER_BYTE or REGISTER_RAW_SIZE is set. --- gdb/ChangeLog | 8 ++++++++ gdb/gdbarch.c | 38 ++++++++++++++++++++++++++++++++++++-- gdb/gdbarch.h | 40 ++++++++++++++++++++++++++++++++++++++++ gdb/gdbarch.sh | 4 ++-- gdb/regcache.c | 19 ++++++++++--------- 5 files changed, 96 insertions(+), 13 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7a394368301..a4b9537fe61 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2003-07-03 Andrew Cagney + + * gdbarch.sh (REGISTER_RAW_SIZE, REGISTER_VIRTUAL_SIZE): Add + predicate. + * gdbarch.h, gdbarch.c: Re-generate. + * regcache.c (init_regcache_descr): Use legacy code when either + REGISTER_BYTE or REGISTER_RAW_SIZE is set. + 2003-07-02 Daniel Jacobowitz * NEWS: Move "set logging" entry into GDB 6.0 section. diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 87585dd42c6..966e373939c 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -641,8 +641,8 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of register_type, has predicate */ /* Skip verify of deprecated_register_virtual_type, has predicate */ /* Skip verify of deprecated_register_byte, has predicate */ - /* Skip verify of deprecated_register_raw_size, invalid_p == 0 */ - /* Skip verify of deprecated_register_virtual_size, invalid_p == 0 */ + /* Skip verify of deprecated_register_raw_size, has predicate */ + /* Skip verify of deprecated_register_virtual_size, has predicate */ /* Skip verify of deprecated_max_register_raw_size, has predicate */ /* Skip verify of deprecated_max_register_virtual_size, has predicate */ /* Skip verify of unwind_dummy_id, has predicate */ @@ -2147,6 +2147,15 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) (long) current_gdbarch->register_name /*REGISTER_NAME ()*/); #endif +#ifdef REGISTER_RAW_SIZE_P + fprintf_unfiltered (file, + "gdbarch_dump: %s # %s\n", + "REGISTER_RAW_SIZE_P()", + XSTRING (REGISTER_RAW_SIZE_P ())); + fprintf_unfiltered (file, + "gdbarch_dump: REGISTER_RAW_SIZE_P() = %d\n", + REGISTER_RAW_SIZE_P ()); +#endif #ifdef REGISTER_RAW_SIZE fprintf_unfiltered (file, "gdbarch_dump: %s # %s\n", @@ -2191,6 +2200,15 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: register_type = 0x%08lx\n", (long) current_gdbarch->register_type); +#ifdef REGISTER_VIRTUAL_SIZE_P + fprintf_unfiltered (file, + "gdbarch_dump: %s # %s\n", + "REGISTER_VIRTUAL_SIZE_P()", + XSTRING (REGISTER_VIRTUAL_SIZE_P ())); + fprintf_unfiltered (file, + "gdbarch_dump: REGISTER_VIRTUAL_SIZE_P() = %d\n", + REGISTER_VIRTUAL_SIZE_P ()); +#endif #ifdef REGISTER_VIRTUAL_SIZE fprintf_unfiltered (file, "gdbarch_dump: %s # %s\n", @@ -3385,6 +3403,13 @@ set_gdbarch_deprecated_register_byte (struct gdbarch *gdbarch, gdbarch->deprecated_register_byte = deprecated_register_byte; } +int +gdbarch_deprecated_register_raw_size_p (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + return gdbarch->deprecated_register_raw_size != generic_register_size; +} + int gdbarch_deprecated_register_raw_size (struct gdbarch *gdbarch, int reg_nr) { @@ -3392,6 +3417,7 @@ gdbarch_deprecated_register_raw_size (struct gdbarch *gdbarch, int reg_nr) if (gdbarch->deprecated_register_raw_size == 0) internal_error (__FILE__, __LINE__, "gdbarch: gdbarch_deprecated_register_raw_size invalid"); + /* Ignore predicate (gdbarch->deprecated_register_raw_size != generic_register_size). */ if (gdbarch_debug >= 2) fprintf_unfiltered (gdb_stdlog, "gdbarch_deprecated_register_raw_size called\n"); return gdbarch->deprecated_register_raw_size (reg_nr); @@ -3404,6 +3430,13 @@ set_gdbarch_deprecated_register_raw_size (struct gdbarch *gdbarch, gdbarch->deprecated_register_raw_size = deprecated_register_raw_size; } +int +gdbarch_deprecated_register_virtual_size_p (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + return gdbarch->deprecated_register_virtual_size != generic_register_size; +} + int gdbarch_deprecated_register_virtual_size (struct gdbarch *gdbarch, int reg_nr) { @@ -3411,6 +3444,7 @@ gdbarch_deprecated_register_virtual_size (struct gdbarch *gdbarch, int reg_nr) if (gdbarch->deprecated_register_virtual_size == 0) internal_error (__FILE__, __LINE__, "gdbarch: gdbarch_deprecated_register_virtual_size invalid"); + /* Ignore predicate (gdbarch->deprecated_register_virtual_size != generic_register_size). */ if (gdbarch_debug >= 2) fprintf_unfiltered (gdb_stdlog, "gdbarch_deprecated_register_virtual_size called\n"); return gdbarch->deprecated_register_virtual_size (reg_nr); diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 4dd7cfa9d7f..0242d5b8ad4 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -709,6 +709,26 @@ extern void set_gdbarch_deprecated_register_byte (struct gdbarch *gdbarch, gdbar DEPRECATED_REGISTER_RAW_SIZE can be deleted. See: maint print registers. */ +#if defined (REGISTER_RAW_SIZE) +/* Legacy for systems yet to multi-arch REGISTER_RAW_SIZE */ +#if !defined (REGISTER_RAW_SIZE_P) +#define REGISTER_RAW_SIZE_P() (1) +#endif +#endif + +/* Default predicate for non- multi-arch targets. */ +#if (!GDB_MULTI_ARCH) && !defined (REGISTER_RAW_SIZE_P) +#define REGISTER_RAW_SIZE_P() (0) +#endif + +extern int gdbarch_deprecated_register_raw_size_p (struct gdbarch *gdbarch); +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (REGISTER_RAW_SIZE_P) +#error "Non multi-arch definition of REGISTER_RAW_SIZE" +#endif +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (REGISTER_RAW_SIZE_P) +#define REGISTER_RAW_SIZE_P() (gdbarch_deprecated_register_raw_size_p (current_gdbarch)) +#endif + /* 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)) @@ -729,6 +749,26 @@ extern void set_gdbarch_deprecated_register_raw_size (struct gdbarch *gdbarch, g DEPRECATED_REGISTER_VIRTUAL_SIZE can be deleted. See: maint print registers. */ +#if defined (REGISTER_VIRTUAL_SIZE) +/* Legacy for systems yet to multi-arch REGISTER_VIRTUAL_SIZE */ +#if !defined (REGISTER_VIRTUAL_SIZE_P) +#define REGISTER_VIRTUAL_SIZE_P() (1) +#endif +#endif + +/* Default predicate for non- multi-arch targets. */ +#if (!GDB_MULTI_ARCH) && !defined (REGISTER_VIRTUAL_SIZE_P) +#define REGISTER_VIRTUAL_SIZE_P() (0) +#endif + +extern int gdbarch_deprecated_register_virtual_size_p (struct gdbarch *gdbarch); +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (REGISTER_VIRTUAL_SIZE_P) +#error "Non multi-arch definition of REGISTER_VIRTUAL_SIZE" +#endif +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (REGISTER_VIRTUAL_SIZE_P) +#define REGISTER_VIRTUAL_SIZE_P() (gdbarch_deprecated_register_virtual_size_p (current_gdbarch)) +#endif + /* 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)) diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 494b916ffe4..982b8a56249 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -486,12 +486,12 @@ F::REGISTER_BYTE:int:deprecated_register_byte:int reg_nr:reg_nr::generic_registe # sizes agree with the value computed from REGISTER_TYPE, # DEPRECATED_REGISTER_RAW_SIZE can be deleted. See: maint print # registers. -f:2:REGISTER_RAW_SIZE:int:deprecated_register_raw_size:int reg_nr:reg_nr::generic_register_size:generic_register_size::0 +F:2:REGISTER_RAW_SIZE:int:deprecated_register_raw_size:int reg_nr:reg_nr::generic_register_size:generic_register_size # If all registers have identical raw and virtual sizes and those # sizes agree with the value computed from REGISTER_TYPE, # DEPRECATED_REGISTER_VIRTUAL_SIZE can be deleted. See: maint print # registers. -f:2:REGISTER_VIRTUAL_SIZE:int:deprecated_register_virtual_size:int reg_nr:reg_nr::generic_register_size:generic_register_size::0 +F:2:REGISTER_VIRTUAL_SIZE:int:deprecated_register_virtual_size:int reg_nr:reg_nr::generic_register_size:generic_register_size # DEPRECATED_MAX_REGISTER_RAW_SIZE can be deleted. It has been # replaced by the constant MAX_REGISTER_SIZE. V:2:DEPRECATED_MAX_REGISTER_RAW_SIZE:int:deprecated_max_register_raw_size diff --git a/gdb/regcache.c b/gdb/regcache.c index 509390f9172..ce1d8118b4c 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -178,16 +178,17 @@ init_regcache_descr (struct gdbarch *gdbarch) /* 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_register_type_p (gdbarch)) + /* NOTE: cagney/2003-06-29: If either of REGISTER_BYTE or + REGISTER_RAW_SIZE are still present, things are most likely + totally screwed. Ex: an architecture with raw register sizes + smaller than what REGISTER_BYTE indicates; non monotonic + REGISTER_BYTE values. For GDB 6 check for these nasty methods + and fall back to legacy code when present. Sigh! */ + if ((!gdbarch_pseudo_register_read_p (gdbarch) + && !gdbarch_pseudo_register_write_p (gdbarch) + && !gdbarch_register_type_p (gdbarch)) + || REGISTER_BYTE_P () || REGISTER_RAW_SIZE_P ()) { - /* 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; -- 2.30.2