aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2017-11-21 18:50:59 +0100
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2017-11-21 18:50:59 +0100
commited0f427344d0befead629d9267aecd01bfb72721 (patch)
tree28c66c138b903afe536bef7624c66ab70e8c06f2 /gdb/testsuite/gdb.arch
parenta25d69c6dcbabf3f6629b847246ffb4ddbc29472 (diff)
downloadgdb-ed0f427344d0befead629d9267aecd01bfb72721.zip
gdb-ed0f427344d0befead629d9267aecd01bfb72721.tar.gz
gdb-ed0f427344d0befead629d9267aecd01bfb72721.tar.bz2
[PowerPC] Detect different long double floating-point formats
Current versions of GCC support switching the format used for "long double" to either IBM double double or IEEE-128. The resulting binary is marked via different setting of the Tag_GNU_Power_ABI_FP GNU attribute. This patch checks this attribute to detect the format of the default "long double" type and sets GDB's notion of the format accordingly. The patch also adds support for the "__ibm128" type, which always uses IBM double double format independent of the format used for "long double". A new test case verifies that all three types, "long double", "__float128", and "__ibm128" are correctly detected in all three compiler settings, the default setting, -mabi=ieeelongdouble, and -mabi=ibmlongdouble. gdb/ChangeLog: 2017-11-21 Ulrich Weigand <uweigand@de.ibm.com> * ppc-tdep.h (enum powerpc_long_double_abi): New data type. (struct gdbarch_tdep): New member long_double_abi. * rs6000-tdep.c (rs6000_gdbarch_init): Initialize long_double_abi member of tdep struct based on Tag_GNU_Power_ABI_FP attribute. * ppc-linux-tdep.c (ppc_linux_init_abi): Install long double data format depending on long_double_abi tdep member. (ppc_floatformat_for_type): Handle __ibm128 type. gdb/testsuite/ChangeLog: 2017-11-21 Ulrich Weigand <uweigand@de.ibm.com> * gdb.arch/ppc-longdouble.exp: New file. * gdb.arch/ppc-longdouble.c: Likewise.
Diffstat (limited to 'gdb/testsuite/gdb.arch')
-rw-r--r--gdb/testsuite/gdb.arch/ppc-longdouble.c38
-rw-r--r--gdb/testsuite/gdb.arch/ppc-longdouble.exp58
2 files changed, 96 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.arch/ppc-longdouble.c b/gdb/testsuite/gdb.arch/ppc-longdouble.c
new file mode 100644
index 0000000..17296bf
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc-longdouble.c
@@ -0,0 +1,38 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+long double ld;
+__float128 float128;
+__ibm128 ibm128;
+
+/* FIXME: GCC will only emit a .gnu.attribute section specifying the
+ long double ABI if long double is used in a function prototype. */
+void test (long double x)
+{
+}
+
+int main()
+{
+ ld = 1.375l;
+ float128 = 2.375l;
+ ibm128 = 3.375l;
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/ppc-longdouble.exp b/gdb/testsuite/gdb.arch/ppc-longdouble.exp
new file mode 100644
index 0000000..66c8f54
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc-longdouble.exp
@@ -0,0 +1,58 @@
+# Copyright 2016-2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if ![istarget "powerpc*"] then {
+ verbose "Skipping powerpc long-double floating point tests."
+ return
+}
+
+standard_testfile
+
+proc do_test { name {opts {}} } {
+ global srcdir subdir srcfile binfile
+ set ccopts {debug quiet}
+ foreach opt $opts {lappend ccopts "additional_flags=$opt"}
+ set lines [gdb_compile "${srcdir}/${subdir}/${srcfile}" "$binfile.$name" executable $ccopts]
+ # We get this warning even with the nowarnings option ...
+ regsub -all "(^|\n)\[^\n\]*using \[^\n\]* extended precision long double" $lines "" lines
+ if { $lines != "" } then {
+ return
+ }
+
+ clean_restart ${binfile}.${name}
+
+ if ![runto_main] then {
+ return
+ }
+
+ # Run to the breakpoint at return.
+ gdb_breakpoint [gdb_get_line_number "return"]
+ gdb_continue_to_breakpoint "return"
+
+ # Print the value of ld
+ gdb_test "print ld" ".* = 1\\.375.*" "the value of ld is 1.375 ($name)"
+ # Print the value of float128
+ gdb_test "print float128" ".* = 2\\.375.*" "the value of float128 is 2.375 ($name)"
+ # Print the value of ibm128
+ gdb_test "print ibm128" ".* = 3\\.375.*" "the value of ibm128 is 3.375 ($name)"
+}
+
+# Verify that we correctly detect the floating-point format used for
+# long double. Re-run the test with -mabi=ieeelongdouble and mabi=ibmlongdouble
+
+do_test default { -mfloat128 }
+do_test ieee128 { -mfloat128 -mabi=ieeelongdouble }
+do_test ibm128 { -mfloat128 -mabi=ibmlongdouble }
+