aboutsummaryrefslogtreecommitdiff
path: root/gdb/ppc-linux-tdep.c
diff options
context:
space:
mode:
authorCarl Love <cel@us.ibm.com>2023-03-23 18:23:05 -0400
committerCarl Love <cel@us.ibm.com>2023-04-18 11:03:08 -0400
commitc1a398a320f46905eaf6f520dddc441791861dcb (patch)
treecc83eb566cd1183ca7e6d94c6a755d997a2987a4 /gdb/ppc-linux-tdep.c
parenta02676b77d84d8229b5d4b01259535234cded19e (diff)
downloadbinutils-c1a398a320f46905eaf6f520dddc441791861dcb.zip
binutils-c1a398a320f46905eaf6f520dddc441791861dcb.tar.gz
binutils-c1a398a320f46905eaf6f520dddc441791861dcb.tar.bz2
PowerPC: fix _Float128 type output string
PowerPC supports two 128-bit floating point formats, the IBM long double and IEEE 128-bit float. The issue is the DWARF information does not distinguish between the two. There have been proposals of how to extend the DWARF information as discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104194 but has not been fully implemented. GCC introduced the _Float128 internal type as a work around for the issue. The workaround is not transparent to GDB. The internal _Float128 type name is printed rather then the user specified long double type. This patch adds a new gdbarch method to allow PowerPC to detect the GCC workaround. The workaround checks for "_Float128" name when reading the base typedef from the die_info. If the workaround is detected, the type and format fields from the _Float128 typedef are copied to the long double typedef. The same is done for the complex long double typedef. This patch fixes 74 regression test failures in gdb.base/whatis-ptype-typedefs.exp on PowerPC with IEEE float 128 as the default on GCC. It fixes one regression test failure in gdb.base/complex-parts.exp. The patch has been tested on Power 10 where GCC defaults to IEEE Float 128-bit and on Power 10 where GCC defaults to the IBM 128-bit float. The patch as also been tested on X86-64 with no new regression failures.
Diffstat (limited to 'gdb/ppc-linux-tdep.c')
-rw-r--r--gdb/ppc-linux-tdep.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index fcddb20..784dafa 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -62,6 +62,7 @@
#include "user-regs.h"
#include <ctype.h>
#include "elf-bfd.h"
+#include "producer.h"
#include "features/rs6000/powerpc-32l.c"
#include "features/rs6000/powerpc-altivec32l.c"
@@ -2006,6 +2007,38 @@ ppc_floatformat_for_type (struct gdbarch *gdbarch,
return default_floatformat_for_type (gdbarch, name, len);
}
+static bool
+linux_dwarf2_omit_typedef_p (struct type *target_type,
+ const char *producer, const char *name)
+{
+ int gcc_major, gcc_minor;
+
+ if (producer_is_gcc (producer, &gcc_major, &gcc_minor))
+ {
+ if ((target_type->code () == TYPE_CODE_FLT
+ || target_type->code () == TYPE_CODE_COMPLEX)
+ && (strcmp (name, "long double") == 0
+ || strcmp (name, "complex long double") == 0))
+ {
+ /* IEEE 128-bit floating point and IBM long double are two
+ encodings for 128-bit values. The DWARF debug data can't
+ distinguish between them. See bugzilla:
+ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104194
+
+ A GCC hack was introduced to still allow the debugger to identify
+ the case where "long double" uses the IEEE 128-bit floating point
+ format: GCC will emit a bogus DWARF type record pretending that
+ "long double" is a typedef alias for the _Float128 type.
+
+ This hack should not be visible to the GDB user, so we replace
+ this bogus typedef by a normal floating-point type, copying the
+ format information from the target type of the bogus typedef. */
+ return true;
+ }
+ }
+ return false;
+}
+
/* Specify the powerpc64le target triplet.
This can be variations of
ppc64le-{distro}-linux-gcc
@@ -2083,6 +2116,9 @@ ppc_linux_init_abi (struct gdbarch_info info,
/* Support for floating-point data type variants. */
set_gdbarch_floatformat_for_type (gdbarch, ppc_floatformat_for_type);
+ /* Support for replacing typedef record. */
+ set_gdbarch_dwarf2_omit_typedef_p (gdbarch, linux_dwarf2_omit_typedef_p);
+
/* Handle inferior calls during interrupted system calls. */
set_gdbarch_write_pc (gdbarch, ppc_linux_write_pc);