/* Target-dependent code for the S+core architecture, for GDB,
the GNU Debugger.
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2019 Free Software Foundation, Inc.
Contributed by Qinwei (qinwei@sunnorth.com.cn)
Contributed by Ching-Peng Lin (cplin@sunplus.com)
return builtin_type (gdbarch)->builtin_uint32;
}
-static CORE_ADDR
-score_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
-{
- return frame_unwind_register_unsigned (next_frame, SCORE_SP_REGNUM);
-}
-
-static CORE_ADDR
-score_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
-{
- return frame_unwind_register_unsigned (next_frame, SCORE_PC_REGNUM);
-}
-
static const char *
score7_register_name (struct gdbarch *gdbarch, int regnum)
{
}
#endif
-static int
-score_print_insn (bfd_vma memaddr, struct disassemble_info *info)
-{
- if (info->endian == BFD_ENDIAN_BIG)
- return print_insn_big_score (memaddr, info);
- else
- return print_insn_little_score (memaddr, info);
-}
-
static inst_t *
score7_fetch_inst (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *memblock)
{
return &inst;
}
-static const gdb_byte *
-score7_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
- int *lenptr)
+/* Implement the breakpoint_kind_from_pc gdbarch method. */
+
+static int
+score7_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
{
- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- gdb_byte buf[SCORE_INSTLEN] = { 0 };
int ret;
unsigned int raw;
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ gdb_byte buf[SCORE_INSTLEN] = { 0 };
if ((ret = target_read_memory (*pcptr & ~0x3, buf, SCORE_INSTLEN)) != 0)
{
error (_("Error: target_read_memory in file:%s, line:%d!"),
- __FILE__, __LINE__);
+ __FILE__, __LINE__);
}
raw = extract_unsigned_integer (buf, SCORE_INSTLEN, byte_order);
- if (byte_order == BFD_ENDIAN_BIG)
+ if (!(raw & 0x80008000))
{
- if (!(raw & 0x80008000))
- {
- /* 16bits instruction. */
- static gdb_byte big_breakpoint16[] = { 0x60, 0x02 };
- *pcptr &= ~0x1;
- *lenptr = sizeof (big_breakpoint16);
- return big_breakpoint16;
- }
+ /* 16bits instruction. */
+ *pcptr &= ~0x1;
+ return 2;
+ }
+ else
+ {
+ /* 32bits instruction. */
+ *pcptr &= ~0x3;
+ return 4;
+ }
+}
+
+/* Implement the sw_breakpoint_from_kind gdbarch method. */
+
+static const gdb_byte *
+score7_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
+{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
+ *size = kind;
+
+ if (kind == 4)
+ {
+ static gdb_byte big_breakpoint32[] = { 0x80, 0x00, 0x80, 0x06 };
+ static gdb_byte little_breakpoint32[] = { 0x06, 0x80, 0x00, 0x80 };
+
+ if (byte_order == BFD_ENDIAN_BIG)
+ return big_breakpoint32;
else
- {
- /* 32bits instruction. */
- static gdb_byte big_breakpoint32[] = { 0x80, 0x00, 0x80, 0x06 };
- *pcptr &= ~0x3;
- *lenptr = sizeof (big_breakpoint32);
- return big_breakpoint32;
- }
+ return little_breakpoint32;
}
else
{
- if (!(raw & 0x80008000))
- {
- /* 16bits instruction. */
- static gdb_byte little_breakpoint16[] = { 0x02, 0x60 };
- *pcptr &= ~0x1;
- *lenptr = sizeof (little_breakpoint16);
- return little_breakpoint16;
- }
+ static gdb_byte big_breakpoint16[] = { 0x60, 0x02 };
+ static gdb_byte little_breakpoint16[] = { 0x02, 0x60 };
+
+ if (byte_order == BFD_ENDIAN_BIG)
+ return big_breakpoint16;
else
- {
- /* 32bits instruction. */
- static gdb_byte little_breakpoint32[] = { 0x06, 0x80, 0x00, 0x80 };
- *pcptr &= ~0x3;
- *lenptr = sizeof (little_breakpoint32);
- return little_breakpoint32;
- }
+ return little_breakpoint16;
}
}
-static const gdb_byte *
-score3_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
- int *lenptr)
+/* Implement the breakpoint_kind_from_pc gdbarch method. */
+
+static int
+score3_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- CORE_ADDR adjust_pc = *pcptr;
int len;
+
+ score3_adjust_pc_and_fetch_inst (pcptr, &len, byte_order);
+
+ return len;
+}
+
+/* Implement the sw_breakpoint_from_kind gdbarch method. */
+
+static const gdb_byte *
+score3_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
+{
+ int index = 0;
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
static gdb_byte score_break_insns[6][6] = {
/* The following three instructions are big endian. */
{ 0x00, 0x20 },
{ 0x00, 0x80, 0x06, 0x00 },
{ 0x00, 0x80, 0x00, 0x80, 0x00, 0x00 }};
- gdb_byte *p = NULL;
- int index = 0;
-
- score3_adjust_pc_and_fetch_inst (&adjust_pc, &len, byte_order);
-
- index = ((byte_order == BFD_ENDIAN_BIG) ? 0 : 3) + (len / 2 - 1);
- p = score_break_insns[index];
+ *size = kind;
- *pcptr = adjust_pc;
- *lenptr = len;
-
- return p;
+ index = ((byte_order == BFD_ENDIAN_BIG) ? 0 : 3) + (kind / 2 - 1);
+ return score_break_insns[index];
}
static CORE_ADDR
}
if (readbuf != NULL)
- regcache_cooked_read_part (regcache, regnum, reg_offset, length,
- readbuf + buf_offset);
+ regcache->cooked_read_part (regnum, reg_offset, length,
+ readbuf + buf_offset);
if (writebuf != NULL)
- regcache_cooked_write_part (regcache, regnum, reg_offset, length,
- writebuf + buf_offset);
+ regcache->cooked_write_part (regnum, reg_offset, length,
+ writebuf + buf_offset);
}
static enum return_value_convention
}
}
-static struct frame_id
-score_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
- return frame_id_build (get_frame_register_unsigned (this_frame,
- SCORE_SP_REGNUM),
- get_frame_pc (this_frame));
-}
-
static int
score_type_needs_double_align (struct type *type)
{
score_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
struct regcache *regcache, CORE_ADDR bp_addr,
int nargs, struct value **args, CORE_ADDR sp,
- int struct_return, CORE_ADDR struct_addr)
+ function_call_return_method return_method,
+ CORE_ADDR struct_addr)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int argnum;
/* Step 3, Check if struct return then save the struct address to
r4 and increase the stack_offset by 4. */
- if (struct_return)
+ if (return_method == return_method_struct)
{
regcache_cooked_write_unsigned (regcache, argreg++, struct_addr);
stack_offset += SCORE_REGSIZE;
enum type_code typecode = TYPE_CODE (arg_type);
const gdb_byte *val = value_contents (arg);
int downward_offset = 0;
- int odd_sized_struct_p;
int arg_last_part_p = 0;
arglen = TYPE_LENGTH (arg_type);
- odd_sized_struct_p = (arglen > SCORE_REGSIZE
- && arglen % SCORE_REGSIZE != 0);
/* If a arg should be aligned to 8 bytes (long long or double),
the value should be put to even register numbers. */
int ret;
gdb_byte *memblock = NULL;
- if (size < 0)
- {
- error (_("Error: malloc size < 0 in file:%s, line:%d!"),
- __FILE__, __LINE__);
- return NULL;
- }
- else if (size == 0)
+ if (size == 0)
return NULL;
- memblock = xmalloc (size);
+ memblock = (gdb_byte *) xmalloc (size);
memset (memblock, 0, size);
ret = target_read_memory (addr & ~0x3, memblock, size);
if (ret)
inst_t *inst = NULL;
if (memblock != NULL)
{
- /* Reading memory block from target succefully and got all
+ /* Reading memory block from target successfully and got all
the instructions(from STARTADDR to PC) needed. */
score7_adjust_memblock_ptr (&memblock, prev_pc, cur_pc);
inst = score7_fetch_inst (gdbarch, cur_pc, memblock);
int fp_offset_p = 0;
int inst_len = 0;
- CORE_ADDR prev_pc = -1;
-
sp = get_frame_register_unsigned (this_frame, SCORE_SP_REGNUM);
fp = get_frame_register_unsigned (this_frame, SCORE_FP_REGNUM);
- for (; cur_pc < pc; prev_pc = cur_pc, cur_pc += inst_len)
+ for (; cur_pc < pc; cur_pc += inst_len)
{
inst_t *inst = NULL;
/* addi! r2, offset */
if (pc - cur_pc >= 2)
{
- unsigned int save_v = inst->v;
inst_t *inst2;
cur_pc += inst->len;
/* addi r2, offset */
if (pc - cur_pc >= 2)
{
- unsigned int save_v = inst->v;
inst_t *inst2;
cur_pc += inst->len;
struct score_frame_cache *cache;
if ((*this_cache) != NULL)
- return (*this_cache);
+ return (struct score_frame_cache *) (*this_cache);
cache = FRAME_OBSTACK_ZALLOC (struct score_frame_cache);
(*this_cache) = cache;
return cache;
if (target_mach == bfd_mach_score3)
- score3_analyze_prologue (start_addr, pc, this_frame, *this_cache);
+ score3_analyze_prologue (start_addr, pc, this_frame,
+ (struct score_frame_cache *) *this_cache);
else
- score7_analyze_prologue (start_addr, pc, this_frame, *this_cache);
+ score7_analyze_prologue (start_addr, pc, this_frame,
+ (struct score_frame_cache *) *this_cache);
}
/* Save SP. */
trad_frame_set_value (cache->saved_regs, SCORE_SP_REGNUM, cache->base);
- return (*this_cache);
+ return (struct score_frame_cache *) (*this_cache);
}
static void
collect function will store the PC in that slot. */
if ((regnum == -1 || regnum == SCORE_EPC_REGNUM)
&& size >= SCORE7_LINUX_EPC_OFFSET + 4)
- regcache_raw_supply (regcache, SCORE_EPC_REGNUM,
- (const gdb_byte *) buf
- + SCORE7_LINUX_EPC_OFFSET);
+ regcache->raw_supply
+ (SCORE_EPC_REGNUM, (const gdb_byte *) buf + SCORE7_LINUX_EPC_OFFSET);
}
static const struct regset score7_linux_gregset =
void *cb_data,
const struct regcache *regcache)
{
- cb (".reg", SCORE7_LINUX_SIZEOF_GREGSET, &score7_linux_gregset,
- NULL, cb_data);
+ cb (".reg", SCORE7_LINUX_SIZEOF_GREGSET, SCORE7_LINUX_SIZEOF_GREGSET,
+ &score7_linux_gregset, NULL, cb_data);
}
static struct gdbarch *
set_gdbarch_register_type (gdbarch, score_register_type);
set_gdbarch_frame_align (gdbarch, score_frame_align);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
- set_gdbarch_unwind_sp (gdbarch, score_unwind_sp);
- set_gdbarch_unwind_pc (gdbarch, score_unwind_pc);
- set_gdbarch_print_insn (gdbarch, score_print_insn);
switch (target_mach)
{
case bfd_mach_score7:
- set_gdbarch_breakpoint_from_pc (gdbarch, score7_breakpoint_from_pc);
+ set_gdbarch_breakpoint_kind_from_pc (gdbarch,
+ score7_breakpoint_kind_from_pc);
+ set_gdbarch_sw_breakpoint_from_kind (gdbarch,
+ score7_sw_breakpoint_from_kind);
set_gdbarch_skip_prologue (gdbarch, score7_skip_prologue);
set_gdbarch_stack_frame_destroyed_p (gdbarch,
score7_stack_frame_destroyed_p);
break;
case bfd_mach_score3:
- set_gdbarch_breakpoint_from_pc (gdbarch, score3_breakpoint_from_pc);
+ set_gdbarch_breakpoint_kind_from_pc (gdbarch,
+ score3_breakpoint_kind_from_pc);
+ set_gdbarch_sw_breakpoint_from_kind (gdbarch,
+ score3_sw_breakpoint_from_kind);
set_gdbarch_skip_prologue (gdbarch, score3_skip_prologue);
set_gdbarch_stack_frame_destroyed_p (gdbarch,
score3_stack_frame_destroyed_p);
/* Dummy frame hooks. */
set_gdbarch_return_value (gdbarch, score_return_value);
set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
- set_gdbarch_dummy_id (gdbarch, score_dummy_id);
set_gdbarch_push_dummy_call (gdbarch, score_push_dummy_call);
/* Normal frame hooks. */
return gdbarch;
}
-extern initialize_file_ftype _initialize_score_tdep;
-
void
_initialize_score_tdep (void)
{