aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2002-02-04 02:22:41 +0000
committerAndrew Cagney <cagney@redhat.com>2002-02-04 02:22:41 +0000
commita73c86fb732868e52699b4dc05bcb6134db9f6df (patch)
treeb07b3d280ab66f67b585b7bbc11d5b54d9d9814b /gdb
parentacf5ed49a0160dd452b2004034b847912f23940b (diff)
downloadgdb-a73c86fb732868e52699b4dc05bcb6134db9f6df.zip
gdb-a73c86fb732868e52699b4dc05bcb6134db9f6df.tar.gz
gdb-a73c86fb732868e52699b4dc05bcb6134db9f6df.tar.bz2
* valprint.c (print_floating): Allow non TYPE_CODE_FLT types.
Restore behavour broken by 2002-01-20 Andrew Cagney <ac131313@redhat.com> IEEE_FLOAT removal.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/valprint.c32
2 files changed, 25 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index be9fe6d..4f54eb3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2002-02-03 Andrew Cagney <ac131313@redhat.com>
+
+ * valprint.c (print_floating): Allow non TYPE_CODE_FLT types.
+ Restore behavour broken by 2002-01-20 Andrew Cagney
+ <ac131313@redhat.com> IEEE_FLOAT removal.
+
2002-02-03 Daniel Jacobowitz <drow@mvista.com>
* c-valprint.c (c_val_print): Pass a proper valaddr to
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 84cd272..5f2c1762 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -540,18 +540,21 @@ longest_to_int (LONGEST arg)
return (rtnval);
}
-/* Print a floating point value of type TYPE, pointed to in GDB by
- VALADDR, on STREAM. */
+/* Print a floating point value of type TYPE (not always a
+ TYPE_CODE_FLT), pointed to in GDB by VALADDR, on STREAM. */
void
print_floating (char *valaddr, struct type *type, struct ui_file *stream)
{
DOUBLEST doub;
int inv;
- const struct floatformat *fmt = floatformat_from_type (type);
+ const struct floatformat *fmt = NULL;
unsigned len = TYPE_LENGTH (type);
- if (floatformat_is_nan (fmt, valaddr))
+ /* If it is a floating-point, check for obvious problems. */
+ if (TYPE_CODE (type) == TYPE_CODE_FLT)
+ fmt = floatformat_from_type (type);
+ if (fmt != NULL && floatformat_is_nan (fmt, valaddr))
{
if (floatformat_is_negative (fmt, valaddr))
fprintf_filtered (stream, "-");
@@ -563,12 +566,14 @@ print_floating (char *valaddr, struct type *type, struct ui_file *stream)
return;
}
- /* FIXME: cagney/2002-01-15: The simpler extract_typed_floating()
- routine could be used here only that routine has no way of
- indicating that the floating point it extracted was invalid (As
- indicated by INVALID_FLOAT). Instead, this code here could call
- something like floating_invalid() to check for an invalid
- floating point. */
+ /* NOTE: cagney/2002-01-15: The TYPE passed into print_floating()
+ isn't necessarily a TYPE_CODE_FLT. Consequently, unpack_double
+ needs to be used as that takes care of any necessary type
+ conversions. Such conversions are of course direct to DOUBLEST
+ and disregard any possible target floating point limitations.
+ For instance, a u64 would be converted and displayed exactly on a
+ host with 80 bit DOUBLEST but with loss of information on a host
+ with 64 bit DOUBLEST. */
doub = unpack_double (type, valaddr, &inv);
if (inv)
@@ -580,9 +585,10 @@ print_floating (char *valaddr, struct type *type, struct ui_file *stream)
/* FIXME: kettenis/2001-01-20: The following code makes too much
assumptions about the host and target floating point format. */
- /* FIXME: cagney/2002-01-15: The floatformat pointed to by FMT
- should contain all the information needed to print the
- floating-point value without host dependencies. */
+ /* NOTE: cagney/2002-02-03: Since the TYPE of what was passed in may
+ not necessarially be a TYPE_CODE_FLT, the below ignores that and
+ instead uses the type's length to determine the precision of the
+ floating-point value being printed. */
if (len < sizeof (double))
fprintf_filtered (stream, "%.9g", (double) doub);