/* Target-dependent code for GDB, the GNU debugger.
- Copyright (C) 1986-2022 Free Software Foundation, Inc.
+ Copyright (C) 1986-2023 Free Software Foundation, Inc.
This file is part of GDB.
#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"
static enum return_value_convention
ppc_linux_return_value (struct gdbarch *gdbarch, struct value *function,
struct type *valtype, struct regcache *regcache,
- gdb_byte *readbuf, const gdb_byte *writebuf)
+ struct value **read_value, const gdb_byte *writebuf)
{
+ gdb_byte *readbuf = nullptr;
+ if (read_value != nullptr)
+ {
+ *read_value = value::allocate (valtype);
+ readbuf = (*read_value)->contents_raw ().data ();
+ }
+
if ((valtype->code () == TYPE_CODE_STRUCT
|| valtype->code () == TYPE_CODE_UNION)
- && !((TYPE_LENGTH (valtype) == 16 || TYPE_LENGTH (valtype) == 8)
+ && !((valtype->length () == 16 || valtype->length () == 8)
&& valtype->is_vector ()))
return RETURN_VALUE_STRUCT_CONVENTION;
else
stub sequence. */
static CORE_ADDR
-ppc_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
+ppc_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
{
unsigned int insnbuf[POWERPC32_PLT_CHECK_LEN];
struct gdbarch *gdbarch = get_frame_arch (frame);
- ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR target = 0;
int scan_limit, i;
const struct regset *
ppc_linux_cgprregset (struct gdbarch *gdbarch)
{
- ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
if (tdep->wordsize == 4)
{
int regnum, void *buf, size_t len)
{
struct gdbarch *gdbarch = regcache->arch ();
- ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
const struct regset *cgprregset = ppc_linux_cgprregset (gdbarch);
void *cb_data,
const struct regcache *regcache)
{
- ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
int have_altivec = tdep->ppc_vr0_regnum != -1;
int have_vsx = tdep->ppc_vsr0_upper_regnum != -1;
int have_ppr = tdep->ppc_ppr_regnum != -1;
}
static void
-ppc_linux_sigtramp_cache (struct frame_info *this_frame,
+ppc_linux_sigtramp_cache (frame_info_ptr this_frame,
struct trad_frame_cache *this_cache,
CORE_ADDR func, LONGEST offset,
int bias)
CORE_ADDR fpregs;
int i;
struct gdbarch *gdbarch = get_frame_arch (this_frame);
- ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
base = get_frame_register_unsigned (this_frame,
static void
ppc32_linux_sigaction_cache_init (const struct tramp_frame *self,
- struct frame_info *this_frame,
+ frame_info_ptr this_frame,
struct trad_frame_cache *this_cache,
CORE_ADDR func)
{
static void
ppc64_linux_sigaction_cache_init (const struct tramp_frame *self,
- struct frame_info *this_frame,
+ frame_info_ptr this_frame,
struct trad_frame_cache *this_cache,
CORE_ADDR func)
{
static void
ppc32_linux_sighandler_cache_init (const struct tramp_frame *self,
- struct frame_info *this_frame,
+ frame_info_ptr this_frame,
struct trad_frame_cache *this_cache,
CORE_ADDR func)
{
static void
ppc64_linux_sighandler_cache_init (const struct tramp_frame *self,
- struct frame_info *this_frame,
+ frame_info_ptr this_frame,
struct trad_frame_cache *this_cache,
CORE_ADDR func)
{
thread_info *thread)
{
struct regcache *regcache = get_thread_regcache (thread);
- ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* Make sure we're in a 32- or 64-bit machine */
else
result = gdb_sys_fstatat64;
}
+ else if (syscall == 317)
+ result = gdb_sys_pipe2;
else if (syscall == 336)
result = gdb_sys_recv;
else if (syscall == 337)
result = gdb_sys_recvfrom;
else if (syscall == 342)
result = gdb_sys_recvmsg;
+ else if (syscall == 359)
+ result = gdb_sys_getrandom;
return (enum gdb_syscall) result;
}
ppc_linux_syscall_record (struct regcache *regcache)
{
struct gdbarch *gdbarch = regcache->arch ();
- ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
ULONGEST scnum;
enum gdb_syscall syscall_gdb;
int ret;
const int SIGNAL_FRAMESIZE = 128;
const int sizeof_rt_sigframe = 1440 * 2 + 8 * 2 + 4 * 6 + 8 + 8 + 128 + 512;
ULONGEST sp;
- ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
int i;
for (i = 3; i <= 12; i++)
if (vsx)
features.vsx = true;
- CORE_ADDR hwcap = linux_get_hwcap (target);
+ gdb::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
+ CORE_ADDR hwcap = linux_get_hwcap (auxv, target, gdbarch);
features.isa205 = ppc_linux_has_isa205 (hwcap);
static void
ppc_elfv2_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym)
{
+ if ((sym->flags & BSF_SYNTHETIC) != 0)
+ /* ELFv2 synthetic symbols (the PLT stubs and the __glink_PLTresolve
+ trampoline) do not have a local entry point. */
+ return;
+
elf_symbol_type *elf_sym = (elf_symbol_type *)sym;
/* If the symbol is marked as having a local entry point, set a target
ppc_init_linux_record_tdep (struct linux_record_tdep *record_tdep,
int wordsize)
{
+ /* The values for TCGETS, TCSETS, TCSETSW, TCSETSF are based on the
+ size of struct termios in the kernel source.
+ include/uapi/asm-generic/termbits.h */
+#define SIZE_OF_STRUCT_TERMIOS 0x2c
+
/* Simply return if it had been initialized. */
if (record_tdep->size_pointer != 0)
return;
record_tdep->size_time_t = 4;
}
else
- internal_error (__FILE__, __LINE__, _("unexpected wordsize"));
+ internal_error (_("unexpected wordsize"));
/* These values are the second argument of system call "sys_fcntl"
and "sys_fcntl64". They are obtained from Linux Kernel source. */
/* These values are the second argument of system call "sys_ioctl".
They are obtained from Linux Kernel source.
See arch/powerpc/include/uapi/asm/ioctls.h. */
- record_tdep->ioctl_TCGETS = 0x403c7413;
- record_tdep->ioctl_TCSETS = 0x803c7414;
- record_tdep->ioctl_TCSETSW = 0x803c7415;
- record_tdep->ioctl_TCSETSF = 0x803c7416;
record_tdep->ioctl_TCGETA = 0x40147417;
record_tdep->ioctl_TCSETA = 0x80147418;
record_tdep->ioctl_TCSETAW = 0x80147419;
record_tdep->ioctl_TCSETAF = 0x8014741c;
+ record_tdep->ioctl_TCGETS = 0x40007413 | (SIZE_OF_STRUCT_TERMIOS << 16);
+ record_tdep->ioctl_TCSETS = 0x80007414 | (SIZE_OF_STRUCT_TERMIOS << 16);
+ record_tdep->ioctl_TCSETSW = 0x80007415 | (SIZE_OF_STRUCT_TERMIOS << 16);
+ record_tdep->ioctl_TCSETSF = 0x80007416 | (SIZE_OF_STRUCT_TERMIOS << 16);
+
record_tdep->ioctl_TCSBRK = 0x2000741d;
record_tdep->ioctl_TCXONC = 0x2000741e;
record_tdep->ioctl_TCFLSH = 0x2000741f;
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
ppc_linux_init_abi (struct gdbarch_info info,
struct gdbarch *gdbarch)
{
- ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
struct tdesc_arch_data *tdesc_data = info.tdesc_data;
static const char *const stap_integer_prefixes[] = { "i", NULL };
static const char *const stap_register_indirection_prefixes[] = { "(",
/* 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);
(well ignoring vectors that is). When this was corrected, it
wasn't fixed for GNU/Linux native platform. Use the
PowerOpen struct convention. */
- set_gdbarch_return_value (gdbarch, ppc_linux_return_value);
+ set_gdbarch_return_value_as_value (gdbarch, ppc_linux_return_value);
+ set_gdbarch_return_value (gdbarch, nullptr);
set_gdbarch_memory_remove_breakpoint (gdbarch,
ppc_linux_memory_remove_breakpoint);
powerpc_so_ops.in_dynsym_resolve_code =
powerpc_linux_in_dynsym_resolve_code;
}
- set_solib_ops (gdbarch, &powerpc_so_ops);
+ set_gdbarch_so_ops (gdbarch, &powerpc_so_ops);
set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
}