From c1a398a320f46905eaf6f520dddc441791861dcb Mon Sep 17 00:00:00 2001 From: Carl Love Date: Thu, 23 Mar 2023 18:23:05 -0400 Subject: 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. --- gdb/dwarf2/read.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'gdb/dwarf2') diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 8f35b973f3e..29a95cb8b2f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -14721,14 +14721,29 @@ static struct type * read_typedef (struct die_info *die, struct dwarf2_cu *cu) { struct objfile *objfile = cu->per_objfile->objfile; - const char *name = NULL; - struct type *this_type, *target_type; + const char *name = dwarf2_full_name (NULL, die, cu); + struct type *this_type; + struct gdbarch *gdbarch = objfile->arch (); + struct type *target_type = die_type (die, cu); + + if (gdbarch_dwarf2_omit_typedef_p (gdbarch, target_type, cu->producer, name)) + { + /* The long double is defined as a base type in C. GCC creates a long + double typedef with target-type _Float128 for the long double to + identify it as the IEEE Float128 value. This is a GCC hack since the + DWARF doesn't distinquish between the IBM long double and IEEE + 128-bit float. Replace the GCC workaround for the long double + typedef with the actual type information copied from the target-type + with the correct long double base type name. */ + this_type = copy_type (target_type); + this_type->set_name (name); + set_die_type (die, this_type, cu); + return this_type; + } - name = dwarf2_full_name (NULL, die, cu); this_type = type_allocator (objfile).new_type (TYPE_CODE_TYPEDEF, 0, name); this_type->set_target_is_stub (true); set_die_type (die, this_type, cu); - target_type = die_type (die, cu); if (target_type != this_type) this_type->set_target_type (target_type); else -- cgit v1.2.1