aboutsummaryrefslogtreecommitdiff
path: root/gdb/ppc-linux-tdep.c
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2016-09-06 17:33:15 +0200
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2016-09-06 17:33:15 +0200
commit00d5215ecec4fa0a78dcc37fec9425593753eb66 (patch)
tree42dbd7d002b2ecff6da919c309ad7a710c2fa215 /gdb/ppc-linux-tdep.c
parent9b790ce7227fa346d08a41462119e9a3e93f5e80 (diff)
downloadgdb-00d5215ecec4fa0a78dcc37fec9425593753eb66.zip
gdb-00d5215ecec4fa0a78dcc37fec9425593753eb66.tar.gz
gdb-00d5215ecec4fa0a78dcc37fec9425593753eb66.tar.bz2
Support 128-bit IEEE floating-point types on Intel and Power
Now that all the prerequisites are in place, this commit finally adds support for handling the __float128 type on Intel and Power, by providing appropriate platform-specific versions of the floatformat_for_type callback. Since at this point we do not yet have any indication in the debug info to distinguish different floating-point formats of the same length, we simply use the type name as hint. Types named "__float128" get the IEEE format. In addition to handling "__float128" itself, we also recognize "_Float128" and (on Power) "_Float64x", as well as the complex versions of those. (As pointed out by Joseph Myers, starting with GCC 7, __float128 is just a typedef for _Float128 -- but it's good to handle this anyway.) A new test case does some simple verification that the format is decoded correctly, using both __float128 and "long double" to make sure using both in the same file still works. Another new test verifies handling of the _FloatN and _FloatNx types supported by GCC 7, as well as the complex versions of those types. Note that this still only supports basic format decoding and encoding. We do not yet support the GNU extension 'g' suffix for __float128 constants. In addition, since all *arithmetic* on floating-point values is still performed in native host "long double" arithmetic, if that format is not able to encode all target __float128 values, we may get incorrect results. (To fix this would require implementing fully synthetic target floating- point arithmetic along the lines of GCC's real.c, presumably using MPFR.) gdb/ChangeLog: * i386-tdep.c (i386_floatformat_for_type): New function. (i386_gdbarch_init): Install it. * ppc-linux-tdep.c (ppc_floatformat_for_type): New function. (ppc_linux_init_abi): Install it. gdb/testsuite/ChangeLog: * gdb.base/float128.c: New file. * gdb.base/float128.exp: Likewise. * gdb.base/floatn.c: Likewise. * gdb.base/floatn.exp: Likewise. Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Diffstat (limited to 'gdb/ppc-linux-tdep.c')
-rw-r--r--gdb/ppc-linux-tdep.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index cde4f2e..ee158e3 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1628,6 +1628,25 @@ ppc_init_linux_record_tdep (struct linux_record_tdep *record_tdep,
record_tdep->ioctl_FIOQSIZE = 0x40086680;
}
+/* Return a floating-point format for a floating-point variable of
+ length LEN in bits. If non-NULL, NAME is the name of its type.
+ If no suitable type is found, return NULL. */
+
+const struct floatformat **
+ppc_floatformat_for_type (struct gdbarch *gdbarch,
+ const char *name, int len)
+{
+ if (len == 128 && name)
+ if (strcmp (name, "__float128") == 0
+ || strcmp (name, "_Float128") == 0
+ || strcmp (name, "_Float64x") == 0
+ || strcmp (name, "complex _Float128") == 0
+ || strcmp (name, "complex _Float64x") == 0)
+ return floatformats_ia64_quad;
+
+ return default_floatformat_for_type (gdbarch, name, len);
+}
+
static void
ppc_linux_init_abi (struct gdbarch_info info,
struct gdbarch *gdbarch)
@@ -1651,6 +1670,9 @@ ppc_linux_init_abi (struct gdbarch_info info,
set_gdbarch_long_double_bit (gdbarch, 16 * TARGET_CHAR_BIT);
set_gdbarch_long_double_format (gdbarch, floatformats_ibm_long_double);
+ /* Support for floating-point data type variants. */
+ set_gdbarch_floatformat_for_type (gdbarch, ppc_floatformat_for_type);
+
/* Handle inferior calls during interrupted system calls. */
set_gdbarch_write_pc (gdbarch, ppc_linux_write_pc);