return 0;
}
+bool
+default_dwarf2_omit_typedef_p (struct type *target_type, const char *producer,
+ const char *name)
+{
+ return false;
+}
+
/* Non-zero if we want to trace architecture code. */
#ifndef GDBARCH_DEBUG
extern CORE_ADDR default_get_return_buf_addr (struct type *val_typegdbarch,
frame_info_ptr cur_frame);
+/* Default implementation of gdbaarch default_dwarf2_omit_typedef_p method. */
+extern bool default_dwarf2_omit_typedef_p (struct type *target_type,
+ const char *producer,
+ const char *name);
+
extern enum return_value_convention default_gdbarch_return_value
(struct gdbarch *gdbarch, struct value *function, struct type *valtype,
struct regcache *regcache, struct value **read_value,
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
extern CORE_ADDR gdbarch_get_return_buf_addr (struct gdbarch *gdbarch, struct type *val_type, frame_info_ptr cur_frame);
extern void set_gdbarch_get_return_buf_addr (struct gdbarch *gdbarch, gdbarch_get_return_buf_addr_ftype *get_return_buf_addr);
+/* Return true if the typedef record needs to be replaced.".
+
+ Return 0 by default */
+
+typedef bool (gdbarch_dwarf2_omit_typedef_p_ftype) (struct type *target_type, const char *producer, const char *name);
+extern bool gdbarch_dwarf2_omit_typedef_p (struct gdbarch *gdbarch, struct type *target_type, const char *producer, const char *name);
+extern void set_gdbarch_dwarf2_omit_typedef_p (struct gdbarch *gdbarch, gdbarch_dwarf2_omit_typedef_p_ftype *dwarf2_omit_typedef_p);
+
/* Return true if the return value of function is stored in the first hidden
parameter. In theory, this feature should be language-dependent, specified
by language and its ABI, such as C++. Unfortunately, compiler may
gdbarch_return_value_ftype *return_value = nullptr;
gdbarch_return_value_as_value_ftype *return_value_as_value = default_gdbarch_return_value;
gdbarch_get_return_buf_addr_ftype *get_return_buf_addr = default_get_return_buf_addr;
+ gdbarch_dwarf2_omit_typedef_p_ftype *dwarf2_omit_typedef_p = default_dwarf2_omit_typedef_p;
gdbarch_return_in_first_hidden_param_p_ftype *return_in_first_hidden_param_p = default_return_in_first_hidden_param_p;
gdbarch_skip_prologue_ftype *skip_prologue = nullptr;
gdbarch_skip_main_prologue_ftype *skip_main_prologue = nullptr;
if ((gdbarch->return_value_as_value == default_gdbarch_return_value) == (gdbarch->return_value == nullptr))
log.puts ("\n\treturn_value_as_value");
/* Skip verify of get_return_buf_addr, invalid_p == 0 */
+ /* Skip verify of dwarf2_omit_typedef_p, invalid_p == 0 */
/* Skip verify of return_in_first_hidden_param_p, invalid_p == 0 */
if (gdbarch->skip_prologue == 0)
log.puts ("\n\tskip_prologue");
gdb_printf (file,
"gdbarch_dump: get_return_buf_addr = <%s>\n",
host_address_to_string (gdbarch->get_return_buf_addr));
+ gdb_printf (file,
+ "gdbarch_dump: dwarf2_omit_typedef_p = <%s>\n",
+ host_address_to_string (gdbarch->dwarf2_omit_typedef_p));
gdb_printf (file,
"gdbarch_dump: return_in_first_hidden_param_p = <%s>\n",
host_address_to_string (gdbarch->return_in_first_hidden_param_p));
gdbarch->get_return_buf_addr = get_return_buf_addr;
}
+bool
+gdbarch_dwarf2_omit_typedef_p (struct gdbarch *gdbarch, struct type *target_type, const char *producer, const char *name)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->dwarf2_omit_typedef_p != NULL);
+ if (gdbarch_debug >= 2)
+ gdb_printf (gdb_stdlog, "gdbarch_dwarf2_omit_typedef_p called\n");
+ return gdbarch->dwarf2_omit_typedef_p (target_type, producer, name);
+}
+
+void
+set_gdbarch_dwarf2_omit_typedef_p (struct gdbarch *gdbarch,
+ gdbarch_dwarf2_omit_typedef_p_ftype dwarf2_omit_typedef_p)
+{
+ gdbarch->dwarf2_omit_typedef_p = dwarf2_omit_typedef_p;
+}
+
int
gdbarch_return_in_first_hidden_param_p (struct gdbarch *gdbarch, struct type *type)
{
invalid=False,
)
+
+# The DWARF info currently does not distinquish between IEEE 128-bit floating
+# point values and the IBM 128-bit floating point format. GCC has an internal
+# hack to identify the IEEE 128-bit floating point value. The long double is a
+# defined base type in C. The GCC hack uses a typedef for long double to
+# reference_Float128 base to identify the long double as and IEEE 128-bit
+# value. The following method is used to "fix" the long double type to be a
+# base type with the IEEE float format info from the _Float128 basetype and
+# the long double name. With the fix, the proper name is printed for the
+# GDB typedef command.
+Function(
+ comment="""
+Return true if the typedef record needs to be replaced.".
+
+Return 0 by default""",
+ type="bool",
+ name="dwarf2_omit_typedef_p",
+ params=[("struct type *", "target_type"), ("const char *", "producer"),
+ ("const char *", "name")],
+ predefault="default_dwarf2_omit_typedef_p",
+ invalid=False,
+)
+
Method(
comment="""
Return true if the return value of function is stored in the first hidden
#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"
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
/* 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);