diff options
author | Andrew Cagney <cagney@redhat.com> | 2001-09-24 17:16:53 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2001-09-24 17:16:53 +0000 |
commit | 96d2f608dcfdd177211dbb65b607d3bc03d1b320 (patch) | |
tree | d8af318ce072f6251da5ca6bc159c7a6b490a53d | |
parent | 2f8d8971c6c9992e015c50639186db1e6ad2f0c4 (diff) | |
download | gdb-96d2f608dcfdd177211dbb65b607d3bc03d1b320.zip gdb-96d2f608dcfdd177211dbb65b607d3bc03d1b320.tar.gz gdb-96d2f608dcfdd177211dbb65b607d3bc03d1b320.tar.bz2 |
* doublest.h (store_floating, extract_floating): Add comment
indicating these functions are deprecated.
(extract_typed_floating, store_typed_floating): Declare.
* doublest.c: Include "gdbtypes.h".
(extract_typed_floating, store_typed_floating): Define.
* stabsread.c (define_symbol): Use store_typed_floating.
* valarith.c (value_binop): Ditto.
* values.c (unpack_long): Use extract_typed_floating.
(unpack_double): Ditto.
-rw-r--r-- | gdb/ChangeLog | 13 | ||||
-rw-r--r-- | gdb/doublest.c | 40 | ||||
-rw-r--r-- | gdb/doublest.h | 10 | ||||
-rw-r--r-- | gdb/stabsread.c | 2 | ||||
-rw-r--r-- | gdb/valarith.c | 3 | ||||
-rw-r--r-- | gdb/values.c | 6 |
6 files changed, 64 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 949e80f..37a112a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2001-09-24 Andrew Cagney <ac131313@redhat.com> + + * doublest.h (store_floating, extract_floating): Add comment + indicating these functions are deprecated. + (extract_typed_floating, store_typed_floating): Declare. + * doublest.c: Include "gdbtypes.h". + (extract_typed_floating, store_typed_floating): Define. + + * stabsread.c (define_symbol): Use store_typed_floating. + * valarith.c (value_binop): Ditto. + * values.c (unpack_long): Use extract_typed_floating. + (unpack_double): Ditto. + 2001-09-24 Orjan Friberg <orjanf@axis.com> * cris-tdep.c (reg_mode_add_sub_cmp_and_or_move_op): Fetch operand1 diff --git a/gdb/doublest.c b/gdb/doublest.c index 287c9ad..e2dd3e8 100644 --- a/gdb/doublest.c +++ b/gdb/doublest.c @@ -31,6 +31,7 @@ #include "floatformat.h" #include "gdb_assert.h" #include "gdb_string.h" +#include "gdbtypes.h" #include <math.h> /* ldexp */ /* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not @@ -606,8 +607,12 @@ floatformat_from_doublest (const struct floatformat *fmt, } -/* Extract/store a floating-point number from a target-order - byte-stream at ADDR. Returns the value as type DOUBLEST. */ +/* Extract/store a target floating-point number from byte-stream at + ADDR to/from a DOUBLEST. The LEN is used to select between the + pre-defined target type FLOAT, DOUBLE or LONG_DOUBLE. These + functions are used when extract/store typed floating() find that + the ``struct type'' did not include a FLOATFORMAT (e.g. some symbol + table readers and XXX-language support modules). */ DOUBLEST extract_floating (const void *addr, int len) @@ -652,3 +657,34 @@ store_floating (void *addr, int len, DOUBLEST val) error ("Can't deal with a floating point number of %d bytes.", len); } } + +/* Extract/store a floating-point number of format TYPE from a + target-ordered byte-stream at ADDR to/from an internal DOUBLEST + accroding to its TYPE_FORMAT(). When GDB reads in debug + information, it is sometimes only provided with the type name, its + length and the fact that it is a float (TYPE_FORMAT() is not set). + For such types, the old extract/store floating() functions are + used. */ + +DOUBLEST +extract_typed_floating (const void *addr, const struct type *type) +{ + DOUBLEST retval; + gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT); + if (TYPE_FLOATFORMAT (type) == NULL) + retval = extract_floating (addr, TYPE_LENGTH (type)); + else + floatformat_to_doublest (TYPE_FLOATFORMAT (type), addr, &retval); + return retval; +} + +void +store_typed_floating (void *addr, const struct type *type, DOUBLEST val) +{ + gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT); + memset (addr, 0, TYPE_LENGTH (type)); + if (TYPE_FLOATFORMAT (type) == NULL) + store_floating (addr, TYPE_LENGTH (type), val); + else + floatformat_from_doublest (TYPE_FLOATFORMAT (type), &val, addr); +} diff --git a/gdb/doublest.h b/gdb/doublest.h index 9ccdc6c..d3955b3 100644 --- a/gdb/doublest.h +++ b/gdb/doublest.h @@ -61,7 +61,13 @@ extern int floatformat_is_negative (const struct floatformat *, char *); extern int floatformat_is_nan (const struct floatformat *, char *); extern char *floatformat_mantissa (const struct floatformat *, char *); -extern DOUBLEST extract_floating (const void *in, int); -extern void store_floating (void *, int, DOUBLEST); +/* Use extract_typed_float() and store_typed_float(). */ +extern DOUBLEST extract_floating (const void *in, int); /* DEPRECATED */ +extern void store_floating (void *, int, DOUBLEST); /* DEPRECATED */ + +extern DOUBLEST extract_typed_floating (const void *addr, + const struct type *type); +extern void store_typed_floating (void *addr, const struct type *type, + DOUBLEST val); #endif diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 87cf768..2063923 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1491,7 +1491,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, dbl_valu = (char *) obstack_alloc (&objfile->symbol_obstack, TYPE_LENGTH (SYMBOL_TYPE (sym))); - store_floating (dbl_valu, TYPE_LENGTH (SYMBOL_TYPE (sym)), d); + store_typed_floating (dbl_valu, SYMBOL_TYPE (sym), d); SYMBOL_VALUE_BYTES (sym) = dbl_valu; SYMBOL_CLASS (sym) = LOC_CONST_BYTES; } diff --git a/gdb/valarith.c b/gdb/valarith.c index d421a02..e0598d0 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -763,8 +763,7 @@ value_binop (value_ptr arg1, value_ptr arg2, enum exp_opcode op) else val = allocate_value (builtin_type_double); - store_floating (VALUE_CONTENTS_RAW (val), TYPE_LENGTH (VALUE_TYPE (val)), - v); + store_typed_floating (VALUE_CONTENTS_RAW (val), VALUE_TYPE (val), v); } else if (TYPE_CODE (type1) == TYPE_CODE_BOOL && diff --git a/gdb/values.c b/gdb/values.c index c41afb5..ededf9d 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -645,7 +645,7 @@ unpack_long (struct type *type, char *valaddr) return extract_signed_integer (valaddr, len); case TYPE_CODE_FLT: - return extract_floating (valaddr, len); + return extract_typed_floating (valaddr, type); case TYPE_CODE_PTR: case TYPE_CODE_REF: @@ -689,7 +689,7 @@ unpack_double (struct type *type, char *valaddr, int *invp) return 1.234567891011121314; } #endif - return extract_floating (valaddr, len); + return extract_typed_floating (valaddr, type); } else if (nosign) { @@ -1297,7 +1297,7 @@ value_from_double (struct type *type, DOUBLEST num) if (code == TYPE_CODE_FLT) { - store_floating (VALUE_CONTENTS_RAW (val), len, num); + store_typed_floating (VALUE_CONTENTS_RAW (val), base_type, num); } else error ("Unexpected type encountered for floating constant."); |