/* Target-dependent code for the Motorola 68000 series.
- Copyright (C) 1990-2022 Free Software Foundation, Inc.
+ Copyright (C) 1990-2023 Free Software Foundation, Inc.
This file is part of GDB.
m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
if (!tdep->m68881_ext_type)
- tdep->m68881_ext_type
- = arch_float_type (gdbarch, -1, "builtin_type_m68881_ext",
- floatformats_m68881_ext);
+ {
+ type_allocator alloc (gdbarch);
+ tdep->m68881_ext_type
+ = init_float_type (alloc, -1, "builtin_type_m68881_ext",
+ floatformats_m68881_ext);
+ }
return tdep->m68881_ext_type;
}
{
m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
- if (regnum < 0 || regnum >= ARRAY_SIZE (m68k_register_names))
- internal_error (__FILE__, __LINE__,
- _("m68k_register_name: illegal register number %d"),
- regnum);
- else if (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM
- && tdep->fpregs_present == 0)
+ gdb_static_assert (ARRAY_SIZE (m68k_register_names) == M68K_NUM_REGS);
+ if (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM
+ && tdep->fpregs_present == 0)
return "";
else
return m68k_register_names[regnum];
return its contents in TO. */
static int
-m68k_register_to_value (struct frame_info *frame, int regnum,
+m68k_register_to_value (frame_info_ptr frame, int regnum,
struct type *type, gdb_byte *to,
int *optimizedp, int *unavailablep)
{
REGNUM in frame FRAME. */
static void
-m68k_value_to_register (struct frame_info *frame, int regnum,
+m68k_value_to_register (frame_info_ptr frame, int regnum,
struct type *type, const gdb_byte *from)
{
gdb_byte to[M68K_MAX_REGISTER_SIZE];
m68k_extract_return_value (struct type *type, struct regcache *regcache,
gdb_byte *valbuf)
{
- int len = TYPE_LENGTH (type);
+ int len = type->length ();
gdb_byte buf[M68K_MAX_REGISTER_SIZE];
if (type->code () == TYPE_CODE_PTR && len == 4)
regcache->raw_read (M68K_D1_REGNUM, valbuf + (len - 4));
}
else
- internal_error (__FILE__, __LINE__,
- _("Cannot extract return value of %d bytes long."), len);
+ internal_error (_("Cannot extract return value of %d bytes long."), len);
}
static void
m68k_store_return_value (struct type *type, struct regcache *regcache,
const gdb_byte *valbuf)
{
- int len = TYPE_LENGTH (type);
+ int len = type->length ();
if (type->code () == TYPE_CODE_PTR && len == 4)
{
regcache->raw_write (M68K_D1_REGNUM, valbuf + (len - 4));
}
else
- internal_error (__FILE__, __LINE__,
- _("Cannot store return value of %d bytes long."), len);
+ internal_error (_("Cannot store return value of %d bytes long."), len);
}
static void
{
m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
enum type_code code = type->code ();
- int len = TYPE_LENGTH (type);
+ int len = type->length ();
gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
|| code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY);
const bool is_vector = code == TYPE_CODE_ARRAY && type->is_vector ();
if (is_vector
- && check_typedef (TYPE_TARGET_TYPE (type))->code () == TYPE_CODE_FLT)
+ && check_typedef (type->target_type ())->code () == TYPE_CODE_FLT)
return 0;
/* According to m68k_return_in_memory in the m68k GCC back-end,
if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
|| code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY)
&& !m68k_reg_struct_return_p (gdbarch, type))
- || (code == TYPE_CODE_FLT && TYPE_LENGTH (type) == 12))
+ || (code == TYPE_CODE_FLT && type->length () == 12))
{
/* The default on m68k is to return structures in static memory.
Consequently a function must return the address where we can
ULONGEST addr;
regcache_raw_read_unsigned (regcache, M68K_D0_REGNUM, &addr);
- read_memory (addr, readbuf, TYPE_LENGTH (type));
+ read_memory (addr, readbuf, type->length ());
}
return RETURN_VALUE_ABI_RETURNS_ADDRESS;
/* GCC may return a `long double' in memory too. */
|| (!tdep->float_return
&& code == TYPE_CODE_FLT
- && TYPE_LENGTH (type) == 12))
+ && type->length () == 12))
{
/* The System V ABI says that:
regcache_raw_read_unsigned (regcache, tdep->pointer_result_regnum,
&addr);
- read_memory (addr, readbuf, TYPE_LENGTH (type));
+ read_memory (addr, readbuf, type->length ());
}
return RETURN_VALUE_ABI_RETURNS_ADDRESS;
/* Push arguments in reverse order. */
for (i = nargs - 1; i >= 0; i--)
{
- struct type *value_type = value_enclosing_type (args[i]);
- int len = TYPE_LENGTH (value_type);
+ struct type *value_type = args[i]->enclosing_type ();
+ int len = value_type->length ();
int container_len = (len + 3) & ~3;
int offset;
else
offset = container_len - len;
sp -= container_len;
- write_memory (sp + offset, value_contents_all (args[i]).data (), len);
+ write_memory (sp + offset, args[i]->contents_all ().data (), len);
}
/* Store struct value address. */
}
static CORE_ADDR
-m68k_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
+m68k_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
{
gdb_byte buf[8];
/* Normal frames. */
static struct m68k_frame_cache *
-m68k_frame_cache (struct frame_info *this_frame, void **this_cache)
+m68k_frame_cache (frame_info_ptr this_frame, void **this_cache)
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
}
static void
-m68k_frame_this_id (struct frame_info *this_frame, void **this_cache,
+m68k_frame_this_id (frame_info_ptr this_frame, void **this_cache,
struct frame_id *this_id)
{
struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
}
static struct value *
-m68k_frame_prev_register (struct frame_info *this_frame, void **this_cache,
+m68k_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
int regnum)
{
struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
};
\f
static CORE_ADDR
-m68k_frame_base_address (struct frame_info *this_frame, void **this_cache)
+m68k_frame_base_address (frame_info_ptr this_frame, void **this_cache)
{
struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
};
static struct frame_id
-m68k_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
+m68k_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
{
CORE_ADDR fp;
This routine returns true on success. */
static int
-m68k_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
+m68k_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
{
gdb_byte *buf;
CORE_ADDR sp, jb_addr;
if (tdep->jb_pc < 0)
{
- internal_error (__FILE__, __LINE__,
- _("m68k_get_longjmp_target: not implemented"));
+ internal_error (_("m68k_get_longjmp_target: not implemented"));
return 0;
}
static struct gdbarch *
m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
- struct gdbarch *gdbarch;
struct gdbarch_list *best_arch;
tdesc_arch_data_up tdesc_data;
int i;
if (best_arch != NULL)
return best_arch->gdbarch;
- m68k_gdbarch_tdep *tdep = new m68k_gdbarch_tdep;
- gdbarch = gdbarch_alloc (&info, tdep);
+ gdbarch *gdbarch
+ = gdbarch_alloc (&info, gdbarch_tdep_up (new m68k_gdbarch_tdep));
+ m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+
tdep->fpregs_present = has_fp;
tdep->float_return = float_return;
tdep->flavour = flavour;