aboutsummaryrefslogtreecommitdiff
path: root/gdb/values.c
diff options
context:
space:
mode:
authorJim Kingdon <jkingdon@engr.sgi.com>1993-10-29 18:16:33 +0000
committerJim Kingdon <jkingdon@engr.sgi.com>1993-10-29 18:16:33 +0000
commitbf5c0d644899aa224fcac5eb0b5dff2002d6448c (patch)
treec10acbcabf8139066784b8d7f465617b458dee71 /gdb/values.c
parente1ec9f078ff7293455d25741056f3fa633deaebf (diff)
downloadgdb-bf5c0d644899aa224fcac5eb0b5dff2002d6448c.zip
gdb-bf5c0d644899aa224fcac5eb0b5dff2002d6448c.tar.gz
gdb-bf5c0d644899aa224fcac5eb0b5dff2002d6448c.tar.bz2
* 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.
Diffstat (limited to 'gdb/values.c')
-rw-r--r--gdb/values.c95
1 files changed, 25 insertions, 70 deletions
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;
}