/* Intel 386 target-dependent stuff.
- Copyright (C) 1988-2022 Free Software Foundation, Inc.
+ Copyright (C) 1988-2023 Free Software Foundation, Inc.
This file is part of GDB.
if (struct_convention == pcc_struct_convention
|| (struct_convention == default_struct_convention
- && tdep->struct_return == pcc_struct_return))
+ && tdep->struct_return == pcc_struct_return)
+ || TYPE_HAS_DYNAMIC_LENGTH (type))
return 0;
/* Structures consisting of a single `float', `double' or 'long
static enum return_value_convention
i386_return_value (struct gdbarch *gdbarch, struct value *function,
struct type *type, struct regcache *regcache,
- gdb_byte *readbuf, const gdb_byte *writebuf)
+ struct value **read_value, const gdb_byte *writebuf)
{
enum type_code code = type->code ();
a record, so the convention applied to records also applies
to arrays. */
- if (readbuf)
+ if (read_value != nullptr)
{
ULONGEST addr;
regcache_raw_read_unsigned (regcache, I386_EAX_REGNUM, &addr);
- read_memory (addr, readbuf, type->length ());
+ *read_value = value_at_non_lval (type, addr);
}
return RETURN_VALUE_ABI_RETURNS_ADDRESS;
here. */
if (code == TYPE_CODE_STRUCT && type->num_fields () == 1)
{
- type = check_typedef (type->field (0).type ());
- return i386_return_value (gdbarch, function, type, regcache,
- readbuf, writebuf);
+ struct type *inner_type = check_typedef (type->field (0).type ());
+ enum return_value_convention result
+ = i386_return_value (gdbarch, function, inner_type, regcache,
+ read_value, writebuf);
+ if (read_value != nullptr)
+ deprecated_set_value_type (*read_value, type);
+ return result;
}
- if (readbuf)
- i386_extract_return_value (gdbarch, type, regcache, readbuf);
+ if (read_value != nullptr)
+ {
+ *read_value = allocate_value (type);
+ i386_extract_return_value (gdbarch, type, regcache,
+ value_contents_raw (*read_value).data ());
+ }
if (writebuf)
i386_store_return_value (gdbarch, type, regcache, writebuf);
status = regcache->raw_read (fpnum, raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 0,
- value_type (result_value)->length ());
+ result_value->type ()->length ());
else
memcpy (buf, raw_buf, register_size (gdbarch, regnum));
}
status = regcache->raw_read (gpnum, raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 0,
- value_type (result_value)->length ());
+ result_value->type ()->length ());
else
memcpy (buf, raw_buf, 2);
}
status = regcache->raw_read (gpnum % 4, raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 0,
- value_type (result_value)->length ());
+ result_value->type ()->length ());
else if (gpnum >= 4)
memcpy (buf, raw_buf + 1, 1);
else
static struct gdbarch *
i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
const struct target_desc *tdesc;
int mm0_regnum;
int ymm0_regnum;
return arches->gdbarch;
/* Allocate space for the new architecture. Assume i386 for now. */
- i386_gdbarch_tdep *tdep = new i386_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new i386_gdbarch_tdep));
+ i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
/* General-purpose registers. */
tdep->gregset_reg_offset = NULL;
set_gdbarch_register_to_value (gdbarch, i386_register_to_value);
set_gdbarch_value_to_register (gdbarch, i386_value_to_register);
- set_gdbarch_return_value (gdbarch, i386_return_value);
+ set_gdbarch_return_value_as_value (gdbarch, i386_return_value);
set_gdbarch_skip_prologue (gdbarch, i386_skip_prologue);
appended to the list first, so that it supercedes the DWARF
unwinder in function epilogues (where the DWARF unwinder
currently fails). */
- frame_unwind_append_unwinder (gdbarch, &i386_epilogue_frame_unwind);
+ if (info.bfd_arch_info->bits_per_word == 32)
+ frame_unwind_append_unwinder (gdbarch, &i386_epilogue_frame_unwind);
/* Hook in the DWARF CFI frame unwinder. This unwinder is appended
to the list before the prologue-based unwinders, so that DWARF
if (!i386_validate_tdesc_p (tdep, tdesc_data.get ()))
{
- delete tdep;
gdbarch_free (gdbarch);
return NULL;
}
tdep-> bnd0_regnum = -1;
/* Hook in the legacy prologue-based unwinders last (fallback). */
- frame_unwind_append_unwinder (gdbarch, &i386_stack_tramp_frame_unwind);
- frame_unwind_append_unwinder (gdbarch, &i386_sigtramp_frame_unwind);
- frame_unwind_append_unwinder (gdbarch, &i386_frame_unwind);
+ if (info.bfd_arch_info->bits_per_word == 32)
+ {
+ frame_unwind_append_unwinder (gdbarch, &i386_stack_tramp_frame_unwind);
+ frame_unwind_append_unwinder (gdbarch, &i386_sigtramp_frame_unwind);
+ frame_unwind_append_unwinder (gdbarch, &i386_frame_unwind);
+ }
/* If we have a register mapping, enable the generic core file
support, unless it has already been enabled. */