/* Target-dependent code for AMD64.
- Copyright (C) 2001-2021 Free Software Foundation, Inc.
+ Copyright (C) 2001-2022 Free Software Foundation, Inc.
Contributed by Jiri Smid, SuSE Labs.
static int
amd64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
int ymm0_regnum = tdep->ymm0_regnum;
int regnum = -1;
static const char *
amd64_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
if (i386_byte_regnum_p (gdbarch, regnum))
return amd64_byte_names[regnum - tdep->al_regnum];
else if (i386_zmm_regnum_p (gdbarch, regnum))
readable_regcache *regcache,
int regnum)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
value *result_value = allocate_value (register_type (gdbarch, regnum));
VALUE_LVAL (result_value) = lval_register;
VALUE_REGNUM (result_value) = regnum;
- gdb_byte *buf = value_contents_raw (result_value);
+ gdb_byte *buf = value_contents_raw (result_value).data ();
if (i386_byte_regnum_p (gdbarch, regnum))
{
struct regcache *regcache,
int regnum, const gdb_byte *buf)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
if (i386_byte_regnum_p (gdbarch, regnum))
{
amd64_ax_pseudo_register_collect (struct gdbarch *gdbarch,
struct agent_expr *ax, int regnum)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
if (i386_byte_regnum_p (gdbarch, regnum))
{
for (int i = 0; i < type->num_fields (); i++)
{
struct type *subtype = check_typedef (type->field (i).type ());
- int bitpos = TYPE_FIELD_BITPOS (type, i);
/* Ignore static fields, empty fields (for example nested
empty structures), and bitfields (these are handled by
|| TYPE_FIELD_PACKED (type, i))
continue;
+ int bitpos = type->field (i).loc_bitpos ();
+
if (bitpos % 8 != 0)
return true;
unsigned int bitoffset)
{
struct type *subtype = check_typedef (type->field (i).type ());
- int bitpos = bitoffset + TYPE_FIELD_BITPOS (type, i);
- int pos = bitpos / 64;
enum amd64_reg_class subclass[2];
int bitsize = TYPE_FIELD_BITSIZE (type, i);
- int endpos;
if (bitsize == 0)
bitsize = TYPE_LENGTH (subtype) * 8;
- endpos = (bitpos + bitsize - 1) / 64;
/* Ignore static fields, or empty fields, for example nested
empty structures.*/
if (field_is_static (&type->field (i)) || bitsize == 0)
return;
+ int bitpos = bitoffset + type->field (i).loc_bitpos ();
+ int pos = bitpos / 64;
+ int endpos = (bitpos + bitsize - 1) / 64;
+
if (subtype->code () == TYPE_CODE_STRUCT
|| subtype->code () == TYPE_CODE_UNION)
{
static void
amd64_classify_aggregate (struct type *type, enum amd64_reg_class theclass[2])
{
- /* 1. If the size of an object is larger than two eightbytes, or it has
- unaligned fields, it has class memory. */
- if (TYPE_LENGTH (type) > 16 || amd64_has_unaligned_fields (type))
+ /* 1. If the size of an object is larger than two times eight bytes, or
+ it is a non-trivial C++ object, or it has unaligned fields, then it
+ has class memory.
+
+ It is important that the trivially_copyable check is before the
+ unaligned fields check, as C++ classes with virtual base classes
+ will have fields (for the virtual base classes) with non-constant
+ loc_bitpos attributes, which will cause an assert to trigger within
+ the unaligned field check. As classes with virtual bases are not
+ trivially copyable, checking that first avoids this problem. */
+ if (TYPE_LENGTH (type) > 16
+ || !language_pass_by_reference (type).trivially_copyable
+ || amd64_has_unaligned_fields (type))
{
theclass[0] = theclass[1] = AMD64_MEMORY;
return;
else
{
/* The argument will be passed in registers. */
- const gdb_byte *valbuf = value_contents (args[i]);
+ const gdb_byte *valbuf = value_contents (args[i]).data ();
gdb_byte buf[8];
gdb_assert (len <= 16);
for (i = 0; i < num_stack_args; i++)
{
struct type *type = value_type (stack_args[i]);
- const gdb_byte *valbuf = value_contents (stack_args[i]);
+ const gdb_byte *valbuf = value_contents (stack_args[i]).data ();
int len = TYPE_LENGTH (type);
write_memory (sp + element * 8, valbuf, len);
start_pc_sal = find_pc_sect_line (start_pc, NULL, 0);
if (start_pc_sal.symtab == NULL
- || producer_is_gcc_ge_4 (COMPUNIT_PRODUCER
- (SYMTAB_COMPUNIT (start_pc_sal.symtab))) < 6
+ || producer_is_gcc_ge_4 (start_pc_sal.symtab->compunit ()
+ ->producer ()) < 6
|| start_pc_sal.pc != start_pc || pc >= start_pc_sal.end)
return pc;
compilers to emit usable line notes. */
if (post_prologue_pc
&& (cust != NULL
- && COMPUNIT_PRODUCER (cust) != NULL
- && (producer_is_llvm (COMPUNIT_PRODUCER (cust))
- || producer_is_icc_ge_19 (COMPUNIT_PRODUCER (cust)))))
+ && cust->producer () != nullptr
+ && (producer_is_llvm (cust->producer ())
+ || producer_is_icc_ge_19 (cust->producer ()))))
return std::max (start_pc, post_prologue_pc);
}
amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct amd64_frame_cache *cache;
CORE_ADDR addr;
struct frame_info *this_frame,
void **this_cache)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
+ gdbarch *arch = get_frame_arch (this_frame);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch);
/* We shouldn't even bother if we don't have a sigcontext_addr
handler. */
struct compunit_symtab *cust;
cust = find_pc_compunit_symtab (pc);
- if (cust != NULL && COMPUNIT_EPILOGUE_UNWIND_VALID (cust))
+ if (cust != NULL && cust->epilogue_unwind_valid ())
return 0;
if (target_read_memory (pc, &insn, 1))
int regnum, const void *fpregs, size_t len)
{
struct gdbarch *gdbarch = regcache->arch ();
- const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ const i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
gdb_assert (len >= tdep->sizeof_fpregset);
amd64_supply_fxsave (regcache, regnum, fpregs);
int regnum, void *fpregs, size_t len)
{
struct gdbarch *gdbarch = regcache->arch ();
- const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ const i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
gdb_assert (len >= tdep->sizeof_fpregset);
amd64_collect_fxsave (regcache, regnum, fpregs);
gdb_byte buf[8];
CORE_ADDR jb_addr;
struct gdbarch *gdbarch = get_frame_arch (frame);
- int jb_pc_offset = gdbarch_tdep (gdbarch)->jb_pc_offset;
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ int jb_pc_offset = tdep->jb_pc_offset;
int len = TYPE_LENGTH (builtin_type (gdbarch)->builtin_func_ptr);
/* If JB_PC_OFFSET is -1, we have no way to find out where the
amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
const target_desc *default_tdesc)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
const struct target_desc *tdesc = info.target_desc;
static const char *const stap_integer_prefixes[] = { "$", NULL };
static const char *const stap_register_prefixes[] = { "%", NULL };
static struct type *
amd64_x32_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
switch (regnum - tdep->eax_regnum)
{
amd64_x32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
const target_desc *default_tdesc)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
amd64_init_abi (info, gdbarch, default_tdesc);
const void *fxsave)
{
struct gdbarch *gdbarch = regcache->arch ();
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
i387_supply_fxsave (regcache, regnum, fxsave);
const void *xsave)
{
struct gdbarch *gdbarch = regcache->arch ();
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
i387_supply_xsave (regcache, regnum, xsave);
void *fxsave)
{
struct gdbarch *gdbarch = regcache->arch ();
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
gdb_byte *regs = (gdb_byte *) fxsave;
i387_collect_fxsave (regcache, regnum, fxsave);
void *xsave, int gcore)
{
struct gdbarch *gdbarch = regcache->arch ();
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
gdb_byte *regs = (gdb_byte *) xsave;
i387_collect_xsave (regcache, regnum, xsave, gcore);