aboutsummaryrefslogtreecommitdiff
path: root/gdb/doublest.c
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2016-09-06 17:31:53 +0200
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2016-09-06 17:31:53 +0200
commit9b790ce7227fa346d08a41462119e9a3e93f5e80 (patch)
treeb6e4e77409e5c0566b05548b01e3b1e700b72719 /gdb/doublest.c
parent49f190bcb7f074ea2e27d4e967e4fae9ed7dafb6 (diff)
downloadgdb-9b790ce7227fa346d08a41462119e9a3e93f5e80.zip
gdb-9b790ce7227fa346d08a41462119e9a3e93f5e80.tar.gz
gdb-9b790ce7227fa346d08a41462119e9a3e93f5e80.tar.bz2
Add gdbarch callback to provide formats for debug info float types
At this point, all TYPE_CODE_FLT types carry their floating-point format, except for those creating from reading DWARF or stabs debug info. Those will be addressed by this commit. The main issue here is that we actually have to determine which floating- point format to use. Currently, we only have the type length as input to this decision. In the future, we may hopefully get --at least in DWARF-- additional information to help disambiguate multiple different formats of the same length. For now, we can still look at the type name as a hint. This decision logic is encapsulated in a gdbarch callback to allow platform-specific overrides. The default implementation use the same logic (compare type length against the various gdbarch_..._bit sizes) that is currently implemented in floatformat_from_length. With this commit, all platforms still use the default logic, so there should be no actual change in behavior. A follow-on commit will add support for __float128 on Intel and Power. Once dwarf2read.c and stabsread.c make use of the new callback to determine floating-point formats, we're now sure every TYPE_CODE_FLT type will always carry its format. The commit therefore adds asserts to verify_floatformat to ensure new code will continue to always provide formats, and removes the code in floatformat_from_type that used to handle types with a NULL TYPE_FLOATFORMAT. gdb/ChangeLog: * gdbarch.sh (floatformat_for_type): New gdbarch callback. * gdbarch.h, gdbarch.c: Re-generate. * arch-utils.h (default_floatformat_for_type): New prototype. * arch-utils.c (default_floatformat_for_type): New function. * doublest.c (floatformat_from_length): Remove. (floatformat_from_type): Assume TYPE_FLOATFORMAT is non-NULL. * gdbtypes.c (verify_floatformat): Require non-NULL format. * dwarf2read.c (dwarf2_init_float_type): New function. (read_base_type): Use it. * stabsread.c (dbx_init_float_type): New function. (read_sun_floating_type): Use it. (read_range_type): Likewise. Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Diffstat (limited to 'gdb/doublest.c')
-rw-r--r--gdb/doublest.c55
1 files changed, 4 insertions, 51 deletions
diff --git a/gdb/doublest.c b/gdb/doublest.c
index 088037e..943a9f6 100644
--- a/gdb/doublest.c
+++ b/gdb/doublest.c
@@ -770,52 +770,8 @@ floatformat_from_doublest (const struct floatformat *fmt,
}
-/* Return a floating-point format for a floating-point variable of
- length LEN. If no suitable floating-point format is found, an
- error is thrown.
-
- We need this functionality since information about the
- floating-point format of a type is not always available to GDB; the
- debug information typically only tells us the size of a
- floating-point type.
-
- FIXME: kettenis/2001-10-28: In many places, particularly in
- target-dependent code, the format of floating-point types is known,
- but not passed on by GDB. This should be fixed. */
-
-static const struct floatformat *
-floatformat_from_length (struct gdbarch *gdbarch, int len)
-{
- const struct floatformat *format;
-
- if (len * TARGET_CHAR_BIT == gdbarch_half_bit (gdbarch))
- format = gdbarch_half_format (gdbarch)
- [gdbarch_byte_order (gdbarch)];
- else if (len * TARGET_CHAR_BIT == gdbarch_float_bit (gdbarch))
- format = gdbarch_float_format (gdbarch)
- [gdbarch_byte_order (gdbarch)];
- else if (len * TARGET_CHAR_BIT == gdbarch_double_bit (gdbarch))
- format = gdbarch_double_format (gdbarch)
- [gdbarch_byte_order (gdbarch)];
- else if (len * TARGET_CHAR_BIT == gdbarch_long_double_bit (gdbarch))
- format = gdbarch_long_double_format (gdbarch)
- [gdbarch_byte_order (gdbarch)];
- /* On i386 the 'long double' type takes 96 bits,
- while the real number of used bits is only 80,
- both in processor and in memory.
- The code below accepts the real bit size. */
- else if ((gdbarch_long_double_format (gdbarch) != NULL)
- && (len * TARGET_CHAR_BIT
- == gdbarch_long_double_format (gdbarch)[0]->totalsize))
- format = gdbarch_long_double_format (gdbarch)
- [gdbarch_byte_order (gdbarch)];
- else
- format = NULL;
- if (format == NULL)
- error (_("Unrecognized %d-bit floating-point type."),
- len * TARGET_CHAR_BIT);
- return format;
-}
+/* Return the floating-point format for a floating-point variable of
+ type TYPE. */
const struct floatformat *
floatformat_from_type (const struct type *type)
@@ -824,11 +780,8 @@ floatformat_from_type (const struct type *type)
const struct floatformat *fmt;
gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
- if (TYPE_FLOATFORMAT (type) != NULL)
- fmt = TYPE_FLOATFORMAT (type)[gdbarch_byte_order (gdbarch)];
- else
- fmt = floatformat_from_length (gdbarch, TYPE_LENGTH (type));
-
+ gdb_assert (TYPE_FLOATFORMAT (type));
+ fmt = TYPE_FLOATFORMAT (type)[gdbarch_byte_order (gdbarch)];
gdb_assert (TYPE_LENGTH (type) >= floatformat_totalsize_bytes (fmt));
return fmt;
}