diff options
author | Ulrich Weigand <ulrich.weigand@de.ibm.com> | 2016-09-06 17:31:53 +0200 |
---|---|---|
committer | Ulrich Weigand <ulrich.weigand@de.ibm.com> | 2016-09-06 17:31:53 +0200 |
commit | 9b790ce7227fa346d08a41462119e9a3e93f5e80 (patch) | |
tree | b6e4e77409e5c0566b05548b01e3b1e700b72719 /gdb/dwarf2read.c | |
parent | 49f190bcb7f074ea2e27d4e967e4fae9ed7dafb6 (diff) | |
download | gdb-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/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 746290e..40ee66d 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -14757,6 +14757,27 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu) return this_type; } +/* Allocate a floating-point type of size BITS and name NAME. Pass NAME_HINT + (which may be different from NAME) to the architecture back-end to allow + it to guess the correct format if necessary. */ + +static struct type * +dwarf2_init_float_type (struct objfile *objfile, int bits, const char *name, + const char *name_hint) +{ + struct gdbarch *gdbarch = get_objfile_arch (objfile); + const struct floatformat **format; + struct type *type; + + format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits); + if (format) + type = init_float_type (objfile, bits, name, format); + else + type = init_type (objfile, TYPE_CODE_ERROR, bits / TARGET_CHAR_BIT, name); + + return type; +} + /* Find a representation of a given base type and install it in the TYPE field of the die. */ @@ -14797,14 +14818,14 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) type = init_boolean_type (objfile, bits, 1, name); break; case DW_ATE_complex_float: - type = init_float_type (objfile, bits / 2, NULL, NULL); + type = dwarf2_init_float_type (objfile, bits / 2, NULL, name); type = init_complex_type (objfile, name, type); break; case DW_ATE_decimal_float: type = init_decfloat_type (objfile, bits, name); break; case DW_ATE_float: - type = init_float_type (objfile, bits, name, NULL); + type = dwarf2_init_float_type (objfile, bits, name, name); break; case DW_ATE_signed: type = init_integer_type (objfile, bits, 0, name); |