/* Target-dependent code for the Motorola 88000 series.
- Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2004-2016 Free Software Foundation, Inc.
This file is part of GDB.
#include "symtab.h"
#include "trad-frame.h"
#include "value.h"
-
-#include "gdb_assert.h"
-#include "gdb_string.h"
+#include <algorithm>
#include "m88k-tdep.h"
/* Fetch the instruction at PC. */
static unsigned long
-m88k_fetch_instruction (CORE_ADDR pc)
+m88k_fetch_instruction (CORE_ADDR pc, enum bfd_endian byte_order)
{
- return read_memory_unsigned_integer (pc, 4);
+ return read_memory_unsigned_integer (pc, 4, byte_order);
}
/* Register information. */
}
/* Return the GDB type object for the "standard" data type of data in
- register REGNUM. */
+ register REGNUM. */
static struct type *
m88k_register_type (struct gdbarch *gdbarch, int regnum)
if (regnum == M88K_R30_REGNUM || regnum == M88K_R31_REGNUM)
return builtin_type (gdbarch)->builtin_data_ptr;
- return builtin_type_int32;
+ return builtin_type (gdbarch)->builtin_int32;
}
\f
m88k_store_arguments (struct regcache *regcache, int nargs,
struct value **args, CORE_ADDR sp)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
int num_register_words = 0;
int num_stack_words = 0;
int i;
if (m88k_integral_or_pointer_p (type) && len < 4)
{
- args[i] = value_cast (builtin_type_int32, args[i]);
+ args[i] = value_cast (builtin_type (gdbarch)->builtin_int32,
+ args[i]);
type = value_type (args[i]);
len = TYPE_LENGTH (type);
}
from WRITEBUF into REGCACHE. */
static enum return_value_convention
-m88k_return_value (struct gdbarch *gdbarch, struct type *func_type,
+m88k_return_value (struct gdbarch *gdbarch, struct value *function,
struct type *type, struct regcache *regcache,
gdb_byte *readbuf, const gdb_byte *writebuf)
{
prologue. */
static CORE_ADDR
-m88k_analyze_prologue (CORE_ADDR pc, CORE_ADDR limit,
+m88k_analyze_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR pc, CORE_ADDR limit,
struct m88k_frame_cache *cache)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR end = limit;
/* Provide a dummy cache if necessary. */
if (cache == NULL)
{
- size_t sizeof_saved_regs =
- (M88K_R31_REGNUM + 1) * sizeof (struct trad_frame_saved_reg);
-
- cache = alloca (sizeof (struct m88k_frame_cache));
- cache->saved_regs = alloca (sizeof_saved_regs);
+ cache = XALLOCA (struct m88k_frame_cache);
+ cache->saved_regs =
+ XALLOCAVEC (struct trad_frame_saved_reg, M88K_R31_REGNUM + 1);
/* We only initialize the members we care about. */
cache->saved_regs[M88K_R1_REGNUM].addr = -1;
while (pc < limit)
{
struct m88k_prologue_insn *pi = m88k_prologue_insn_table;
- unsigned long insn = m88k_fetch_instruction (pc);
+ unsigned long insn = m88k_fetch_instruction (pc, byte_order);
while ((insn & pi->mask) != pi->insn)
pi++;
prologue. */
if (cache->fp_offset != -1
&& cache->saved_regs[M88K_R1_REGNUM].addr != -1)
- return min (pc, end);
+ return std::min (pc, end);
break;
case M88K_PIA_NOTE_ST:
/* If no frame has been allocated, the stores aren't part of
the prologue. */
if (cache->sp_offset == 0)
- return min (pc, end);
+ return std::min (pc, end);
/* Record location of saved registers. */
{
/* A second stack pointer adjustment isn't part of the
prologue. */
if (cache->sp_offset != 0)
- return min (pc, end);
+ return std::min (pc, end);
/* Store stack pointer adjustment. */
cache->sp_offset = -SUBU_OFFSET (insn);
/* A second frame pointer assignment isn't part of the
prologue. */
if (cache->fp_offset != -1)
- return min (pc, end);
+ return std::min (pc, end);
/* Record frame pointer assignment. */
cache->fp_offset = ADDU_OFFSET (insn);
the instruction in the delay slot might be. Limit the
prologue analysis to the delay slot and record the branch
instruction as the end of the prologue. */
- limit = min (limit, pc + 2 * M88K_INSN_SIZE);
+ limit = std::min (limit, pc + 2 * M88K_INSN_SIZE);
end = pc;
break;
case M88K_PIA_NOTE_PROLOGUE_END:
- return min (pc, end);
+ return std::min (pc, end);
}
pc += M88K_INSN_SIZE;
return sal.end;
}
- return m88k_analyze_prologue (pc, pc + m88k_max_prologue_size, NULL);
+ return m88k_analyze_prologue (gdbarch, pc, pc + m88k_max_prologue_size,
+ NULL);
}
static struct m88k_frame_cache *
m88k_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct m88k_frame_cache *cache;
CORE_ADDR frame_sp;
if (*this_cache)
- return *this_cache;
+ return (struct m88k_frame_cache *) *this_cache;
cache = FRAME_OBSTACK_ZALLOC (struct m88k_frame_cache);
cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
cache->pc = get_frame_func (this_frame);
if (cache->pc != 0)
- m88k_analyze_prologue (cache->pc, get_frame_pc (this_frame), cache);
+ m88k_analyze_prologue (gdbarch, cache->pc, get_frame_pc (this_frame),
+ cache);
/* Calculate the stack pointer used in the prologue. */
if (cache->fp_offset != -1)
static const struct frame_unwind m88k_frame_unwind =
{
NORMAL_FRAME,
+ default_frame_unwind_stop_reason,
m88k_frame_this_id,
m88k_frame_prev_register,
NULL,
struct regcache *regcache,
int regnum, const void *gregs, size_t len)
{
- const gdb_byte *regs = gregs;
+ const gdb_byte *regs = (const gdb_byte *) gregs;
int i;
for (i = 0; i < M88K_NUM_REGS; i++)
/* Motorola 88000 register set. */
-static struct regset m88k_gregset =
+static const struct regset m88k_gregset =
{
NULL,
m88k_supply_gregset
};
-/* Return the appropriate register set for the core section identified
- by SECT_NAME and SECT_SIZE. */
+/* Iterate over supported core file register note sections. */
-static const struct regset *
-m88k_regset_from_core_section (struct gdbarch *gdbarch,
- const char *sect_name, size_t sect_size)
+static void
+m88k_iterate_over_regset_sections (struct gdbarch *gdbarch,
+ iterate_over_regset_sections_cb *cb,
+ void *cb_data,
+ const struct regcache *regcache)
{
- if (strcmp (sect_name, ".reg") == 0 && sect_size >= M88K_NUM_REGS * 4)
- return &m88k_gregset;
-
- return NULL;
+ cb (".reg", M88K_NUM_REGS * 4, &m88k_gregset, NULL, cb_data);
}
\f
set_gdbarch_pc_regnum (gdbarch, M88K_SXIP_REGNUM);
/* Core file support. */
- set_gdbarch_regset_from_core_section
- (gdbarch, m88k_regset_from_core_section);
+ set_gdbarch_iterate_over_regset_sections
+ (gdbarch, m88k_iterate_over_regset_sections);
set_gdbarch_print_insn (gdbarch, print_insn_m88k);
set_gdbarch_push_dummy_call (gdbarch, m88k_push_dummy_call);
set_gdbarch_dummy_id (gdbarch, m88k_dummy_id);
- /* Return value info */
+ /* Return value info. */
set_gdbarch_return_value (gdbarch, m88k_return_value);
set_gdbarch_addr_bits_remove (gdbarch, m88k_addr_bits_remove);