From: Andrew Cagney Date: Sun, 12 May 2002 02:16:05 +0000 (+0000) Subject: * arch-utils.h (generic_register_size): Declare. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b2e75d78994bf7899fdb51387a9d95950f09ad9a;p=binutils-gdb.git * arch-utils.h (generic_register_size): Declare. (generic_register_raw_size, generic_register_virtual_size): Delete declarations. * arch-utils.c (generic_register_raw_size): Delete. (generic_register_size): New function. (generic_register_virtual_size): Delete. * gdbarch.sh (REGISTER_RAW_SIZE, REGISTER_VIRTUAL_SIZE): Make default generic_register_size. * gdbarch.h, gdbarch.c: Re-generate. * d10v-tdep.c (d10v_gdbarch_init): Use generic_register_size for register_virtual_size. * x86-64-tdep.c (x86_64_gdbarch_init): Ditto. * rs6000-tdep.c (rs6000_gdbarch_init): Ditto. * gdbint.texinfo (Target Architecture Definition): Mention defaults for REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE. (Target Architecture Definition): Mention same. Add references to web pages. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 364d1430664..459d1dcd0bc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,21 @@ +2002-05-11 Andrew Cagney + + * arch-utils.h (generic_register_size): Declare. + (generic_register_raw_size, generic_register_virtual_size): Delete + declarations. + * arch-utils.c (generic_register_raw_size): Delete. + (generic_register_size): New function. + (generic_register_virtual_size): Delete. + + * gdbarch.sh (REGISTER_RAW_SIZE, REGISTER_VIRTUAL_SIZE): Make + default generic_register_size. + * gdbarch.h, gdbarch.c: Re-generate. + + * d10v-tdep.c (d10v_gdbarch_init): Use generic_register_size for + register_virtual_size. + * x86-64-tdep.c (x86_64_gdbarch_init): Ditto. + * rs6000-tdep.c (rs6000_gdbarch_init): Ditto. + 2002-05-11 Andrew Cagney * gdbarch.sh (gdbarch_data): Add gdbarch parameter. diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 154438acf26..1fb8e36fef4 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -401,21 +401,13 @@ legacy_virtual_frame_pointer (CORE_ADDR pc, *frame_offset = 0; } -/* Assume the world is flat. Every register is large enough to fit a - target integer. */ +/* Assume the world is sane, every register's virtual and real size + is identical. */ int -generic_register_raw_size (int regnum) +generic_register_size (int regnum) { gdb_assert (regnum >= 0 && regnum < NUM_REGS + NUM_PSEUDO_REGS); - return TARGET_INT_BIT / HOST_CHAR_BIT; -} - -/* Assume the virtual size corresponds to the virtual type. */ - -int -generic_register_virtual_size (int regnum) -{ return TYPE_LENGTH (REGISTER_VIRTUAL_TYPE (regnum)); } diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index 72200626a61..bcd17aaf713 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -149,13 +149,10 @@ extern int generic_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc extern void default_print_float_info (void); -/* Assume all registers are the same size and a size identical to that - of the integer type. */ -extern int generic_register_raw_size (int regnum); +/* Assume that the world is sane, a registers raw and virtual size + both match its type. */ -/* Assume the virtual size of registers corresponds to the virtual type. */ - -extern int generic_register_virtual_size (int regnum); +extern int generic_register_size (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/d10v-tdep.c b/gdb/d10v-tdep.c index 2060c93186f..d5f5b05106f 100644 --- a/gdb/d10v-tdep.c +++ b/gdb/d10v-tdep.c @@ -1486,7 +1486,7 @@ d10v_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_register_byte (gdbarch, d10v_register_byte); set_gdbarch_register_raw_size (gdbarch, d10v_register_raw_size); set_gdbarch_max_register_raw_size (gdbarch, 8); - set_gdbarch_register_virtual_size (gdbarch, generic_register_virtual_size); + 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); diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 8c9a9f627b1..3ddf6f683fd 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,10 @@ +2002-05-11 Andrew Cagney + + * gdbint.texinfo (Target Architecture Definition): Mention + defaults for REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE. + (Target Architecture Definition): Mention same. Add references to + web pages. + 2002-05-08 Michael Snyder * stabs.texinfo (Attributes): Document new "vector" attribute. diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo index 3387cdbfbfc..a52c19c225d 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -2496,8 +2496,13 @@ C@t{++} reference type. @emph{Maintainer's note: The way GDB manipulates registers is undergoing significant change. Many of the macros and functions refered to in the -sections below are likely to be made obsolete. See the file @file{TODO} -for more up-to-date information.} +section below are likely to be made obsolete. For instance, instead of +having different raw and virtual register sizes, an architecture can +define pseudo-registers that map onto the raw registers. + +See the @uref{http://www.gnu.org/software/gdb/bugs/, Bug Tracking +Database} and @uref{http://sources.redhat.com/gdb/current/ari, ARI +Index} for more up-to-date information.} Some architectures use one representation for a value when it lives in a register, but use a different representation when it lives in memory. @@ -3175,12 +3180,14 @@ Return non-zero if @var{reg} uses different raw and virtual formats. @item REGISTER_RAW_SIZE (@var{reg}) @findex REGISTER_RAW_SIZE -Return the raw size of @var{reg}. +Return the raw size of @var{reg}; defaults to the size of the register's +virtual type. @xref{Target Architecture Definition, , Using Different Register and Memory Data Representations}. @item REGISTER_VIRTUAL_SIZE (@var{reg}) @findex REGISTER_VIRTUAL_SIZE -Return the virtual size of @var{reg}. +Return the virtual size of @var{reg}; defaults to the size of the +register's virtual type. @xref{Target Architecture Definition, , Using Different Register and Memory Data Representations}. @item REGISTER_VIRTUAL_TYPE (@var{reg}) diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index b8d680e2ce2..38c8843e42b 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -312,9 +312,9 @@ struct gdbarch startup_gdbarch = 0, 0, 0, - generic_register_raw_size, + generic_register_size, 0, - generic_register_virtual_size, + generic_register_size, 0, 0, 0, @@ -479,7 +479,9 @@ 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_raw_size = generic_register_size; current_gdbarch->max_register_raw_size = -1; + current_gdbarch->register_virtual_size = generic_register_size; current_gdbarch->max_register_virtual_size = -1; current_gdbarch->do_registers_info = do_registers_info; current_gdbarch->print_float_info = default_print_float_info; @@ -615,15 +617,11 @@ verify_gdbarch (struct gdbarch *gdbarch) if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && (gdbarch->register_byte == 0)) fprintf_unfiltered (log, "\n\tregister_byte"); - if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) - && (gdbarch->register_raw_size == 0)) - fprintf_unfiltered (log, "\n\tregister_raw_size"); + /* Skip verify of register_raw_size, invalid_p == 0 */ if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && (gdbarch->max_register_raw_size == -1)) fprintf_unfiltered (log, "\n\tmax_register_raw_size"); - if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) - && (gdbarch->register_virtual_size == 0)) - fprintf_unfiltered (log, "\n\tregister_virtual_size"); + /* Skip verify of register_virtual_size, invalid_p == 0 */ if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && (gdbarch->max_register_virtual_size == -1)) fprintf_unfiltered (log, "\n\tmax_register_virtual_size"); diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 77f094533f6..84b8c7d8211 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -720,6 +720,11 @@ extern void set_gdbarch_register_byte (struct gdbarch *gdbarch, gdbarch_register #endif #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)) +#endif + typedef int (gdbarch_register_raw_size_ftype) (int reg_nr); extern int gdbarch_register_raw_size (struct gdbarch *gdbarch, int reg_nr); extern void set_gdbarch_register_raw_size (struct gdbarch *gdbarch, gdbarch_register_raw_size_ftype *register_raw_size); @@ -743,6 +748,11 @@ extern void set_gdbarch_max_register_raw_size (struct gdbarch *gdbarch, int max_ #endif #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)) +#endif + typedef int (gdbarch_register_virtual_size_ftype) (int reg_nr); extern int gdbarch_register_virtual_size (struct gdbarch *gdbarch, int reg_nr); extern void set_gdbarch_register_virtual_size (struct gdbarch *gdbarch, gdbarch_register_virtual_size_ftype *register_virtual_size); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 366bda154b0..4aed81b6b7b 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -463,9 +463,9 @@ f:2:REGISTER_NAME: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_RAW_SIZE:int:register_raw_size:int reg_nr:reg_nr::generic_register_raw_size: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_virtual_size:0 +f:2:REGISTER_VIRTUAL_SIZE:int:register_virtual_size:int reg_nr:reg_nr::generic_register_size:generic_register_size::0 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 f:2:DO_REGISTERS_INFO:void:do_registers_info:int reg_nr, int fpregs:reg_nr, fpregs:::do_registers_info::0 diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 74285a3a4e0..ee7e9c3aceb 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -2663,7 +2663,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_register_byte (gdbarch, rs6000_register_byte); set_gdbarch_register_raw_size (gdbarch, rs6000_register_raw_size); set_gdbarch_max_register_raw_size (gdbarch, 16); - set_gdbarch_register_virtual_size (gdbarch, generic_register_virtual_size); + set_gdbarch_register_virtual_size (gdbarch, generic_register_size); set_gdbarch_max_register_virtual_size (gdbarch, 16); set_gdbarch_register_virtual_type (gdbarch, rs6000_register_virtual_type); set_gdbarch_do_registers_info (gdbarch, rs6000_do_registers_info); diff --git a/gdb/x86-64-tdep.c b/gdb/x86-64-tdep.c index 9cd9813752e..70a5d9cbb0f 100644 --- a/gdb/x86-64-tdep.c +++ b/gdb/x86-64-tdep.c @@ -1002,7 +1002,7 @@ x86_64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) for (i = 0, sum = 0; i < X86_64_NUM_REGS; i++) sum += x86_64_register_info_table[i].size; set_gdbarch_register_bytes (gdbarch, sum); - set_gdbarch_register_virtual_size (gdbarch, generic_register_virtual_size); + set_gdbarch_register_virtual_size (gdbarch, generic_register_size); set_gdbarch_max_register_virtual_size (gdbarch, 16); set_gdbarch_register_virtual_type (gdbarch, x86_64_register_virtual_type);