diff options
-rw-r--r-- | gdb/ChangeLog | 19 | ||||
-rw-r--r-- | gdb/config/i960/tm-i960.h | 26 | ||||
-rw-r--r-- | gdb/config/m68k/tm-m68k.h | 13 | ||||
-rw-r--r-- | gdb/config/m88k/tm-m88k.h | 11 | ||||
-rw-r--r-- | gdb/remote-nindy.c | 22 | ||||
-rw-r--r-- | gdb/stabsread.c | 16 | ||||
-rw-r--r-- | gdb/values.c | 95 |
7 files changed, 95 insertions, 107 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 962de49..9f0e5f9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,22 @@ +Fri Oct 29 08:11:29 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * defs.h, findvar.c (extract_floating, store_floating): New functions. + * Move SWAP_TARGET_AND_HOST from defs.h to findvar.c because it is + now used only by extract_floating and store_floating. + * valprint.c (print_floating): Use unsigned arithmetic. Use + extract_unsigned_integer instead of SWAP_TARGET_AND_HOST. + Change sizeof (float) to 4 and sizeof (double) to 8 (those are always + the relevant sizes for this code, which is in #ifdef IEEE_FLOAT). + * values.c (unpack_long, unpack_double, value_from_double), + valarith.c (value_binop), stabsread.c (define_symbol): + Use extract_floating and store_floating instead of + SWAP_TARGET_AND_HOST. + * config/m68k/tm-m68k.h, config/i960/tm-i960.h (REGISTER_CONVERT_*): + Use extract_floating and store_floating. + * config/m88k/tm-m88k.h: Add comments (it should be doing the same). + * i386-tdep.c (i386_extract_return_value), + * remote-nindy.c (nindy_store_registers): Use store_floating. + Fri Oct 29 09:31:38 1993 Steve Chamberlain (sac@rtl.cygnus.com) * remote-sim.c (gdbsim_store_register): Change var name so diff --git a/gdb/config/i960/tm-i960.h b/gdb/config/i960/tm-i960.h index 1337362..9523800 100644 --- a/gdb/config/i960/tm-i960.h +++ b/gdb/config/i960/tm-i960.h @@ -169,26 +169,32 @@ extern CORE_ADDR saved_pc_after_call (); extern struct ext_format ext_format_i960; -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ +#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ { \ - if ((REGNUM) >= FP0_REGNUM) \ - ieee_extended_to_double (&ext_format_i960, (FROM), (double *)(TO)); \ - else \ + 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); \ } /* Convert data from virtual format for register REGNUM to raw format for register REGNUM. */ -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ +#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ { \ - if ((REGNUM) >= FP0_REGNUM) \ - double_to_ieee_extended (&ext_format_i960, (double *)(FROM), (TO)); \ - else \ - memcpy ((TO), (FROM), 4); \ + 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); \ } - /* Return the GDB type object for the "standard" data type of data in register N. */ diff --git a/gdb/config/m68k/tm-m68k.h b/gdb/config/m68k/tm-m68k.h index db7b6a4..a57db13 100644 --- a/gdb/config/m68k/tm-m68k.h +++ b/gdb/config/m68k/tm-m68k.h @@ -156,8 +156,12 @@ extern const struct ext_format ext_format_68881; #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ { \ - if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - ieee_extended_to_double (&ext_format_68881, (FROM), (double *)(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); \ } @@ -168,7 +172,10 @@ extern const struct ext_format ext_format_68881; #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ { \ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - double_to_ieee_extended (&ext_format_68881, (double *)(FROM), (TO)); \ + { \ + double val = extract_floating ((FROM), REGISTER_VIRTUAL_SIZE (REGNUM)); \ + double_to_ieee_extended (&ext_format_68881, &val, (TO)); \ + } \ else \ memcpy ((TO), (FROM), 4); \ } diff --git a/gdb/config/m88k/tm-m88k.h b/gdb/config/m88k/tm-m88k.h index 68bdd61..c8a7d9b 100644 --- a/gdb/config/m88k/tm-m88k.h +++ b/gdb/config/m88k/tm-m88k.h @@ -386,10 +386,13 @@ if (!target_is_m88110) \ #define REGISTER_CONVERTIBLE(N) ((N) >= XFP_REGNUM) - /* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ +extern const struct ext_format ext_format_m88110; + +/* Convert data from raw format for register REGNUM + to virtual format for register REGNUM. */ + +/* FIXME: Use store_floating like tm-m68k.h. */ - extern const struct ext_format ext_format_m88110; #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ { \ if ((REGNUM) < XFP_REGNUM) \ @@ -401,6 +404,8 @@ if (!target_is_m88110) \ /* Convert data from virtual format for register REGNUM to raw format for register REGNUM. */ +/* FIXME: Use extract_floating like tm-m68k.h. */ + #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ { \ if ((REGNUM) < XFP_REGNUM) \ diff --git a/gdb/remote-nindy.c b/gdb/remote-nindy.c index 72dcfdd..4050ff4 100644 --- a/gdb/remote-nindy.c +++ b/gdb/remote-nindy.c @@ -472,7 +472,7 @@ nindy_store_registers(regno) int regno; { struct nindy_regs nindy_regs; - int regnum, inv; + int regnum; double dub; memcpy (nindy_regs.local_regs, ®isters[REGISTER_BYTE (R0_REGNUM)], 16*4); @@ -480,18 +480,14 @@ nindy_store_registers(regno) memcpy (nindy_regs.pcw_acw, ®isters[REGISTER_BYTE (PCW_REGNUM)], 2*4); memcpy (nindy_regs.ip, ®isters[REGISTER_BYTE (IP_REGNUM)], 1*4); memcpy (nindy_regs.tcw, ®isters[REGISTER_BYTE (TCW_REGNUM)], 1*4); - /* Float regs. Only works on IEEE_FLOAT hosts. FIXME! */ - for (regnum = FP0_REGNUM; regnum < FP0_REGNUM + 4; regnum++) { - ieee_extended_to_double (&ext_format_i960, - ®isters[REGISTER_BYTE (regnum)], &dub); - /* dub now in host byte order */ - /* FIXME-someday, the arguments to unpack_double are backward. - It expects a target double and returns a host; we pass the opposite. - This mostly works but not quite. */ - dub = unpack_double (builtin_type_double, (char *)&dub, &inv); - /* dub now in target byte order */ - memcpy (&nindy_regs.fp_as_double[8 * (regnum - FP0_REGNUM)], &dub, 8); - } + for (regnum = FP0_REGNUM; regnum < FP0_REGNUM + 4; regnum++) + { + ieee_extended_to_double (&ext_format_i960, + ®isters[REGISTER_BYTE (regnum)], &dub); + store_floating (&nindy_regs.fp_as_double[8 * (regnum - FP0_REGNUM)], + REGISTER_VIRTUAL_SIZE (regnum), + dub); + } immediate_quit++; ninRegsPut( (char *) &nindy_regs ); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index f2d671c..71a806e 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -613,11 +613,13 @@ define_symbol (valu, string, desc, type, objfile) double d = atof (p); char *dbl_valu; + /* FIXME-if-picky-about-floating-accuracy: Should be using + target arithmetic to get the value. real.c in GCC + probably has the necessary code. */ + /* FIXME: lookup_fundamental_type is a hack. We should be creating a type especially for the type of float constants. - Problem is, what type should it be? We currently have to - read this in host floating point format, but what type - represents a host format "double"? + Problem is, what type should it be? Also, what should the name of this type be? Should we be using 'S' constants (see stabs.texinfo) instead? */ @@ -625,11 +627,9 @@ define_symbol (valu, string, desc, type, objfile) SYMBOL_TYPE (sym) = lookup_fundamental_type (objfile, FT_DBL_PREC_FLOAT); dbl_valu = (char *) - obstack_alloc (&objfile -> symbol_obstack, sizeof (double)); - memcpy (dbl_valu, &d, sizeof (double)); - /* Put it in target byte order, but it's still in host - floating point format. */ - SWAP_TARGET_AND_HOST (dbl_valu, sizeof (double)); + obstack_alloc (&objfile -> symbol_obstack, + TYPE_LENGTH (SYMBOL_TYPE (sym))); + store_floating (dbl_valu, TYPE_LENGTH (SYMBOL_TYPE (sym))); SYMBOL_VALUE_BYTES (sym) = dbl_valu; SYMBOL_CLASS (sym) = LOC_CONST_BYTES; } diff --git a/gdb/values.c b/gdb/values.c index d36bfcd..9b12ad5 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -594,49 +594,33 @@ unpack_long (type, valaddr) register int len = TYPE_LENGTH (type); register int nosign = TYPE_UNSIGNED (type); - if (code == TYPE_CODE_ENUM || code == TYPE_CODE_BOOL) - code = TYPE_CODE_INT; - if (code == TYPE_CODE_FLT) + switch (code) { - if (len == sizeof (float)) - { - float retval; - memcpy (&retval, valaddr, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - - if (len == sizeof (double)) - { - double retval; - memcpy (&retval, valaddr, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } + case TYPE_CODE_ENUM: + case TYPE_CODE_BOOL: + case TYPE_CODE_INT: + case TYPE_CODE_CHAR: + if (nosign) + return extract_unsigned_integer (valaddr, len); else - { - error ("Unexpected type of floating point number."); - } - } - else if ((code == TYPE_CODE_INT || code == TYPE_CODE_CHAR) && nosign) - { - return extract_unsigned_integer (valaddr, len); - } - else if (code == TYPE_CODE_INT || code == TYPE_CODE_CHAR) - { - return extract_signed_integer (valaddr, len); - } - /* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure - whether we want this to be true eventually. */ - else if (code == TYPE_CODE_PTR || code == TYPE_CODE_REF) - { + return extract_signed_integer (valaddr, len); + + case TYPE_CODE_FLT: + return extract_floating (valaddr, len); + + case TYPE_CODE_PTR: + case TYPE_CODE_REF: + /* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure + whether we want this to be true eventually. */ return extract_address (valaddr, len); - } - else if (code == TYPE_CODE_MEMBER) - error ("not implemented: member types in unpack_long"); - error ("Value not integer or pointer."); - return 0; /* For lint -- never reached */ + case TYPE_CODE_MEMBER: + error ("not implemented: member types in unpack_long"); + + default: + error ("Value can't be converted to intenot integer or pointer."); + } + return 0; /* Placate lint. */ } /* Return a double value from the specified type and address. @@ -663,27 +647,7 @@ unpack_double (type, valaddr, invp) *invp = 1; return 1.234567891011121314; } - - if (len == sizeof (float)) - { - float retval; - memcpy (&retval, valaddr, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - - if (len == sizeof (double)) - { - double retval; - memcpy (&retval, valaddr, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - else - { - error ("Unexpected type of floating point number."); - return 0; /* Placate lint. */ - } + return extract_floating (valaddr, TYPE_LENGTH (type)); } else if (nosign) { /* Unsigned -- be sure we compensate for signed LONGEST. */ @@ -1341,20 +1305,11 @@ value_from_double (type, num) if (code == TYPE_CODE_FLT) { - if (len == sizeof (float)) - * (float *) VALUE_CONTENTS_RAW (val) = num; - else if (len == sizeof (double)) - * (double *) VALUE_CONTENTS_RAW (val) = num; - else - error ("Floating type encountered with unexpected data length."); + store_floating (VALUE_CONTENTS_RAW (val), len, num); } else error ("Unexpected type encountered for floating constant."); - /* num was in host byte order. So now put the value's contents - into target byte order. */ - SWAP_TARGET_AND_HOST (VALUE_CONTENTS_RAW (val), len); - return val; } |