25#include "gdbsupport/errors.h"
30#include "opcode/s12z.h"
33#include "opcodes/s12z-opc.h"
40#define N_PHYSICAL_REGISTERS (S12Z_N_REGISTERS - 2)
85 CORE_ADDR start_pc = 0;
91 if (prologue_end != 0)
95 warning (_(
"%s Failed to find end of prologue PC = %08x"),
96 __FUNCTION__, (
unsigned int) pc);
104 switch (registers[
reg_perm[reg_nr]].bytes)
126 case 15:
return REG_S;
127 case 7:
return REG_X;
128 case 8:
return REG_Y;
129 case 42:
return REG_D0;
130 case 43:
return REG_D1;
131 case 44:
return REG_D2;
132 case 45:
return REG_D3;
133 case 46:
return REG_D4;
134 case 47:
return REG_D5;
135 case 48:
return REG_D6;
136 case 49:
return REG_D7;
148 struct mem_read_abstraction_base
base;
163posn (
struct mem_read_abstraction_base *b)
175 size_t n, bfd_byte *bytes)
180 (*mra->
info->read_memory_func) (mra->
memaddr + offset,
181 bytes, n, mra->
info);
196 struct operand *
const *operands)
198 int stack_adjustment = 0;
199 gdb_assert (n_operands > 0);
200 if (operands[0]->cl == OPND_CL_REGISTER_ALL)
201 stack_adjustment = 26;
202 else if (operands[0]->cl == OPND_CL_REGISTER_ALL16)
203 stack_adjustment = 4 * 2;
205 for (
int i = 0; i < n_operands; ++i)
207 if (operands[i]->cl != OPND_CL_REGISTER)
209 const struct register_operand *op
210 = (
const struct register_operand *) operands[i];
215 stack_adjustment += 3;
219 stack_adjustment += 4;
225 stack_adjustment += 2;
231 stack_adjustment += 1;
234 gdb_assert_not_reached (
"Invalid register in push/pull operation.");
238 return stack_adjustment;
249 CORE_ADDR this_sp_for_id;
251 CORE_ADDR start_addr;
255 if (NULL != *prologue_cache)
260 *prologue_cache = info;
270 this_sp = (NULL == this_frame) ? 0 :
276 warning (_(
"Couldn't find function including address %s SP is %s"),
295 this_sp_for_id = this_sp;
306 if (end_addr < start_addr)
307 error (_(
"end addr %s is less than start addr %s"),
310 CORE_ADDR addr = start_addr;
312 int saved_frame_size = 0;
317 mra.
base.read = (int (*)(mem_read_abstraction_base*,
323 while (this_pc > addr)
325 enum optr optr = OP_INVALID;
328 struct operand *operands[6];
331 decode_s12z (&optr, &osize, &n_operands, operands,
332 (mem_read_abstraction_base *) &mra);
350 saved_frame_size = frame_size;
354 frame_size = saved_frame_size;
363 if (operands[0]->cl == OPND_CL_REGISTER)
365 int reg = ((
struct register_operand *) (operands[0]))->reg;
366 if ((reg == REG_S) && (operands[1]->cl == OPND_CL_MEMORY))
368 const struct memory_operand *mo
369 = (
const struct memory_operand * ) operands[1];
370 if (mo->n_regs == 1 && !mo->indirect
371 && mo->regs[0] == REG_S
372 && mo->mutation == OPND_RM_NONE)
376 int simm = (
signed char) mo->base_offset;
386 for (
int o = 0; o < n_operands; ++o)
397 this_sp_for_id = this_sp - frame_size;
405 gdb_assert (this_sp == this_sp_for_id);
410 this_sp + frame_size + 3);
424 void **prologue_cache,
struct frame_id *this_id)
436 void **prologue_cache,
int regnum)
501 size_t len = strlen (
name);
502 const int stop_1 = 15;
503 const int stop_2 = 17;
504 for (
int i = 0; i < stop_1 - len; ++i)
507 for (
int i = 0; i < stop_2 - len; ++i)
509 for (
int b = 15; b >= 0; --b)
511 if (ccw & (0x1u << b))
528 int regnum,
int print_all)
582 error (_(
"bad size for return value"));
592 gdb_byte *readbuf,
const gdb_byte *writebuf)
594 if (
type->
code () == TYPE_CODE_STRUCT
623 _(
"Show the current value of the microcontroller's BDCCSR."),
643 s12z_breakpoint::kind_from_pc);
645 s12z_breakpoint::bp_from_kind);
void gdbarch_register(enum bfd_architecture bfd_architecture, gdbarch_init_ftype *init, gdbarch_dump_tdep_ftype *dump_tdep, gdbarch_supports_arch_info_ftype *supports_arch_info)
static std::vector< const char * > arches
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
#define BP_MANIPULATION(BREAK_INSN)
bool find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr, const struct block **block)
enum register_status cooked_read(int regnum, gdb_byte *buf)
const std::string & string()
struct cmd_list_element * maintenanceinfolist
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
@ RETURN_VALUE_REGISTER_CONVENTION
@ RETURN_VALUE_STRUCT_CONVENTION
struct value * value_of_register(int regnum, frame_info_ptr frame)
int default_frame_sniffer(const struct frame_unwind *self, frame_info_ptr this_frame, void **this_prologue_cache)
enum unwind_stop_reason default_frame_unwind_stop_reason(frame_info_ptr this_frame, void **this_cache)
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
ULONGEST get_frame_register_unsigned(frame_info_ptr frame, int regnum)
CORE_ADDR get_frame_pc(frame_info_ptr frame)
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
void set_gdbarch_long_long_bit(struct gdbarch *gdbarch, int long_long_bit)
void set_gdbarch_addr_bit(struct gdbarch *gdbarch, int addr_bit)
void set_gdbarch_char_signed(struct gdbarch *gdbarch, int char_signed)
void set_gdbarch_ps_regnum(struct gdbarch *gdbarch, int ps_regnum)
void set_gdbarch_breakpoint_kind_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_kind_from_pc_ftype *breakpoint_kind_from_pc)
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
void set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype *skip_prologue)
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype *register_name)
void set_gdbarch_int_bit(struct gdbarch *gdbarch, int int_bit)
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype *return_value)
void set_gdbarch_print_registers_info(struct gdbarch *gdbarch, gdbarch_print_registers_info_ftype *print_registers_info)
int gdbarch_num_regs(struct gdbarch *gdbarch)
void set_gdbarch_inner_than(struct gdbarch *gdbarch, gdbarch_inner_than_ftype *inner_than)
void set_gdbarch_sp_regnum(struct gdbarch *gdbarch, int sp_regnum)
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
int gdbarch_num_pseudo_regs(struct gdbarch *gdbarch)
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype *register_type)
void set_gdbarch_short_bit(struct gdbarch *gdbarch, int short_bit)
void set_gdbarch_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, gdbarch_dwarf2_reg_to_regnum_ftype *dwarf2_reg_to_regnum)
void set_gdbarch_long_bit(struct gdbarch *gdbarch, int long_bit)
void set_gdbarch_ptr_bit(struct gdbarch *gdbarch, int ptr_bit)
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
void set_gdbarch_sw_breakpoint_from_kind(struct gdbarch *gdbarch, gdbarch_sw_breakpoint_from_kind_ftype *sw_breakpoint_from_kind)
struct gdbarch * gdbarch_alloc(const struct gdbarch_info *info, gdbarch_tdep_up tdep)
std::unique_ptr< gdbarch_tdep_base > gdbarch_tdep_up
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
void default_print_registers_info(struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, int regnum, int print_all)
static const char * s12z_register_name(struct gdbarch *gdbarch, int regnum)
static const int reg_perm[N_PHYSICAL_REGISTERS]
static void s12z_extract_return_value(struct type *type, struct regcache *regcache, void *valbuf)
static bfd_vma posn(struct mem_read_abstraction_base *b)
static struct gdbarch * s12z_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
static const int inv_reg_perm[N_PHYSICAL_REGISTERS]
constexpr gdb_byte s12z_break_insn[]
static void show_bdccsr_command(const char *args, int from_tty)
static void s12z_frame_this_id(frame_info_ptr this_frame, void **prologue_cache, struct frame_id *this_id)
static struct type * s12z_register_type(struct gdbarch *gdbarch, int reg_nr)
static struct trad_frame_cache * s12z_frame_cache(frame_info_ptr this_frame, void **prologue_cache)
static int s12z_dwarf_reg_to_regnum(struct gdbarch *gdbarch, int num)
static void advance(struct mem_read_abstraction_base *b)
static const char ccw_bits[]
static void s12z_print_registers_info(struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, int regnum, int print_all)
static void s12z_print_ccw_info(struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, int reg)
static CORE_ADDR s12z_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
static struct value * s12z_frame_prev_register(frame_info_ptr this_frame, void **prologue_cache, int regnum)
static int abstract_read_memory(struct mem_read_abstraction_base *b, int offset, size_t n, bfd_byte *bytes)
void _initialize_s12z_tdep()
#define N_PHYSICAL_REGISTERS
static const struct frame_unwind s12z_frame_unwind
static int push_pull_get_stack_adjustment(int n_operands, struct operand *const *operands)
static enum return_value_convention s12z_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
struct type * builtin_int0
struct type * builtin_uint16
struct type * builtin_uint32
struct type * builtin_uint24
struct type * builtin_uint8
struct disassemble_info * disasm_info()
struct mem_read_abstraction_base base
struct disassemble_info * info
frame_info_ptr this_frame
struct value::@203::@204 reg
CORE_ADDR skip_prologue_using_sal(struct gdbarch *gdbarch, CORE_ADDR func_addr)
void target_rcmd(const char *command, struct ui_file *outbuf)
struct trad_frame_cache * trad_frame_cache_zalloc(frame_info_ptr this_frame)
void trad_frame_set_reg_addr(struct trad_frame_cache *this_trad_cache, int regnum, CORE_ADDR addr)
void trad_frame_get_id(struct trad_frame_cache *this_trad_cache, struct frame_id *this_id)
void trad_frame_set_id(struct trad_frame_cache *this_trad_cache, struct frame_id this_id)
void trad_frame_set_this_base(struct trad_frame_cache *this_trad_cache, CORE_ADDR this_base)
void trad_frame_set_reg_value(struct trad_frame_cache *this_trad_cache, int regnum, LONGEST val)
struct value * trad_frame_get_register(struct trad_frame_cache *this_trad_cache, frame_info_ptr this_frame, int regnum)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
LONGEST value_as_long(struct value *val)