From ad09cb2bd3ea991f862103ee802a7a93e7895909 Mon Sep 17 00:00:00 2001 From: Peter Schauer Date: Tue, 2 Nov 1993 21:51:10 +0000 Subject: [PATCH] * findvar.c (value_of_register, value_from_register), hppa-tdep.c (pa_print_fp_reg), infcmd.c (do_registers_info), valops.c (value_assign): Use REGISTER_CONVERT_TO_* only if REGISTER_CONVERTIBLE is defined, otherwise just copy the content. Pass desired type to REGISTER_CONVERT_TO_*. * config/m68k/tm-m68k.h, config/i960/tm-i960.h (REGISTER_CONVERT_*): Pass length of desired type to store/extract_floating. * config/i386/tm-arm.h, config/i386/tm-i386aix.h, config/i386/tm-sun386.h, config/i386/tm-symmetry.h, config/m88k/tm-m88k.h config/rs6000/tm-rs6000.h (REGISTER_CONVERT_*): Use extract_floating and store_floating with length of desired type. * config/m68k/tm-news.h (STORE,EXTRACT_RETURN_VALUE): Add type parameter to REGISTER_CONVERT_*. * config/a29k/tm-a29k.h, config/convex/tm-convex.h, config/gould/tm-np1.h, config/gould/tm-pn.h, config/h8300/tm-h8300.h, config/h8500/tm-h8500.h, config/i386/tm-i386v.h, config/mips/tm-mips.h, config/ns32k/tm-merlin.h, config/ns32k/tm-umax.h, config/pa/tm-hppa.h, config/pyr/tm-pyr.h, config/sh/tm-sh.h, config/sparc/tm-sparc.h, config/tahoe/tm-tahoe.h, config/vax/tm-vax.h, config/z8k/tm-z8k.h (REGISTER_CONVERTIBLE, REGISTER_CONVERT_TO_RAW, REGISTER_CONVERT_TO_VIRTUAL): Remove versions for which REGISTER_CONVERTIBLE is always false. * z8k-tdep.c (register_convert_to_virtual, register_convert_to_raw): Remove, no longer used. * alpha-tdep.c (alpha_register_convert_to_raw, alpha_register_convert_to_virtual): New routines to handle the different raw formats in alpha floating point registers. * config/alpha/tm-alpha.h (REGISTER_CONVERTIBLE, REGISTER_CONVERT_TO_VIRTUAL, REGISTER_CONVERT_TO_RAW): Use them. --- gdb/ChangeLog | 35 +++++++++ gdb/alpha-tdep.c | 67 +++++++++++++++++ gdb/config/a29k/tm-a29k.h | 17 ----- gdb/config/h8300/tm-h8300.h | 17 ----- gdb/config/h8500/tm-h8500.h | 17 ----- gdb/config/i386/tm-i386aix.h | 31 +++++--- gdb/config/i386/tm-i386v.h | 17 ----- gdb/config/i386/tm-sun386.h | 31 ++++---- gdb/config/i386/tm-symmetry.h | 33 ++++----- gdb/config/i960/tm-i960.h | 30 +++----- gdb/config/m68k/tm-m68k.h | 30 +++----- gdb/config/m68k/tm-news.h | 7 +- gdb/config/m88k/tm-m88k.h | 29 +++----- gdb/config/mips/tm-mips.h | 17 ----- gdb/config/ns32k/tm-merlin.h | 17 ----- gdb/config/ns32k/tm-umax.h | 17 ----- gdb/config/sh/tm-sh.h | 17 ----- gdb/config/sparc/tm-sparc.h | 17 ----- gdb/config/vax/tm-vax.h | 17 ----- gdb/config/z8k/tm-z8k.h | 17 ----- gdb/findvar.c | 136 ++++++++++++++++++++++++++-------- gdb/hppa-tdep.c | 15 +++- gdb/valops.c | 38 ++++++---- gdb/z8k-tdep.c | 22 ------ 24 files changed, 331 insertions(+), 360 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index bd6ac807a8e..5c9b6de9dcb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,38 @@ +Tue Nov 2 13:42:30 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * findvar.c (value_of_register, value_from_register), + hppa-tdep.c (pa_print_fp_reg), infcmd.c (do_registers_info), + valops.c (value_assign): Use REGISTER_CONVERT_TO_* only if + REGISTER_CONVERTIBLE is defined, otherwise just copy the content. + Pass desired type to REGISTER_CONVERT_TO_*. + + * config/m68k/tm-m68k.h, config/i960/tm-i960.h (REGISTER_CONVERT_*): + Pass length of desired type to store/extract_floating. + * config/i386/tm-arm.h, config/i386/tm-i386aix.h, + config/i386/tm-sun386.h, config/i386/tm-symmetry.h, + config/m88k/tm-m88k.h config/rs6000/tm-rs6000.h (REGISTER_CONVERT_*): + Use extract_floating and store_floating with length of desired type. + * config/m68k/tm-news.h (STORE,EXTRACT_RETURN_VALUE): Add type + parameter to REGISTER_CONVERT_*. + + * config/a29k/tm-a29k.h, config/convex/tm-convex.h, + config/gould/tm-np1.h, config/gould/tm-pn.h, config/h8300/tm-h8300.h, + config/h8500/tm-h8500.h, config/i386/tm-i386v.h, + config/mips/tm-mips.h, config/ns32k/tm-merlin.h, + config/ns32k/tm-umax.h, config/pa/tm-hppa.h, config/pyr/tm-pyr.h, + config/sh/tm-sh.h, config/sparc/tm-sparc.h, config/tahoe/tm-tahoe.h, + config/vax/tm-vax.h, config/z8k/tm-z8k.h (REGISTER_CONVERTIBLE, + REGISTER_CONVERT_TO_RAW, REGISTER_CONVERT_TO_VIRTUAL): Remove + versions for which REGISTER_CONVERTIBLE is always false. + * z8k-tdep.c (register_convert_to_virtual, register_convert_to_raw): + Remove, no longer used. + + * alpha-tdep.c (alpha_register_convert_to_raw, + alpha_register_convert_to_virtual): New routines to handle + the different raw formats in alpha floating point registers. + * config/alpha/tm-alpha.h (REGISTER_CONVERTIBLE, + REGISTER_CONVERT_TO_VIRTUAL, REGISTER_CONVERT_TO_RAW): Use them. + Mon Nov 1 09:40:21 1993 Jim Kingdon (kingdon@lioth.cygnus.com) * symtab.c, symtab.h, source.c: Change find_line_pc_range to take diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 51f167bf406..a1b53e6e378 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -882,6 +882,73 @@ alpha_in_lenient_prologue (startaddr, pc) return pc >= startaddr && pc < end_prologue; } +/* The alpha needs a conversion between register and memory format if + the register is a floating point register and + memory format is float, as the register format must be double + or + memory format is an integer with 4 bytes or less, as the representation + of integers in floating point registers is different. */ +void +alpha_register_convert_to_virtual (regnum, valtype, raw_buffer, virtual_buffer) + int regnum; + struct type *valtype; + char *raw_buffer; + char *virtual_buffer; +{ + if (TYPE_LENGTH (valtype) >= REGISTER_RAW_SIZE (regnum)) + { + memcpy (virtual_buffer, raw_buffer, REGISTER_VIRTUAL_SIZE (regnum)); + return; + } + + if (TYPE_CODE (valtype) == TYPE_CODE_FLT) + { + double d = extract_floating (raw_buffer, REGISTER_RAW_SIZE (regnum)); + store_floating (virtual_buffer, TYPE_LENGTH (valtype), d); + } + else if (TYPE_CODE (valtype) == TYPE_CODE_INT && TYPE_LENGTH (valtype) <= 4) + { + unsigned LONGEST l; + l = extract_unsigned_integer (raw_buffer, REGISTER_RAW_SIZE (regnum)); + l = ((l >> 32) & 0xc0000000) | ((l >> 29) & 0x3fffffff); + store_unsigned_integer (virtual_buffer, TYPE_LENGTH (valtype), l); + } + else + error ("Cannot retrieve value from floating point register"); +} + +void +alpha_register_convert_to_raw (valtype, regnum, virtual_buffer, raw_buffer) + struct type *valtype; + int regnum; + char *virtual_buffer; + char *raw_buffer; +{ + if (TYPE_LENGTH (valtype) >= REGISTER_RAW_SIZE (regnum)) + { + memcpy (raw_buffer, virtual_buffer, REGISTER_RAW_SIZE (regnum)); + return; + } + + if (TYPE_CODE (valtype) == TYPE_CODE_FLT) + { + double d = extract_floating (virtual_buffer, TYPE_LENGTH (valtype)); + store_floating (raw_buffer, REGISTER_RAW_SIZE (regnum), d); + } + else if (TYPE_CODE (valtype) == TYPE_CODE_INT && TYPE_LENGTH (valtype) <= 4) + { + unsigned LONGEST l; + if (TYPE_UNSIGNED (valtype)) + l = extract_unsigned_integer (virtual_buffer, TYPE_LENGTH (valtype)); + else + l = extract_signed_integer (virtual_buffer, TYPE_LENGTH (valtype)); + l = ((l & 0xc0000000) << 32) | ((l & 0x3fffffff) << 29); + store_unsigned_integer (raw_buffer, REGISTER_RAW_SIZE (regnum), l); + } + else + error ("Cannot store value in floating point register"); +} + /* Given a return value in `regbuf' with a type `valtype', extract and copy its value into `valbuf'. */ void diff --git a/gdb/config/a29k/tm-a29k.h b/gdb/config/a29k/tm-a29k.h index ac102da06ce..7d240444cfe 100644 --- a/gdb/config/a29k/tm-a29k.h +++ b/gdb/config/a29k/tm-a29k.h @@ -270,23 +270,6 @@ CORE_ADDR skip_prologue (); #define MAX_REGISTER_VIRTUAL_SIZE (4) -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ memcpy ((TO), (FROM), 4); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ memcpy ((TO), (FROM), 4); } - /* Return the GDB type object for the "standard" data type of data in register N. */ diff --git a/gdb/config/h8300/tm-h8300.h b/gdb/config/h8300/tm-h8300.h index 16d5415ebe6..6bb576d3682 100644 --- a/gdb/config/h8300/tm-h8300.h +++ b/gdb/config/h8300/tm-h8300.h @@ -125,23 +125,6 @@ extern CORE_ADDR h8300_skip_prologue (); #define MAX_REGISTER_VIRTUAL_SIZE 4 -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ memcpy((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ memcpy((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); } - /* Return the GDB type object for the "standard" data type of data in register N. */ diff --git a/gdb/config/h8500/tm-h8500.h b/gdb/config/h8500/tm-h8500.h index c908bf8c37f..9d56af596b9 100644 --- a/gdb/config/h8500/tm-h8500.h +++ b/gdb/config/h8500/tm-h8500.h @@ -106,23 +106,6 @@ int h8500_register_size PARAMS ((int regno)); #define MAX_REGISTER_VIRTUAL_SIZE 4 -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ memcpy ((TO), (FROM), 4); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ memcpy ((TO), (FROM), 4); } - /* Return the GDB type object for the "standard" data type of data in register N. */ diff --git a/gdb/config/i386/tm-i386aix.h b/gdb/config/i386/tm-i386aix.h index 646b434c73a..4e6b2df48fb 100644 --- a/gdb/config/i386/tm-i386aix.h +++ b/gdb/config/i386/tm-i386aix.h @@ -112,19 +112,30 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define REGISTER_CONVERTIBLE(N) \ ((N < FP0_REGNUM) ? 0 : 1) -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ +/* Convert data from raw format for register REGNUM in buffer FROM + to virtual format with type TYPE in buffer TO. */ + #undef REGISTER_CONVERT_TO_VIRTUAL -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - ((REGNUM < FP0_REGNUM) ? memcpy ((TO), (FROM), 4) : \ - i387_to_double((FROM), (TO))) +#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \ +{ \ + double val; \ + i387_to_double ((FROM), (char *)&val); \ + store_floating ((TO), TYPE_LENGTH (TYPE), val); \ +} +extern void +i387_to_double PARAMS ((char *, char *)); + +/* Convert data from virtual format with type TYPE in buffer FROM + to raw format for register REGNUM in buffer TO. */ -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ #undef REGISTER_CONVERT_TO_RAW -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - ((REGNUM < FP0_REGNUM) ? memcpy ((TO), (FROM), 4) : \ - double_to_i387((FROM), (TO))) +#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \ +{ \ + double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \ + double_to_i387((char *)&val, (TO))) +} +extern void +double_to_i387 PARAMS ((char *, char *)); /* Return the GDB type object for the "standard" data type of data in register N. */ diff --git a/gdb/config/i386/tm-i386v.h b/gdb/config/i386/tm-i386v.h index f80f5192148..89c1c616665 100644 --- a/gdb/config/i386/tm-i386v.h +++ b/gdb/config/i386/tm-i386v.h @@ -145,23 +145,6 @@ i386_skip_prologue PARAMS ((int)); #define MAX_REGISTER_VIRTUAL_SIZE 4 -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - {memcpy ((TO), (FROM), 4);} - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - {memcpy ((TO), (FROM), 4);} - /* Return the GDB type object for the "standard" data type of data in register N. */ /* Perhaps si and di should go here, but potentially they could be diff --git a/gdb/config/i386/tm-sun386.h b/gdb/config/i386/tm-sun386.h index b2d0b7661a2..9c1f6a88626 100644 --- a/gdb/config/i386/tm-sun386.h +++ b/gdb/config/i386/tm-sun386.h @@ -167,27 +167,26 @@ i386_skip_prologue PARAMS ((int)); #define REGISTER_CONVERTIBLE(N) (((unsigned)((N) - FP0_REGNUM)) < 8) -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - i387_to_double ((FROM), (TO)); \ - else \ - memcpy ((TO), (FROM), 4); } +/* Convert data from raw format for register REGNUM in buffer FROM + to virtual format with type TYPE in buffer TO. */ +#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \ +{ \ + double val; \ + i387_to_double ((FROM), (char *)&val); \ + store_floating ((TO), TYPE_LENGTH (TYPE), val); \ +} extern void i387_to_double PARAMS ((char *, char *)); -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - double_to_i387 ((FROM), (TO)); \ - else \ - memcpy ((TO), (FROM), 4); } +/* Convert data from virtual format with type TYPE in buffer FROM + to raw format for register REGNUM in buffer TO. */ +#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \ +{ \ + double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \ + double_to_i387((char *)&val, (TO))) +} extern void double_to_i387 PARAMS ((char *, char *)); diff --git a/gdb/config/i386/tm-symmetry.h b/gdb/config/i386/tm-symmetry.h index 24d14053b68..76aafce42fb 100644 --- a/gdb/config/i386/tm-symmetry.h +++ b/gdb/config/i386/tm-symmetry.h @@ -269,31 +269,28 @@ switch (regno) { \ (N < 14) ? 1 : \ 0) -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ +/* Convert data from raw format for register REGNUM in buffer FROM + to virtual format with type TYPE in buffer TO. */ #undef REGISTER_CONVERT_TO_VIRTUAL -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -((REGNUM < 3) ? memcpy ((TO), (FROM), 4) : \ -(REGNUM < 5) ? i387_to_double((FROM), (TO)) : \ -(REGNUM < 8) ? memcpy ((TO), (FROM), 4) : \ -(REGNUM < 14) ? i387_to_double((FROM), (TO)) : \ - memcpy ((TO), (FROM), 4)) - +#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \ +{ \ + double val; \ + i387_to_double ((FROM), (char *)&val); \ + store_floating ((TO), TYPE_LENGTH (TYPE), val); \ +} extern void i387_to_double PARAMS ((char *, char *)); -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ +/* Convert data from virtual format with type TYPE in buffer FROM + to raw format for register REGNUM in buffer TO. */ #undef REGISTER_CONVERT_TO_RAW -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -((REGNUM < 3) ? memcpy ((TO), (FROM), 4) : \ -(REGNUM < 5) ? double_to_i387((FROM), (TO)) : \ -(REGNUM < 8) ? memcpy ((TO), (FROM), 4) : \ -(REGNUM < 14) ? double_to_i387((FROM), (TO)) : \ - memcpy ((TO), (FROM), 4)) - +#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \ +{ \ + double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \ + double_to_i387((char *)&val, (TO))) +} extern void double_to_i387 PARAMS ((char *, char *)); diff --git a/gdb/config/i960/tm-i960.h b/gdb/config/i960/tm-i960.h index 952380054ee..12f844e383a 100644 --- a/gdb/config/i960/tm-i960.h +++ b/gdb/config/i960/tm-i960.h @@ -164,35 +164,25 @@ extern CORE_ADDR saved_pc_after_call (); #define REGISTER_CONVERTIBLE(N) ((N) >= FP0_REGNUM) -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ +/* Convert data from raw format for register REGNUM in buffer FROM + to virtual format with type TYPE in buffer TO. */ extern struct ext_format ext_format_i960; -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ +#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \ { \ double val; \ - if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - { \ - ieee_extended_to_double (&ext_format_i960, (FROM), &val); \ - store_floating ((TO), REGISTER_VIRTUAL_SIZE (REGNUM), val); \ - } \ - else \ - memcpy ((TO), (FROM), 4); \ + ieee_extended_to_double (&ext_format_i960, (FROM), &val); \ + store_floating ((TO), TYPE_LENGTH (TYPE), val); \ } -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ +/* Convert data from virtual format with type TYPE in buffer FROM + to raw format for register REGNUM in buffer TO. */ -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ +#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \ { \ - if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - { \ - double val = extract_floating ((FROM), REGISTER_VIRTUAL_SIZE (REGNUM)); \ - double_to_ieee_extended (&ext_format_i960, &val, (TO)); \ - } \ - else \ - memcpy ((TO), (FROM), 4); \ + double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \ + double_to_ieee_extended (&ext_format_i960, &val, (TO)); \ } /* Return the GDB type object for the "standard" data type diff --git a/gdb/config/m68k/tm-m68k.h b/gdb/config/m68k/tm-m68k.h index a57db1329df..69988da3225 100644 --- a/gdb/config/m68k/tm-m68k.h +++ b/gdb/config/m68k/tm-m68k.h @@ -151,33 +151,23 @@ read_memory_integer (read_register (SP_REGNUM), 4) will complain. */ extern const struct ext_format ext_format_68881; -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ +/* Convert data from raw format for register REGNUM in buffer FROM + to virtual format with type TYPE in buffer TO. */ -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ +#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \ { \ double val; \ - if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - { \ - ieee_extended_to_double (&ext_format_68881, (FROM), &val); \ - store_floating ((TO), REGISTER_VIRTUAL_SIZE (REGNUM), val); \ - } \ - else \ - memcpy ((TO), (FROM), 4); \ + ieee_extended_to_double (&ext_format_68881, (FROM), &val); \ + store_floating ((TO), TYPE_LENGTH (TYPE), val); \ } -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ +/* Convert data from virtual format with type TYPE in buffer FROM + to raw format for register REGNUM in buffer TO. */ -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ +#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \ { \ - if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - { \ - double val = extract_floating ((FROM), REGISTER_VIRTUAL_SIZE (REGNUM)); \ - double_to_ieee_extended (&ext_format_68881, &val, (TO)); \ - } \ - else \ - memcpy ((TO), (FROM), 4); \ + double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \ + double_to_ieee_extended (&ext_format_68881, &val, (TO)); \ } /* Return the GDB type object for the "standard" data type diff --git a/gdb/config/m68k/tm-news.h b/gdb/config/m68k/tm-news.h index 886cf250227..ee3d9b2a2b9 100644 --- a/gdb/config/m68k/tm-news.h +++ b/gdb/config/m68k/tm-news.h @@ -35,7 +35,9 @@ Here is an m-news.h file for gdb. It supports the 68881 registers. { if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \ { \ REGISTER_CONVERT_TO_VIRTUAL (FP0_REGNUM, \ - ®BUF[REGISTER_BYTE (FP0_REGNUM)], VALBUF); \ + REGISTER_VIRTUAL_TYPE (FP0_REGNUM), \ + ®BUF[REGISTER_BYTE (FP0_REGNUM)], \ + VALBUF); \ } \ else \ memcpy (VALBUF, REGBUF, TYPE_LENGTH (TYPE)); } @@ -48,7 +50,8 @@ Here is an m-news.h file for gdb. It supports the 68881 registers. { if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \ { \ char raw_buf[REGISTER_RAW_SIZE (FP0_REGNUM)]; \ - REGISTER_CONVERT_TO_RAW (FP0_REGNUM, VALBUF, raw_buf); \ + REGISTER_CONVERT_TO_RAW (REGISTER_VIRTUAL_TYPE (FP0_REGNUM), \ + FP0_REGNUM, VALBUF, raw_buf); \ write_register_bytes (FP0_REGNUM, \ raw_buf, REGISTER_RAW_SIZE (FP0_REGNUM)); \ } \ diff --git a/gdb/config/m88k/tm-m88k.h b/gdb/config/m88k/tm-m88k.h index c8a7d9bc384..77b902badaa 100644 --- a/gdb/config/m88k/tm-m88k.h +++ b/gdb/config/m88k/tm-m88k.h @@ -388,30 +388,23 @@ if (!target_is_m88110) \ extern const struct ext_format ext_format_m88110; -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ +/* Convert data from raw format for register REGNUM in buffer FROM + to virtual format with type TYPE in buffer TO. */ -/* FIXME: Use store_floating like tm-m68k.h. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ +#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \ { \ - if ((REGNUM) < XFP_REGNUM) \ - memcpy ((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); \ - else ieee_extended_to_double(&ext_format_m88110, \ - (FROM), (double *)(TO)); \ + double val; \ + ieee_extended_to_double (&ext_format_m88110, (FROM), &val); \ + store_floating ((TO), TYPE_LENGTH (TYPE), val); \ } -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -/* FIXME: Use extract_floating like tm-m68k.h. */ +/* Convert data from virtual format with type TYPE in buffer FROM + to raw format for register REGNUM in buffer TO. */ -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ +#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \ { \ - if ((REGNUM) < XFP_REGNUM) \ - memcpy ((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); \ - else double_to_ieee_extended (&ext_format_m88110, \ - (double *)(FROM), (TO)); \ + double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \ + double_to_ieee_extended (&ext_format_m88110, &val, (TO)); \ } /* Return the GDB type object for the "standard" data type diff --git a/gdb/config/mips/tm-mips.h b/gdb/config/mips/tm-mips.h index ddb63c4616d..472766178ed 100644 --- a/gdb/config/mips/tm-mips.h +++ b/gdb/config/mips/tm-mips.h @@ -164,23 +164,6 @@ extern CORE_ADDR mips_skip_prologue PARAMS ((CORE_ADDR addr, int lenient)); #define MAX_REGISTER_VIRTUAL_SIZE 8 -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - memcpy ((TO), (FROM), 4); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - memcpy ((TO), (FROM), 4); - /* Return the GDB type object for the "standard" data type of data in register N. */ diff --git a/gdb/config/ns32k/tm-merlin.h b/gdb/config/ns32k/tm-merlin.h index 4503993a739..b6d29c17d8d 100644 --- a/gdb/config/ns32k/tm-merlin.h +++ b/gdb/config/ns32k/tm-merlin.h @@ -141,23 +141,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define MAX_REGISTER_VIRTUAL_SIZE 8 -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - memcpy ((TO), (FROM), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - memcpy ((TO), (FROM), REGISTER_VIRTUAL_SIZE(REGNUM)); - /* Return the GDB type object for the "standard" data type of data in register N. */ diff --git a/gdb/config/ns32k/tm-umax.h b/gdb/config/ns32k/tm-umax.h index 6d3e1ca597f..3e33d25e188 100644 --- a/gdb/config/ns32k/tm-umax.h +++ b/gdb/config/ns32k/tm-umax.h @@ -156,23 +156,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define MAX_REGISTER_VIRTUAL_SIZE 8 -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - memcpy ((TO), (FROM), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - memcpy ((TO), (FROM), REGISTER_VIRTUAL_SIZE(REGNUM)); - /* Return the GDB type object for the "standard" data type of data in register N. */ diff --git a/gdb/config/sh/tm-sh.h b/gdb/config/sh/tm-sh.h index 784a4839ef5..61ce7c9b855 100644 --- a/gdb/config/sh/tm-sh.h +++ b/gdb/config/sh/tm-sh.h @@ -98,23 +98,6 @@ extern CORE_ADDR sh_skip_prologue (); #define MAX_REGISTER_VIRTUAL_SIZE 4 -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - { memcpy ((TO), (FROM), 4); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - { memcpy ((TO), (FROM), 4); } - /* Return the GDB type object for the "standard" data type of data in register N. */ diff --git a/gdb/config/sparc/tm-sparc.h b/gdb/config/sparc/tm-sparc.h index 09193f8763a..4e8e183b2d3 100644 --- a/gdb/config/sparc/tm-sparc.h +++ b/gdb/config/sparc/tm-sparc.h @@ -238,23 +238,6 @@ extern CORE_ADDR sparc_pc_adjust(); #define MAX_REGISTER_VIRTUAL_SIZE 8 -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ memcpy ((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ memcpy ((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); } - /* Return the GDB type object for the "standard" data type of data in register N. */ diff --git a/gdb/config/vax/tm-vax.h b/gdb/config/vax/tm-vax.h index ddf0dcf7179..6d39f752e53 100644 --- a/gdb/config/vax/tm-vax.h +++ b/gdb/config/vax/tm-vax.h @@ -142,23 +142,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define MAX_REGISTER_VIRTUAL_SIZE 4 -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - memcpy ((TO), (FROM), 4); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - memcpy ((TO), (FROM), 4); - /* Return the GDB type object for the "standard" data type of data in register N. */ diff --git a/gdb/config/z8k/tm-z8k.h b/gdb/config/z8k/tm-z8k.h index 5412c049980..898ead95d4c 100644 --- a/gdb/config/z8k/tm-z8k.h +++ b/gdb/config/z8k/tm-z8k.h @@ -107,23 +107,6 @@ extern CORE_ADDR mz8k_skip_prologue PARAMS ((CORE_ADDR ip)); #define MAX_REGISTER_VIRTUAL_SIZE 4 -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - register_convert_to_virtual(REGNUM, FROM, TO) - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - register_convert_to_raw(REGNUM, FROM, TO) - /* Return the GDB type object for the "standard" data type of data in register N. */ diff --git a/gdb/findvar.c b/gdb/findvar.c index fe9fc369425..8f28b90c12a 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -168,6 +168,91 @@ store_address (addr, len, val) store_unsigned_integer (addr, len, (LONGEST)val); } +/* Swap LEN bytes at BUFFER between target and host byte-order. This is + the wrong way to do byte-swapping because it assumes that you have a way + to have a host variable of exactly the right size. Once extract_floating + and store_floating have been fixed, this can go away. */ +#if TARGET_BYTE_ORDER == HOST_BYTE_ORDER +#define SWAP_TARGET_AND_HOST(buffer,len) +#else /* Target and host byte order differ. */ +#define SWAP_TARGET_AND_HOST(buffer,len) \ + { \ + char tmp; \ + char *p = (char *)(buffer); \ + char *q = ((char *)(buffer)) + len - 1; \ + for (; p < q; p++, q--) \ + { \ + tmp = *q; \ + *q = *p; \ + *p = tmp; \ + } \ + } +#endif /* Target and host byte order differ. */ + +/* There are many problems with floating point cross-debugging. + + 1. These routines only handle byte-swapping, not conversion of + formats. So if host is IEEE floating and target is VAX floating, + or vice-versa, it loses. This means that we can't (yet) use these + routines for extendeds. Extendeds are handled by + REGISTER_CONVERTIBLE. What we want is a fixed version of + ieee-float.c (the current version can't deal with single or double, + and I suspect it is probably broken for some extendeds too). + + 2. We can't deal with it if there is more than one floating point + format in use. This has to be fixed at the unpack_double level. + + 3. We probably should have a LONGEST_DOUBLE or DOUBLEST or whatever + we want to call it which is long double where available. */ + +double +extract_floating (addr, len) + PTR addr; + int len; +{ + if (len == sizeof (float)) + { + float retval; + memcpy (&retval, addr, sizeof (retval)); + SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); + return retval; + } + else if (len == sizeof (double)) + { + double retval; + memcpy (&retval, addr, sizeof (retval)); + SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); + return retval; + } + else + { + error ("Can't deal with a floating point number of %d bytes.", len); + } +} + +void +store_floating (addr, len, val) + PTR addr; + int len; + double val; +{ + if (len == sizeof (float)) + { + float floatval = val; + SWAP_TARGET_AND_HOST (&floatval, sizeof (floatval)); + memcpy (addr, &floatval, sizeof (floatval)); + } + else if (len == sizeof (double)) + { + SWAP_TARGET_AND_HOST (&val, sizeof (val)); + memcpy (addr, &val, sizeof (val)); + } + else + { + error ("Can't deal with a floating point number of %d bytes.", len); + } +} + #if !defined (GET_SAVED_REGISTER) /* Return the address in which frame FRAME's value of register REGNUM @@ -340,16 +425,25 @@ value_of_register (regnum) int optim; register value val; char raw_buffer[MAX_REGISTER_RAW_SIZE]; - char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; enum lval_type lval; get_saved_register (raw_buffer, &optim, &addr, selected_frame, regnum, &lval); - REGISTER_CONVERT_TO_VIRTUAL (regnum, raw_buffer, virtual_buffer); val = allocate_value (REGISTER_VIRTUAL_TYPE (regnum)); - memcpy (VALUE_CONTENTS_RAW (val), virtual_buffer, - REGISTER_VIRTUAL_SIZE (regnum)); + + /* Convert raw data to virtual format if necessary. */ + +#ifdef REGISTER_CONVERTIBLE + if (REGISTER_CONVERTIBLE (regnum)) + { + REGISTER_CONVERT_TO_VIRTUAL (regnum, REGISTER_VIRTUAL_TYPE (regnum), + raw_buffer, VALUE_CONTENTS_RAW (val)); + } + else +#endif + memcpy (VALUE_CONTENTS_RAW (val), raw_buffer, + REGISTER_RAW_SIZE (regnum)); VALUE_LVAL (val) = lval; VALUE_ADDRESS (val) = addr; VALUE_REGNO (val) = regnum; @@ -710,7 +804,6 @@ value_from_register (type, regnum, frame) FRAME frame; { char raw_buffer [MAX_REGISTER_RAW_SIZE]; - char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; CORE_ADDR addr; int optim; value v = allocate_value (type); @@ -879,36 +972,17 @@ value_from_register (type, regnum, frame) VALUE_OPTIMIZED_OUT (v) = optim; VALUE_LVAL (v) = lval; VALUE_ADDRESS (v) = addr; + + /* Convert raw data to virtual format if necessary. */ - /* Convert the raw contents to virtual contents. - (Just copy them if the formats are the same.) */ - - REGISTER_CONVERT_TO_VIRTUAL (regnum, raw_buffer, virtual_buffer); - +#ifdef REGISTER_CONVERTIBLE if (REGISTER_CONVERTIBLE (regnum)) { - /* When the raw and virtual formats differ, the virtual format - corresponds to a specific data type. If we want that type, - copy the data into the value. - Otherwise, do a type-conversion. */ - - if (type != REGISTER_VIRTUAL_TYPE (regnum)) - { - /* eg a variable of type `float' in a 68881 register - with raw type `extended' and virtual type `double'. - Fetch it as a `double' and then convert to `float'. */ - /* FIXME: This value will be not_lval, which means we can't assign - to it. Probably the right fix is to do the cast on a temporary - value, and just copy the VALUE_CONTENTS over. */ - v = allocate_value (REGISTER_VIRTUAL_TYPE (regnum)); - memcpy (VALUE_CONTENTS_RAW (v), virtual_buffer, - REGISTER_VIRTUAL_SIZE (regnum)); - v = value_cast (type, v); - } - else - memcpy (VALUE_CONTENTS_RAW (v), virtual_buffer, len); + REGISTER_CONVERT_TO_VIRTUAL (regnum, type, + raw_buffer, VALUE_CONTENTS_RAW (v)); } else +#endif { /* Raw and virtual formats are the same for this register. */ @@ -920,7 +994,7 @@ value_from_register (type, regnum, frame) } #endif - memcpy (VALUE_CONTENTS_RAW (v), virtual_buffer + VALUE_OFFSET (v), len); + memcpy (VALUE_CONTENTS_RAW (v), raw_buffer + VALUE_OFFSET (v), len); } return v; diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 186a080d0eb..cc16dd01fdd 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -1097,9 +1097,20 @@ pa_print_fp_reg (i) unsigned char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; REGISTER_TYPE val; - /* Get the data in raw format, then convert also to virtual format. */ + /* Get the data in raw format. */ read_relative_register_raw_bytes (i, raw_buffer); - REGISTER_CONVERT_TO_VIRTUAL (i, raw_buffer, virtual_buffer); + + /* Convert raw data to virtual format if necessary. */ +#ifdef REGISTER_CONVERTIBLE + if (REGISTER_CONVERTIBLE (i)) + { + REGISTER_CONVERT_TO_VIRTUAL (i, REGISTER_VIRTUAL_TYPE (i), + raw_buffer, virtual_buffer); + } + else +#endif + memcpy (virtual_buffer, raw_buffer, + REGISTER_VIRTUAL_SIZE (i)); fputs_filtered (reg_names[i], gdb_stdout); print_spaces_filtered (15 - strlen (reg_names[i]), gdb_stdout); diff --git a/gdb/valops.c b/gdb/valops.c index 7697266107b..ebddb5b90b4 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -286,7 +286,6 @@ value_assign (toval, fromval) register struct type *type = VALUE_TYPE (toval); register value val; char raw_buffer[MAX_REGISTER_RAW_SIZE]; - char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; int use_buffer = 0; COERCE_ARRAY (fromval); @@ -300,17 +299,19 @@ value_assign (toval, fromval) convert FROMVAL's contents now, with result in `raw_buffer', and set USE_BUFFER to the number of bytes to write. */ +#ifdef REGISTER_CONVERTIBLE if (VALUE_REGNO (toval) >= 0 && REGISTER_CONVERTIBLE (VALUE_REGNO (toval))) { int regno = VALUE_REGNO (toval); - if (VALUE_TYPE (fromval) != REGISTER_VIRTUAL_TYPE (regno)) - fromval = value_cast (REGISTER_VIRTUAL_TYPE (regno), fromval); - memcpy (virtual_buffer, VALUE_CONTENTS (fromval), - REGISTER_VIRTUAL_SIZE (regno)); - REGISTER_CONVERT_TO_RAW (regno, virtual_buffer, raw_buffer); - use_buffer = REGISTER_RAW_SIZE (regno); + if (REGISTER_CONVERTIBLE (regno)) + { + REGISTER_CONVERT_TO_RAW (VALUE_TYPE (fromval), regno, + VALUE_CONTENTS (fromval), raw_buffer); + use_buffer = REGISTER_RAW_SIZE (regno); + } } +#endif switch (VALUE_LVAL (toval)) { @@ -336,10 +337,10 @@ value_assign (toval, fromval) + VALUE_BITSIZE (toval) + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT; - /* If bigger than a LONGEST, we don't handle it correctly, - but at least avoid corrupting memory. */ + if (len > sizeof (LONGEST)) - len = sizeof (LONGEST); + error ("Can't handle bitfields which don't fit in a %d bit word.", + sizeof (LONGEST) * HOST_CHAR_BIT); read_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), buffer, len); @@ -359,8 +360,20 @@ value_assign (toval, fromval) case lval_register: if (VALUE_BITSIZE (toval)) { - char buffer[MAX_REGISTER_RAW_SIZE]; + char buffer[sizeof (LONGEST)]; int len = REGISTER_RAW_SIZE (VALUE_REGNO (toval)); + + if (len > sizeof (LONGEST)) + error ("Can't handle bitfields in registers larger than %d bits.", + sizeof (LONGEST) * HOST_CHAR_BIT); + + if (VALUE_BITPOS (toval) + VALUE_BITSIZE (toval) + > len * HOST_CHAR_BIT) + /* Getting this right would involve being very careful about + byte order. */ + error ("\ +Can't handle bitfield which doesn't fit in a single register."); + read_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), buffer, len); modify_field (buffer, value_as_long (fromval), @@ -485,9 +498,6 @@ value_assign (toval, fromval) type = VALUE_TYPE (fromval); } - /* FIXME: This loses if fromval is a different size than toval, for - example because fromval got cast in the REGISTER_CONVERTIBLE case - above. */ val = allocate_value (type); memcpy (val, toval, VALUE_CONTENTS_RAW (val) - (char *) val); memcpy (VALUE_CONTENTS_RAW (val), VALUE_CONTENTS (fromval), diff --git a/gdb/z8k-tdep.c b/gdb/z8k-tdep.c index ffec6f6bd6a..465b74dcdf5 100644 --- a/gdb/z8k-tdep.c +++ b/gdb/z8k-tdep.c @@ -384,28 +384,6 @@ print_register_hook (regno) } -void -register_convert_to_virtual (regnum, from, to) - unsigned char *from; - unsigned char *to; -{ - to[0] = from[0]; - to[1] = from[1]; - to[2] = from[2]; - to[3] = from[3]; -} - -void -register_convert_to_raw (regnum, to, from) - char *to; - char *from; -{ - to[0] = from[0]; - to[1] = from[1]; - to[2] = from[2]; - to[3] = from[3]; -} - void z8k_pop_frame () { -- 2.30.2