|
|
a094f6 |
commit 00d5215ecec4fa0a78dcc37fec9425593753eb66
|
|
|
a094f6 |
Author: Ulrich Weigand <ulrich.weigand@de.ibm.com>
|
|
|
a094f6 |
Date: Tue Sep 6 17:33:15 2016 +0200
|
|
|
a094f6 |
|
|
|
a094f6 |
Support 128-bit IEEE floating-point types on Intel and Power
|
|
|
a094f6 |
|
|
|
a094f6 |
Now that all the prerequisites are in place, this commit finally adds support
|
|
|
a094f6 |
for handling the __float128 type on Intel and Power, by providing appropriate
|
|
|
a094f6 |
platform-specific versions of the floatformat_for_type callback.
|
|
|
a094f6 |
|
|
|
a094f6 |
Since at this point we do not yet have any indication in the debug info to
|
|
|
a094f6 |
distinguish different floating-point formats of the same length, we simply
|
|
|
a094f6 |
use the type name as hint. Types named "__float128" get the IEEE format.
|
|
|
a094f6 |
In addition to handling "__float128" itself, we also recognize "_Float128"
|
|
|
a094f6 |
and (on Power) "_Float64x", as well as the complex versions of those.
|
|
|
a094f6 |
(As pointed out by Joseph Myers, starting with GCC 7, __float128 is just
|
|
|
a094f6 |
a typedef for _Float128 -- but it's good to handle this anyway.)
|
|
|
a094f6 |
|
|
|
a094f6 |
A new test case does some simple verification that the format is decoded
|
|
|
a094f6 |
correctly, using both __float128 and "long double" to make sure using both
|
|
|
a094f6 |
in the same file still works. Another new test verifies handling of the
|
|
|
a094f6 |
_FloatN and _FloatNx types supported by GCC 7, as well as the complex
|
|
|
a094f6 |
versions of those types.
|
|
|
a094f6 |
|
|
|
a094f6 |
Note that this still only supports basic format decoding and encoding.
|
|
|
a094f6 |
We do not yet support the GNU extension 'g' suffix for __float128 constants.
|
|
|
a094f6 |
In addition, since all *arithmetic* on floating-point values is still
|
|
|
a094f6 |
performed in native host "long double" arithmetic, if that format is not
|
|
|
a094f6 |
able to encode all target __float128 values, we may get incorrect results.
|
|
|
a094f6 |
(To fix this would require implementing fully synthetic target floating-
|
|
|
a094f6 |
point arithmetic along the lines of GCC's real.c, presumably using MPFR.)
|
|
|
a094f6 |
|
|
|
a094f6 |
gdb/ChangeLog:
|
|
|
a094f6 |
|
|
|
a094f6 |
* i386-tdep.c (i386_floatformat_for_type): New function.
|
|
|
a094f6 |
(i386_gdbarch_init): Install it.
|
|
|
a094f6 |
* ppc-linux-tdep.c (ppc_floatformat_for_type): New function.
|
|
|
a094f6 |
(ppc_linux_init_abi): Install it.
|
|
|
a094f6 |
|
|
|
a094f6 |
gdb/testsuite/ChangeLog:
|
|
|
a094f6 |
|
|
|
a094f6 |
* gdb.base/float128.c: New file.
|
|
|
a094f6 |
* gdb.base/float128.exp: Likewise.
|
|
|
a094f6 |
* gdb.base/floatn.c: Likewise.
|
|
|
a094f6 |
* gdb.base/floatn.exp: Likewise.
|
|
|
a094f6 |
|
|
|
a094f6 |
Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
|
|
|
a094f6 |
|
|
|
a094f6 |
### a/gdb/ChangeLog
|
|
|
a094f6 |
### b/gdb/ChangeLog
|
|
|
a094f6 |
## -1,5 +1,12 @@
|
|
|
a094f6 |
2016-09-05 Ulrich Weigand <uweigand@de.ibm.com>
|
|
|
a094f6 |
|
|
|
a094f6 |
+ * i386-tdep.c (i386_floatformat_for_type): New function.
|
|
|
a094f6 |
+ (i386_gdbarch_init): Install it.
|
|
|
a094f6 |
+ * ppc-linux-tdep.c (ppc_floatformat_for_type): New function.
|
|
|
a094f6 |
+ (ppc_linux_init_abi): Install it.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+2016-09-05 Ulrich Weigand <uweigand@de.ibm.com>
|
|
|
a094f6 |
+
|
|
|
a094f6 |
* gdbarch.sh (floatformat_for_type): New gdbarch callback.
|
|
|
a094f6 |
* gdbarch.h, gdbarch.c: Re-generate.
|
|
|
a094f6 |
* arch-utils.h (default_floatformat_for_type): New prototype.
|
|
|
a094f6 |
Index: gdb-7.6.1/gdb/i386-tdep.c
|
|
|
a094f6 |
===================================================================
|
|
|
a094f6 |
--- gdb-7.6.1.orig/gdb/i386-tdep.c 2017-03-11 22:05:54.267721188 +0100
|
|
|
a094f6 |
+++ gdb-7.6.1/gdb/i386-tdep.c 2017-03-11 22:07:59.209585676 +0100
|
|
|
a094f6 |
@@ -7495,6 +7495,23 @@
|
|
|
a094f6 |
}
|
|
|
a094f6 |
}
|
|
|
a094f6 |
|
|
|
a094f6 |
+/* Return a floating-point format for a floating-point variable of
|
|
|
a094f6 |
+ length LEN in bits. If non-NULL, NAME is the name of its type.
|
|
|
a094f6 |
+ If no suitable type is found, return NULL. */
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+static const struct floatformat **
|
|
|
a094f6 |
+i386_floatformat_for_type (struct gdbarch *gdbarch,
|
|
|
a094f6 |
+ const char *name, int len)
|
|
|
a094f6 |
+{
|
|
|
a094f6 |
+ if (len == 128 && name)
|
|
|
a094f6 |
+ if (strcmp (name, "__float128") == 0
|
|
|
a094f6 |
+ || strcmp (name, "_Float128") == 0
|
|
|
a094f6 |
+ || strcmp (name, "complex _Float128") == 0)
|
|
|
a094f6 |
+ return floatformats_ia64_quad;
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ return default_floatformat_for_type (gdbarch, name, len);
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
static int
|
|
|
a094f6 |
i386_validate_tdesc_p (struct gdbarch_tdep *tdep,
|
|
|
a094f6 |
struct tdesc_arch_data *tdesc_data)
|
|
|
a094f6 |
@@ -7640,6 +7657,9 @@
|
|
|
a094f6 |
alignment. */
|
|
|
a094f6 |
set_gdbarch_long_double_bit (gdbarch, 96);
|
|
|
a094f6 |
|
|
|
a094f6 |
+ /* Support for floating-point data type variants. */
|
|
|
a094f6 |
+ set_gdbarch_floatformat_for_type (gdbarch, i386_floatformat_for_type);
|
|
|
a094f6 |
+
|
|
|
a094f6 |
/* Register numbers of various important registers. */
|
|
|
a094f6 |
set_gdbarch_sp_regnum (gdbarch, I386_ESP_REGNUM); /* %esp */
|
|
|
a094f6 |
set_gdbarch_pc_regnum (gdbarch, I386_EIP_REGNUM); /* %eip */
|
|
|
a094f6 |
Index: gdb-7.6.1/gdb/ppc-linux-tdep.c
|
|
|
a094f6 |
===================================================================
|
|
|
a094f6 |
--- gdb-7.6.1.orig/gdb/ppc-linux-tdep.c 2017-03-11 22:05:54.267721188 +0100
|
|
|
a094f6 |
+++ gdb-7.6.1/gdb/ppc-linux-tdep.c 2017-03-11 22:08:14.080688571 +0100
|
|
|
a094f6 |
@@ -1691,6 +1691,25 @@
|
|
|
a094f6 |
record_tdep->ioctl_FIOQSIZE = 0x40086680;
|
|
|
a094f6 |
}
|
|
|
a094f6 |
|
|
|
a094f6 |
+/* Return a floating-point format for a floating-point variable of
|
|
|
a094f6 |
+ length LEN in bits. If non-NULL, NAME is the name of its type.
|
|
|
a094f6 |
+ If no suitable type is found, return NULL. */
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+static const struct floatformat **
|
|
|
a094f6 |
+ppc_floatformat_for_type (struct gdbarch *gdbarch,
|
|
|
a094f6 |
+ const char *name, int len)
|
|
|
a094f6 |
+{
|
|
|
a094f6 |
+ if (len == 128 && name)
|
|
|
a094f6 |
+ if (strcmp (name, "__float128") == 0
|
|
|
a094f6 |
+ || strcmp (name, "_Float128") == 0
|
|
|
a094f6 |
+ || strcmp (name, "_Float64x") == 0
|
|
|
a094f6 |
+ || strcmp (name, "complex _Float128") == 0
|
|
|
a094f6 |
+ || strcmp (name, "complex _Float64x") == 0)
|
|
|
a094f6 |
+ return floatformats_ia64_quad;
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ return default_floatformat_for_type (gdbarch, name, len);
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
static void
|
|
|
a094f6 |
ppc_linux_init_abi (struct gdbarch_info info,
|
|
|
a094f6 |
struct gdbarch *gdbarch)
|
|
|
a094f6 |
@@ -1713,6 +1732,9 @@
|
|
|
a094f6 |
set_gdbarch_long_double_bit (gdbarch, 16 * TARGET_CHAR_BIT);
|
|
|
a094f6 |
set_gdbarch_long_double_format (gdbarch, floatformats_ibm_long_double);
|
|
|
a094f6 |
|
|
|
a094f6 |
+ /* Support for floating-point data type variants. */
|
|
|
a094f6 |
+ set_gdbarch_floatformat_for_type (gdbarch, ppc_floatformat_for_type);
|
|
|
a094f6 |
+
|
|
|
a094f6 |
/* Handle inferior calls during interrupted system calls. */
|
|
|
a094f6 |
set_gdbarch_write_pc (gdbarch, ppc_linux_write_pc);
|
|
|
a094f6 |
|
|
|
a094f6 |
Index: gdb-7.6.1/gdb/testsuite/gdb.base/float128.c
|
|
|
a094f6 |
===================================================================
|
|
|
a094f6 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
a094f6 |
+++ gdb-7.6.1/gdb/testsuite/gdb.base/float128.c 2017-03-11 22:07:59.210585683 +0100
|
|
|
a094f6 |
@@ -0,0 +1,30 @@
|
|
|
a094f6 |
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ Copyright 2016 Free Software Foundation, Inc.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
a094f6 |
+ it under the terms of the GNU General Public License as published by
|
|
|
a094f6 |
+ the Free Software Foundation; either version 3 of the License, or
|
|
|
a094f6 |
+ (at your option) any later version.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ This program is distributed in the hope that it will be useful,
|
|
|
a094f6 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a094f6 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
a094f6 |
+ GNU General Public License for more details.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ You should have received a copy of the GNU General Public License
|
|
|
a094f6 |
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+#include <stdio.h>
|
|
|
a094f6 |
+#include <stdlib.h>
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+long double ld;
|
|
|
a094f6 |
+__float128 f128;
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+int main()
|
|
|
a094f6 |
+{
|
|
|
a094f6 |
+ ld = 1.375l;
|
|
|
a094f6 |
+ f128 = 2.375q;
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ return 0;
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
Index: gdb-7.6.1/gdb/testsuite/gdb.base/float128.exp
|
|
|
a094f6 |
===================================================================
|
|
|
a094f6 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
a094f6 |
+++ gdb-7.6.1/gdb/testsuite/gdb.base/float128.exp 2017-03-11 22:07:59.211585690 +0100
|
|
|
a094f6 |
@@ -0,0 +1,76 @@
|
|
|
a094f6 |
+# Copyright 2016 Free Software Foundation, Inc.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
a094f6 |
+# it under the terms of the GNU General Public License as published by
|
|
|
a094f6 |
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
a094f6 |
+# (at your option) any later version.
|
|
|
a094f6 |
+#
|
|
|
a094f6 |
+# This program is distributed in the hope that it will be useful,
|
|
|
a094f6 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a094f6 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
a094f6 |
+# GNU General Public License for more details.
|
|
|
a094f6 |
+#
|
|
|
a094f6 |
+# You should have received a copy of the GNU General Public License
|
|
|
a094f6 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# This file is part of the gdb testsuite. It is intended to test that
|
|
|
a094f6 |
+# gdb could correctly handle floating point constant with a suffix.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+standard_testfile .c
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+proc do_compile { {opts {}} } {
|
|
|
a094f6 |
+ global srcdir subdir srcfile binfile
|
|
|
a094f6 |
+ set ccopts {debug quiet}
|
|
|
a094f6 |
+ foreach opt $opts {lappend ccopts "additional_flags=$opt"}
|
|
|
a094f6 |
+ gdb_compile "${srcdir}/${subdir}/${srcfile}" "$binfile" executable $ccopts
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+if { [do_compile] != "" && [do_compile {-mfloat128}] != "" } {
|
|
|
a094f6 |
+ untested "compiler can't handle __float128 type?"
|
|
|
a094f6 |
+ return -1
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+clean_restart ${binfile}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+if ![runto_main] then {
|
|
|
a094f6 |
+ perror "couldn't run to breakpoint"
|
|
|
a094f6 |
+ continue
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# Run to the breakpoint at return.
|
|
|
a094f6 |
+gdb_breakpoint [gdb_get_line_number "return"]
|
|
|
a094f6 |
+gdb_continue_to_breakpoint "return"
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# Print the original value of ld and f128
|
|
|
a094f6 |
+gdb_test "print ld" ".* = 1\\.375.*" "The original value of ld is 1.375"
|
|
|
a094f6 |
+gdb_test "print f128" ".* = 2\\.375.*" "The original value of f128 is 2.375"
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# Test that gdb could correctly recognize float constant expression with a suffix.
|
|
|
a094f6 |
+# FIXME: gdb does not yet recognize the GNU extension 'q' suffix for __float128 constants.
|
|
|
a094f6 |
+gdb_test "print ld=-1.375l" ".* = -1\\.375.*" "Try to change ld to -1.375 with 'print ld=-1.375l'"
|
|
|
a094f6 |
+gdb_test "print f128=-2.375l" ".* = -2\\.375.*" "Try to change f128 to -2.375 with 'print f128=-2.375l'"
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# Test that gdb could handle the above correctly with "set var" command.
|
|
|
a094f6 |
+set test "set variable ld=10.375l"
|
|
|
a094f6 |
+gdb_test_multiple "set var ld=10.375l" "$test" {
|
|
|
a094f6 |
+ -re "$gdb_prompt $" {
|
|
|
a094f6 |
+ pass "$test"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+ -re "Invalid number.*$gdb_prompt $" {
|
|
|
a094f6 |
+ fail "$test (do not recognize 10.375l)"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+set test "set variable f128=20.375l"
|
|
|
a094f6 |
+gdb_test_multiple "set var f128=20.375l" "$test" {
|
|
|
a094f6 |
+ -re "$gdb_prompt $" {
|
|
|
a094f6 |
+ pass "$test"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+ -re "Invalid number.*$gdb_prompt $" {
|
|
|
a094f6 |
+ fail "$test (do not recognize 20.375l)"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+gdb_test "print ld" ".* = 10\\.375.*" "The value of ld is changed to 10.375"
|
|
|
a094f6 |
+gdb_test "print f128" ".* = 20\\.375.*" "The value of f128 is changed to 20.375"
|
|
|
a094f6 |
+
|
|
|
a094f6 |
Index: gdb-7.6.1/gdb/testsuite/gdb.base/floatn.c
|
|
|
a094f6 |
===================================================================
|
|
|
a094f6 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
a094f6 |
+++ gdb-7.6.1/gdb/testsuite/gdb.base/floatn.c 2017-03-11 22:07:59.211585690 +0100
|
|
|
a094f6 |
@@ -0,0 +1,48 @@
|
|
|
a094f6 |
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ Copyright 2016 Free Software Foundation, Inc.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
a094f6 |
+ it under the terms of the GNU General Public License as published by
|
|
|
a094f6 |
+ the Free Software Foundation; either version 3 of the License, or
|
|
|
a094f6 |
+ (at your option) any later version.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ This program is distributed in the hope that it will be useful,
|
|
|
a094f6 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a094f6 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
a094f6 |
+ GNU General Public License for more details.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ You should have received a copy of the GNU General Public License
|
|
|
a094f6 |
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+#include <stdio.h>
|
|
|
a094f6 |
+#include <stdlib.h>
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+_Float32 f32;
|
|
|
a094f6 |
+_Float64 f64;
|
|
|
a094f6 |
+_Float128 f128;
|
|
|
a094f6 |
+_Float32x f32x;
|
|
|
a094f6 |
+_Float64x f64x;
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+_Complex _Float32 c32;
|
|
|
a094f6 |
+_Complex _Float64 c64;
|
|
|
a094f6 |
+_Complex _Float128 c128;
|
|
|
a094f6 |
+_Complex _Float32x c32x;
|
|
|
a094f6 |
+_Complex _Float64x c64x;
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+int main()
|
|
|
a094f6 |
+{
|
|
|
a094f6 |
+ f32 = 1.5f32;
|
|
|
a094f6 |
+ f64 = 2.25f64;
|
|
|
a094f6 |
+ f128 = 3.375f128;
|
|
|
a094f6 |
+ f32x = 10.5f32x;
|
|
|
a094f6 |
+ f64x = 20.25f64x;
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ c32 = 1.5f32 + 1.0if;
|
|
|
a094f6 |
+ c64 = 2.25f64 + 1.0if;
|
|
|
a094f6 |
+ c128 = 3.375f128 + 1.0if;
|
|
|
a094f6 |
+ c32x = 10.5f32x + 1.0if;
|
|
|
a094f6 |
+ c64x = 20.25f64x + 1.0if;
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ return 0;
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
Index: gdb-7.6.1/gdb/testsuite/gdb.base/floatn.exp
|
|
|
a094f6 |
===================================================================
|
|
|
a094f6 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
a094f6 |
+++ gdb-7.6.1/gdb/testsuite/gdb.base/floatn.exp 2017-03-11 22:07:59.211585690 +0100
|
|
|
a094f6 |
@@ -0,0 +1,124 @@
|
|
|
a094f6 |
+# Copyright 2016 Free Software Foundation, Inc.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
a094f6 |
+# it under the terms of the GNU General Public License as published by
|
|
|
a094f6 |
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
a094f6 |
+# (at your option) any later version.
|
|
|
a094f6 |
+#
|
|
|
a094f6 |
+# This program is distributed in the hope that it will be useful,
|
|
|
a094f6 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a094f6 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
a094f6 |
+# GNU General Public License for more details.
|
|
|
a094f6 |
+#
|
|
|
a094f6 |
+# You should have received a copy of the GNU General Public License
|
|
|
a094f6 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# This file is part of the gdb testsuite. It is intended to test that
|
|
|
a094f6 |
+# gdb could correctly handle floating point constant with a suffix.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+standard_testfile .c
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+proc do_compile { {opts {}} } {
|
|
|
a094f6 |
+ global srcdir subdir srcfile binfile
|
|
|
a094f6 |
+ set ccopts {debug quiet}
|
|
|
a094f6 |
+ foreach opt $opts {lappend ccopts "additional_flags=$opt"}
|
|
|
a094f6 |
+ gdb_compile "${srcdir}/${subdir}/${srcfile}" "$binfile" executable $ccopts
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+if { [do_compile] != "" && [do_compile {-mfloat128}] != "" } {
|
|
|
a094f6 |
+ untested "compiler can't handle _FloatN/_FloatNx types?"
|
|
|
a094f6 |
+ return -1
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+clean_restart ${binfile}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+if ![runto_main] then {
|
|
|
a094f6 |
+ perror "couldn't run to breakpoint"
|
|
|
a094f6 |
+ continue
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# Run to the breakpoint at return.
|
|
|
a094f6 |
+gdb_breakpoint [gdb_get_line_number "return"]
|
|
|
a094f6 |
+gdb_continue_to_breakpoint "return"
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# Print the original values of f32, f64, f128, f32x, f64x.
|
|
|
a094f6 |
+gdb_test "print f32" ".* = 1\\.5.*" "The original value of f32 is 1.5"
|
|
|
a094f6 |
+gdb_test "print f64" ".* = 2\\.25.*" "The original value of f64 is 2.25"
|
|
|
a094f6 |
+gdb_test "print f128" ".* = 3\\.375.*" "The original value of f128 is 3.375"
|
|
|
a094f6 |
+gdb_test "print f32x" ".* = 10\\.5.*" "The original value of f32x is 10.5"
|
|
|
a094f6 |
+gdb_test "print f64x" ".* = 20\\.25.*" "The original value of f64x is 20.25"
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# Test that gdb could correctly recognize float constant expression with a suffix.
|
|
|
a094f6 |
+# FIXME: gdb does not yet recognize the suffix for _FloatN/_FloatNx types.
|
|
|
a094f6 |
+gdb_test "print f32=-1.5" ".* = -1\\.5.*" "Try to change f32 to -1.5 with 'print f32=-1.5'"
|
|
|
a094f6 |
+gdb_test "print f64=-2.25" ".* = -2\\.25.*" "Try to change f64 to -2.25 with 'print f64=-2.25'"
|
|
|
a094f6 |
+gdb_test "print f128=-3.375" ".* = -3\\.375.*" "Try to change f128 to -3.375 with 'print f128=-3.375'"
|
|
|
a094f6 |
+gdb_test "print f32x=-10.5" ".* = -10\\.5.*" "Try to change f32x to -10.5 with 'print f32=-1.5x'"
|
|
|
a094f6 |
+gdb_test "print f64x=-20.25" ".* = -20\\.25.*" "Try to change f64x to -20.25 with 'print f64=-2.25x'"
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# Test that gdb could handle the above correctly with "set var" command.
|
|
|
a094f6 |
+set test "set variable f32 = 10.5"
|
|
|
a094f6 |
+gdb_test_multiple "set var f32=10.5" "$test" {
|
|
|
a094f6 |
+ -re "$gdb_prompt $" {
|
|
|
a094f6 |
+ pass "$test"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+ -re "Invalid number.*$gdb_prompt $" {
|
|
|
a094f6 |
+ fail "$test (do not recognize 10.5)"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+set test "set variable f64 = 20.25"
|
|
|
a094f6 |
+gdb_test_multiple "set var f64=20.25" "$test" {
|
|
|
a094f6 |
+ -re "$gdb_prompt $" {
|
|
|
a094f6 |
+ pass "$test"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+ -re "Invalid number.*$gdb_prompt $" {
|
|
|
a094f6 |
+ fail "$test (do not recognize 20.25)"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+set test "set variable f128 = 30.375"
|
|
|
a094f6 |
+gdb_test_multiple "set var f128=30.375" "$test" {
|
|
|
a094f6 |
+ -re "$gdb_prompt $" {
|
|
|
a094f6 |
+ pass "$test"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+ -re "Invalid number.*$gdb_prompt $" {
|
|
|
a094f6 |
+ fail "$test (do not recognize 30.375)"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+set test "set variable f32x = 100.5"
|
|
|
a094f6 |
+gdb_test_multiple "set var f32x=100.5" "$test" {
|
|
|
a094f6 |
+ -re "$gdb_prompt $" {
|
|
|
a094f6 |
+ pass "$test"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+ -re "Invalid number.*$gdb_prompt $" {
|
|
|
a094f6 |
+ fail "$test (do not recognize 100.5)"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+set test "set variable f64x = 200.25"
|
|
|
a094f6 |
+gdb_test_multiple "set var f64x=200.25" "$test" {
|
|
|
a094f6 |
+ -re "$gdb_prompt $" {
|
|
|
a094f6 |
+ pass "$test"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+ -re "Invalid number.*$gdb_prompt $" {
|
|
|
a094f6 |
+ fail "$test (do not recognize 200.25)"
|
|
|
a094f6 |
+ }
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+gdb_test "print f32" ".* = 10\\.5.*" "The value of f32 is changed to 10.5"
|
|
|
a094f6 |
+gdb_test "print f64" ".* = 20\\.25.*" "The value of f64 is changed to 20.25"
|
|
|
a094f6 |
+gdb_test "print f128" ".* = 30\\.375.*" "The value of f128 is changed to 30.375"
|
|
|
a094f6 |
+gdb_test "print f32x" ".* = 100\\.5.*" "The value of f32x is changed to 100.5"
|
|
|
a094f6 |
+gdb_test "print f64x" ".* = 200\\.25.*" "The value of f64x is changed to 200.25"
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# Print the original values of c32, c64, c128, c32x, c64x.
|
|
|
a094f6 |
+gdb_test "print c32" ".* = 1\\.5 \\+ 1 \\* I.*" "The original value of c32 is 1.5 + 1 * I"
|
|
|
a094f6 |
+gdb_test "print c64" ".* = 2\\.25 \\+ 1 \\* I.*" "The original value of c64 is 2.25 + 1 * I"
|
|
|
a094f6 |
+gdb_test "print c128" ".* = 3\\.375 \\+ 1 \\* I.*" "The original value of c128 is 3.375 + 1 * I"
|
|
|
a094f6 |
+gdb_test "print c32x" ".* = 10\\.5 \\+ 1 \\* I.*" "The original value of c32x is 10.5 + 1 * I"
|
|
|
a094f6 |
+gdb_test "print c64x" ".* = 20\\.25 \\+ 1 \\* I.*" "The original value of c64x is 20.25 + 1 * I"
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+# FIXME: GDB cannot parse non-trivial complex constants yet.
|
|
|
a094f6 |
+
|