aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2017-11-06 16:02:33 +0100
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2017-11-06 16:02:33 +0100
commitb07e9c466ed24af614090ac42d6730a291608f69 (patch)
treecd800a1298a4333f68ab971b516017362029fa0b /gdb
parent3b2ca8248cae742c00cb4e94138edf1403d43d47 (diff)
downloadfsf-binutils-gdb-b07e9c466ed24af614090ac42d6730a291608f69.zip
fsf-binutils-gdb-b07e9c466ed24af614090ac42d6730a291608f69.tar.gz
fsf-binutils-gdb-b07e9c466ed24af614090ac42d6730a291608f69.tar.bz2
Target FP: Remove unused floating-point routines
This patch removes the following routines, which now have no remaining users in GDB: - extract_typed_floating - store_typed_floating - convert_typed_floating - decimal_from_doublest - decimal_to_doublest - value_as_double - unpack_double - value_from_double - value_from_decfloat This completes removal of DOUBLEST from all files except doublest.{c,h} and target-float.c. gdb/ChangeLog: 2017-11-06 Ulrich Weigand <uweigand@de.ibm.com> * doublest.c: Do not include "gdbtypes.h". (extract_typed_floating): Remove. (store_typed_floating): Remove. (convert_typed_floating): Remove. * doublest.h (struct type): Remove. (DOUBLEST_PRINT_FORMAT): Remove. (DOUBLEST_SCAN_FORMAT): Remove. (extract_typed_floating): Remove. (store_typed_floating): Remove. (convert_typed_floating): Remove. * dfp.c (decimal_from_doublest): Remove. (decimal_to_doublest): Remove. * dfp.h: Do not include "doublest.h". (decimal_from_doublest): Remove. (decimal_to_doublest): Remove. * value.c: Do not include "doublest.h" and "dfp.h". (value_as_double): Remove. (unpack_double): Remove. (value_from_double): Remove. (value_from_decfloat): Remove. * value.h: Do not include "doublest.h". (value_as_double): Remove. (unpack_double): Remove. (value_from_double): Remove. (value_from_decfloat): Remove.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog30
-rw-r--r--gdb/dfp.c23
-rw-r--r--gdb/dfp.h5
-rw-r--r--gdb/doublest.c93
-rw-r--r--gdb/doublest.h13
-rw-r--r--gdb/value.c83
-rw-r--r--gdb/value.h7
7 files changed, 30 insertions, 224 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 617caae..2691367 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,35 @@
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
+ * doublest.c: Do not include "gdbtypes.h".
+ (extract_typed_floating): Remove.
+ (store_typed_floating): Remove.
+ (convert_typed_floating): Remove.
+ * doublest.h (struct type): Remove.
+ (DOUBLEST_PRINT_FORMAT): Remove.
+ (DOUBLEST_SCAN_FORMAT): Remove.
+ (extract_typed_floating): Remove.
+ (store_typed_floating): Remove.
+ (convert_typed_floating): Remove.
+
+ * dfp.c (decimal_from_doublest): Remove.
+ (decimal_to_doublest): Remove.
+ * dfp.h: Do not include "doublest.h".
+ (decimal_from_doublest): Remove.
+ (decimal_to_doublest): Remove.
+
+ * value.c: Do not include "doublest.h" and "dfp.h".
+ (value_as_double): Remove.
+ (unpack_double): Remove.
+ (value_from_double): Remove.
+ (value_from_decfloat): Remove.
+ * value.h: Do not include "doublest.h".
+ (value_as_double): Remove.
+ (unpack_double): Remove.
+ (value_from_double): Remove.
+ (value_from_decfloat): Remove.
+
+2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
+
* i386-tdep.c: Include "target-float.h". Do not include "doublest.h".
(i386_extract_return_value): Use target_float_convert.
(i386_store_return_value): Likewise.
diff --git a/gdb/dfp.c b/gdb/dfp.c
index d470268..ec05134 100644
--- a/gdb/dfp.c
+++ b/gdb/dfp.c
@@ -268,29 +268,6 @@ decimal_to_longest (const gdb_byte *from, int len, enum bfd_endian byte_order)
return strtoll (str.c_str (), NULL, 10);
}
-/* Converts a value of a float type to a decimal float of
- specified LEN bytes.
-
- This is an ugly way to do the conversion, but libdecnumber does
- not offer a direct way to do it. */
-void
-decimal_from_doublest (DOUBLEST from,
- gdb_byte *to, int len, enum bfd_endian byte_order)
-{
- std::string str = string_printf ("%.30" DOUBLEST_PRINT_FORMAT, from);
- decimal_from_string (to, len, byte_order, str);
-}
-
-/* Converts a decimal float of LEN bytes to a double value. */
-DOUBLEST
-decimal_to_doublest (const gdb_byte *from, int len, enum bfd_endian byte_order)
-{
- /* This is an ugly way to do the conversion, but libdecnumber does
- not offer a direct way to do it. */
- std::string str = decimal_to_string (from, len, byte_order);
- return strtod (str.c_str (), NULL);
-}
-
/* Perform operation OP with operands X and Y with sizes LEN_X and LEN_Y
and byte orders BYTE_ORDER_X and BYTE_ORDER_Y, and store value in
RESULT with size LEN_RESULT and byte order BYTE_ORDER_RESULT. */
diff --git a/gdb/dfp.h b/gdb/dfp.h
index e17f1ce..af52fa2 100644
--- a/gdb/dfp.h
+++ b/gdb/dfp.h
@@ -25,7 +25,6 @@
#ifndef DFP_H
#define DFP_H
-#include "doublest.h" /* For DOUBLEST. */
#include "expression.h" /* For enum exp_opcode. */
extern std::string decimal_to_string (const gdb_byte *, int, enum bfd_endian,
@@ -38,10 +37,6 @@ extern void decimal_from_ulongest (ULONGEST from, gdb_byte *to,
int len, enum bfd_endian byte_order);
extern LONGEST decimal_to_longest (const gdb_byte *from, int len,
enum bfd_endian byte_order);
-extern void decimal_from_doublest (DOUBLEST from, gdb_byte *to,
- int len, enum bfd_endian byte_order);
-extern DOUBLEST decimal_to_doublest (const gdb_byte *from, int len,
- enum bfd_endian byte_order);
extern void decimal_binop (enum exp_opcode,
const gdb_byte *, int, enum bfd_endian,
const gdb_byte *, int, enum bfd_endian,
diff --git a/gdb/doublest.c b/gdb/doublest.c
index 79c15fe..87d3b1f 100644
--- a/gdb/doublest.c
+++ b/gdb/doublest.c
@@ -26,7 +26,6 @@
#include "defs.h"
#include "doublest.h"
#include "floatformat.h"
-#include "gdbtypes.h"
#include <math.h> /* ldexp */
#include <algorithm>
@@ -897,95 +896,3 @@ floatformat_from_string (const struct floatformat *fmt, gdb_byte *out,
floatformat_from_doublest (fmt, &doub, out);
return true;
}
-
-/* Extract a floating-point number of type TYPE from a target-order
- byte-stream at ADDR. Returns the value as type DOUBLEST. */
-
-DOUBLEST
-extract_typed_floating (const void *addr, const struct type *type)
-{
- const struct floatformat *fmt = floatformat_from_type (type);
- DOUBLEST retval;
-
- floatformat_to_doublest (fmt, addr, &retval);
- return retval;
-}
-
-/* Store VAL as a floating-point number of type TYPE to a target-order
- byte-stream at ADDR. */
-
-void
-store_typed_floating (void *addr, const struct type *type, DOUBLEST val)
-{
- const struct floatformat *fmt = floatformat_from_type (type);
-
- /* FIXME: kettenis/2001-10-28: It is debatable whether we should
- zero out any remaining bytes in the target buffer when TYPE is
- longer than the actual underlying floating-point format. Perhaps
- we should store a fixed bitpattern in those remaining bytes,
- instead of zero, or perhaps we shouldn't touch those remaining
- bytes at all.
-
- NOTE: cagney/2001-10-28: With the way things currently work, it
- isn't a good idea to leave the end bits undefined. This is
- because GDB writes out the entire sizeof(<floating>) bits of the
- floating-point type even though the value might only be stored
- in, and the target processor may only refer to, the first N <
- TYPE_LENGTH (type) bits. If the end of the buffer wasn't
- initialized, GDB would write undefined data to the target. An
- errant program, refering to that undefined data, would then
- become non-deterministic.
-
- See also the function convert_typed_floating below. */
- memset (addr, 0, TYPE_LENGTH (type));
-
- floatformat_from_doublest (fmt, &val, addr);
-}
-
-/* Convert a floating-point number of type FROM_TYPE from a
- target-order byte-stream at FROM to a floating-point number of type
- TO_TYPE, and store it to a target-order byte-stream at TO. */
-
-void
-convert_typed_floating (const void *from, const struct type *from_type,
- void *to, const struct type *to_type)
-{
- const struct floatformat *from_fmt = floatformat_from_type (from_type);
- const struct floatformat *to_fmt = floatformat_from_type (to_type);
-
- if (from_fmt == NULL || to_fmt == NULL)
- {
- /* If we don't know the floating-point format of FROM_TYPE or
- TO_TYPE, there's not much we can do. We might make the
- assumption that if the length of FROM_TYPE and TO_TYPE match,
- their floating-point format would match too, but that
- assumption might be wrong on targets that support
- floating-point types that only differ in endianness for
- example. So we warn instead, and zero out the target buffer. */
- warning (_("Can't convert floating-point number to desired type."));
- memset (to, 0, TYPE_LENGTH (to_type));
- }
- else if (from_fmt == to_fmt)
- {
- /* We're in business. The floating-point format of FROM_TYPE
- and TO_TYPE match. However, even though the floating-point
- format matches, the length of the type might still be
- different. Make sure we don't overrun any buffers. See
- comment in store_typed_floating for a discussion about
- zeroing out remaining bytes in the target buffer. */
- memset (to, 0, TYPE_LENGTH (to_type));
- memcpy (to, from, std::min (TYPE_LENGTH (from_type),
- TYPE_LENGTH (to_type)));
- }
- else
- {
- /* The floating-point types don't match. The best we can do
- (apart from simulating the target FPU) is converting to the
- widest floating-point type supported by the host, and then
- again to the desired type. */
- DOUBLEST d;
-
- floatformat_to_doublest (from_fmt, from, &d);
- floatformat_from_doublest (to_fmt, &d, to);
- }
-}
diff --git a/gdb/doublest.h b/gdb/doublest.h
index 4b9d6bc..fe3f897 100644
--- a/gdb/doublest.h
+++ b/gdb/doublest.h
@@ -20,7 +20,6 @@
#ifndef DOUBLEST_H
#define DOUBLEST_H
-struct type;
struct floatformat;
/* Use `long double' if the host compiler supports it. (Note that this is not
@@ -35,12 +34,8 @@ struct floatformat;
#if (defined HAVE_LONG_DOUBLE && defined PRINTF_HAS_LONG_DOUBLE \
&& defined SCANF_HAS_LONG_DOUBLE)
typedef long double DOUBLEST;
-# define DOUBLEST_PRINT_FORMAT "Lg"
-# define DOUBLEST_SCAN_FORMAT "Lg"
#else
typedef double DOUBLEST;
-# define DOUBLEST_PRINT_FORMAT "g"
-# define DOUBLEST_SCAN_FORMAT "lg"
/* If we can't scan or print long double, we don't want to use it
anywhere. */
# undef HAVE_LONG_DOUBLE
@@ -81,12 +76,4 @@ extern bool floatformat_from_string (const struct floatformat *fmt,
extern size_t floatformat_totalsize_bytes (const struct floatformat *fmt);
-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);
-extern void convert_typed_floating (const void *from,
- const struct type *from_type,
- void *to, const struct type *to_type);
-
#endif
diff --git a/gdb/value.c b/gdb/value.c
index bc21113..8fd391e 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -28,10 +28,8 @@
#include "target.h"
#include "language.h"
#include "demangle.h"
-#include "doublest.h"
#include "regcache.h"
#include "block.h"
-#include "dfp.h"
#include "target-float.h"
#include "objfiles.h"
#include "valprint.h"
@@ -2764,18 +2762,6 @@ value_as_long (struct value *val)
return unpack_long (value_type (val), value_contents (val));
}
-DOUBLEST
-value_as_double (struct value *val)
-{
- DOUBLEST foo;
- int inv;
-
- foo = unpack_double (value_type (val), value_contents (val), &inv);
- if (inv)
- error (_("Invalid floating value found in program."));
- return foo;
-}
-
/* Extract a value as a C pointer. Does not deallocate the value.
Note that val's type may not actually be a pointer; value_as_long
handles all the cases. */
@@ -2938,49 +2924,6 @@ unpack_long (struct type *type, const gdb_byte *valaddr)
return 0; /* Placate lint. */
}
-/* Return a double value from the specified type and address.
- INVP points to an int which is set to 0 for valid value,
- 1 for invalid value (bad float format). In either case,
- the returned double is OK to use. Argument is in target
- format, result is in host format. */
-
-DOUBLEST
-unpack_double (struct type *type, const gdb_byte *valaddr, int *invp)
-{
- enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
- enum type_code code;
- int len;
- int nosign;
-
- *invp = 0; /* Assume valid. */
- type = check_typedef (type);
- code = TYPE_CODE (type);
- len = TYPE_LENGTH (type);
- nosign = TYPE_UNSIGNED (type);
- if (code == TYPE_CODE_FLT)
- {
- if (!target_float_is_valid (valaddr, type))
- {
- *invp = 1;
- return 0.0;
- }
-
- return extract_typed_floating (valaddr, type);
- }
- else if (code == TYPE_CODE_DECFLOAT)
- return decimal_to_doublest (valaddr, len, byte_order);
- else if (nosign)
- {
- /* Unsigned -- be sure we compensate for signed LONGEST. */
- return (ULONGEST) unpack_long (type, valaddr);
- }
- else
- {
- /* Signed -- we are OK with unpack_long. */
- return unpack_long (type, valaddr);
- }
-}
-
/* Unpack raw data (copied from debugee, target byte order) at VALADDR
as a CORE_ADDR, assuming the raw data is described by type TYPE.
We don't assume any alignment for the raw data. Return value is in
@@ -3693,32 +3636,6 @@ value_from_contents (struct type *type, const gdb_byte *contents)
return result;
}
-struct value *
-value_from_double (struct type *type, DOUBLEST num)
-{
- struct value *val = allocate_value (type);
- struct type *base_type = check_typedef (type);
- enum type_code code = TYPE_CODE (base_type);
-
- if (code == TYPE_CODE_FLT)
- {
- store_typed_floating (value_contents_raw (val), base_type, num);
- }
- else
- error (_("Unexpected type encountered for floating constant."));
-
- return val;
-}
-
-struct value *
-value_from_decfloat (struct type *type, const gdb_byte *dec)
-{
- struct value *val = allocate_value (type);
-
- memcpy (value_contents_raw (val), dec, TYPE_LENGTH (type));
- return val;
-}
-
/* Extract a value from the history file. Input will be of the form
$digits or $$digits. See block comment above 'write_dollar_variable'
for details. */
diff --git a/gdb/value.h b/gdb/value.h
index 237d5db..b1b8c6d 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -20,7 +20,6 @@
#if !defined (VALUE_H)
#define VALUE_H 1
-#include "doublest.h"
#include "frame.h" /* For struct frame_id. */
struct block;
@@ -613,12 +612,9 @@ extern int print_address_demangle (const struct value_print_options *,
extern bool is_floating_value (struct value *val);
extern LONGEST value_as_long (struct value *val);
-extern DOUBLEST value_as_double (struct value *val);
extern CORE_ADDR value_as_address (struct value *val);
extern LONGEST unpack_long (struct type *type, const gdb_byte *valaddr);
-extern DOUBLEST unpack_double (struct type *type, const gdb_byte *valaddr,
- int *invp);
extern CORE_ADDR unpack_pointer (struct type *type, const gdb_byte *valaddr);
extern LONGEST unpack_field_as_long (struct type *type,
@@ -644,9 +640,6 @@ extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num);
extern struct value *value_from_longest (struct type *type, LONGEST num);
extern struct value *value_from_ulongest (struct type *type, ULONGEST num);
extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
-extern struct value *value_from_double (struct type *type, DOUBLEST num);
-extern struct value *value_from_decfloat (struct type *type,
- const gdb_byte *decbytes);
extern struct value *value_from_history_ref (const char *, const char **);
extern struct value *value_from_component (struct value *, struct type *,
LONGEST);