From a7e3c2ad4b6733e3011e00d214ec83139fa3c3d2 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Sat, 10 Aug 2002 02:00:16 +0000 Subject: [PATCH] 2002-08-09 Andrew Cagney * 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 | 9 +++++++++ gdb/arch-utils.c | 17 +++++++++++++++++ gdb/arch-utils.h | 3 +++ gdb/gdbarch.c | 7 +++---- gdb/gdbarch.h | 5 +++++ gdb/gdbarch.sh | 2 +- gdb/regcache.c | 3 ++- 7 files changed, 40 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2546b4365be..53f5c66ec44 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2002-08-09 Andrew Cagney + + * 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 * regcache.c: Include "gdbcmd.h" diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index a407f9e28be..5497e83308b 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -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; +} + int legacy_pc_in_sigtramp (CORE_ADDR pc, char *name) diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index 7ceb8b70b84..a38272c9099 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -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); diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 93a5c0e5aff..e2e5b7b6b33 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -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)) diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 57fb0cf71f5..973f250b626 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -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); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 141eba31b91..f416aea1743 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -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 diff --git a/gdb/regcache.c b/gdb/regcache.c index dcfe7aa8f4e..c633d2dd944 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -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; -- 2.30.2