59 #define H8300_MAX_NUM_REGS 18
61 #define E_PSEUDO_CCR_REGNUM(gdbarch) (gdbarch_num_regs (gdbarch))
62 #define E_PSEUDO_EXR_REGNUM(gdbarch) (gdbarch_num_regs (gdbarch)+1)
91 #define BINWORD(gdbarch) ((is_h8300hmode (gdbarch) \
92 && !is_h8300_normal_mode (gdbarch)) \
93 ? h8300h_reg_size : h8300_reg_size)
138 #define IS_MOVB_RnRm(x) (((x) & 0xff88) == 0x0c88)
139 #define IS_MOVW_RnRm(x) (((x) & 0xff88) == 0x0d00)
140 #define IS_MOVL_RnRm(x) (((x) & 0xff88) == 0x0f80)
141 #define IS_MOVB_Rn16_SP(x) (((x) & 0xfff0) == 0x6ee0)
142 #define IS_MOVB_EXT(x) ((x) == 0x7860)
143 #define IS_MOVB_Rn24_SP(x) (((x) & 0xfff0) == 0x6aa0)
144 #define IS_MOVW_Rn16_SP(x) (((x) & 0xfff0) == 0x6fe0)
145 #define IS_MOVW_EXT(x) ((x) == 0x78e0)
146 #define IS_MOVW_Rn24_SP(x) (((x) & 0xfff0) == 0x6ba0)
148 #define IS_MOVL_PRE(x) ((x) == 0x0100)
149 #define IS_MOVL_Rn16_SP(x) (((x) & 0xfff0) == 0x6fe0)
150 #define IS_MOVL_EXT(x) ((x) == 0x78e0)
151 #define IS_MOVL_Rn24_SP(x) (((x) & 0xfff0) == 0x6ba0)
153 #define IS_PUSHFP_MOVESPFP(x) ((x) == 0x6df60d76)
154 #define IS_PUSH_FP(x) ((x) == 0x01006df6)
155 #define IS_MOV_SP_FP(x) ((x) == 0x0ff6)
156 #define IS_SUB2_SP(x) ((x) == 0x1b87)
157 #define IS_SUB4_SP(x) ((x) == 0x1b97)
158 #define IS_ADD_IMM_SP(x) ((x) == 0x7a1f)
159 #define IS_SUB_IMM_SP(x) ((x) == 0x7a3f)
160 #define IS_SUBL4_SP(x) ((x) == 0x1acf)
161 #define IS_MOV_IMM_Rn(x) (((x) & 0xfff0) == 0x7905)
162 #define IS_SUB_RnSP(x) (((x) & 0xff0f) == 0x1907)
163 #define IS_ADD_RnSP(x) (((x) & 0xff0f) == 0x0907)
164 #define IS_PUSH(x) (((x) & 0xfff0) == 0x6df0)
184 && (w & 0x70) <= 0x20
185 && (w & 0x7) >= 0x3 && (w & 0x7) <= 0x5)
189 && 8 <= (w & 0xf) && (w & 0xf) <= 10)
203 if (disp < 0 && disp > 0xffffff)
222 if (disp < 0 && disp > 0xffffff)
246 if (disp < 0 && disp > 0xffffff)
297 int regno, i, spill_size;
301 if (pc >= current_pc)
316 if (pc >= current_pc)
326 while (pc < current_pc)
364 else if (
IS_SUB_RnSP (op) && (op & 0x00f0) == regno)
379 else if (op == 0x0100)
392 else if ((op & 0xffcf) == 0x0100)
400 i = ((op & 0x0030) >> 4) + 1;
401 regno = op1 & 0x000f;
402 for (; i > 0; regno++, --i)
420 && pc + spill_size <= current_pc)
448 if (cache->
base == 0)
496 if (cache->
base == 0)
502 static struct value *
543 h8300_frame_base_address
558 if (sal.end && sal.end < func_end)
642 int stack_alloc = 0, stack_offset = 0;
652 for (argument = 0; argument < nargs; argument++)
665 for (argument = 0; argument < nargs; argument++)
673 int padded_len =
align_up (len, wordsize);
677 memset (padded, 0, padded_len);
678 memcpy (len < wordsize ? padded + padded_len - len : padded,
686 if (len > wordsize && len % wordsize)
690 stack_offset += padded_len;
704 for (offset = 0; offset < padded_len; offset +=
wordsize)
708 wordsize, byte_order);
717 stack_offset += padded_len;
774 error (
_(
"I don't know how this 8 byte value is returned."));
807 error (
_(
"I don't know how this 8 byte value is returned."));
864 (val >> 16) & 0xffff);
870 error (
_(
"I don't know how to return an 8 byte value."));
894 (val >> 32) & 0xffffffff);
960 static char *register_names[] = {
961 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
962 "sp",
"",
"pc",
"cycles",
"tick",
"inst",
966 || regno >= (
sizeof (register_names) /
sizeof (*register_names)))
968 _(
"h8300_register_name: illegal register number %d"),
971 return register_names[regno];
977 static char *register_names[] = {
978 "er0",
"er1",
"er2",
"er3",
"er4",
"er5",
"er6",
979 "sp",
"",
"pc",
"cycles",
"",
"tick",
"inst",
984 || regno >= (
sizeof (register_names) /
sizeof (*register_names)))
986 _(
"h8300s_register_name: illegal register number %d"),
989 return register_names[regno];
995 static char *register_names[] = {
996 "er0",
"er1",
"er2",
"er3",
"er4",
"er5",
"er6",
997 "sp",
"",
"pc",
"cycles",
"",
"tick",
"inst",
998 "mach",
"macl",
"sbr",
"vbr",
1002 || regno >= (
sizeof (register_names) /
sizeof (*register_names)))
1004 _(
"h8300sx_register_name: illegal register number %d"),
1007 return register_names[regno];
1017 if (!name || !*name)
1039 unsigned char l = rval & 0xff;
1069 if ((Z | (N ^ V)) == 0)
1071 if ((Z | (N ^ V)) == 1)
1077 unsigned char l = rval & 0xff;
1089 struct frame_info *frame,
int regno,
int cpregs)
1134 static struct type *
1140 _(
"h8300_register_type: illegal register number %d"),
1170 gdb_byte *buf,
int pseudo_regno,
int raw_regno)
1188 const gdb_byte *buf,
int raw_regno,
int pseudo_regno)
1248 static const unsigned char *
1253 static unsigned char breakpoint[] = { 0x01, 0x80 };
1255 *lenptr =
sizeof (breakpoint);
1259 static struct gdbarch *
1263 struct gdbarch *gdbarch;
1282 case bfd_mach_h8300:
1294 case bfd_mach_h8300h:
1295 case bfd_mach_h8300hn:
1315 case bfd_mach_h8300s:
1316 case bfd_mach_h8300sn:
1336 case bfd_mach_h8300sx:
1337 case bfd_mach_h8300sxn:
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
void set_gdbarch_double_bit(struct gdbarch *gdbarch, int double_bit)
static void h8300_pseudo_register_write(struct gdbarch *gdbarch, struct regcache *regcache, int regno, const gdb_byte *buf)
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
static void h8300h_store_return_value(struct type *type, struct regcache *regcache, const void *valbuf)
#define E_PSEUDO_CCR_REGNUM(gdbarch)
struct type * builtin_func_ptr
CORE_ADDR get_frame_pc(struct frame_info *frame)
#define IS_MOVW_Rn24_SP(x)
static int h8300_dbg_reg_to_regnum(struct gdbarch *gdbarch, int regno)
struct gdbarch * get_regcache_arch(const struct regcache *regcache)
struct value * frame_unwind_got_memory(struct frame_info *frame, int regnum, CORE_ADDR addr)
void write_memory_unsigned_integer(CORE_ADDR addr, int len, enum bfd_endian byte_order, ULONGEST value)
static const char * h8300sx_register_name(struct gdbarch *gdbarch, int regno)
void set_gdbarch_stab_reg_to_regnum(struct gdbarch *gdbarch, gdbarch_stab_reg_to_regnum_ftype stab_reg_to_regnum)
ULONGEST align_down(ULONGEST v, int n)
ULONGEST frame_unwind_register_unsigned(struct frame_info *frame, int regnum)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
char * phex(ULONGEST l, int sizeof_l)
void internal_error(const char *file, int line, const char *fmt,...)
static struct gdbarch * h8300_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
static void h8300_frame_this_id(struct frame_info *this_frame, void **this_cache, struct frame_id *this_id)
struct type * builtin_uint8
static void h8300_print_register(struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, int regno)
static const char * h8300_register_name(struct gdbarch *gdbarch, int regno)
struct gdbarch_list * gdbarch_list_lookup_by_info(struct gdbarch_list *arches, const struct gdbarch_info *info)
int gdbarch_num_regs(struct gdbarch *gdbarch)
const struct bfd_arch_info * bfd_arch_info
static int h8300_register_sim_regno(struct gdbarch *gdbarch, int regnum)
void set_gdbarch_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, gdbarch_dwarf2_reg_to_regnum_ftype dwarf2_reg_to_regnum)
static int h8300s_dbg_reg_to_regnum(struct gdbarch *gdbarch, int regno)
static CORE_ADDR h8300_unwind_pc(struct gdbarch *gdbarch, struct frame_info *next_frame)
static enum register_status pseudo_from_raw_register(struct gdbarch *gdbarch, struct regcache *regcache, gdb_byte *buf, int pseudo_regno, int raw_regno)
static CORE_ADDR h8300_unwind_sp(struct gdbarch *gdbarch, struct frame_info *next_frame)
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
void set_gdbarch_print_registers_info(struct gdbarch *gdbarch, gdbarch_print_registers_info_ftype print_registers_info)
struct type * builtin_int32
#define FRAME_OBSTACK_ZALLOC(TYPE)
void store_unsigned_integer(gdb_byte *, int, enum bfd_endian, ULONGEST)
struct value * frame_unwind_got_constant(struct frame_info *frame, int regnum, ULONGEST val)
static void h8300_init_frame_cache(struct gdbarch *gdbarch, struct h8300_frame_cache *cache)
static const char * h8300s_register_name(struct gdbarch *gdbarch, int regno)
int gdbarch_num_pseudo_regs(struct gdbarch *gdbarch)
void set_gdbarch_addr_bit(struct gdbarch *gdbarch, int addr_bit)
static int is_h8300sxmode(struct gdbarch *gdbarch)
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
void set_gdbarch_ecoff_reg_to_regnum(struct gdbarch *gdbarch, gdbarch_ecoff_reg_to_regnum_ftype ecoff_reg_to_regnum)
void set_gdbarch_pseudo_register_write(struct gdbarch *gdbarch, gdbarch_pseudo_register_write_ftype pseudo_register_write)
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype register_type)
LONGEST read_memory_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
const gdb_byte * value_contents(struct value *value)
void initialize_file_ftype(void)
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
static void h8300_extract_return_value(struct type *type, struct regcache *regcache, void *valbuf)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
enum register_status regcache_cooked_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
void set_gdbarch_sp_regnum(struct gdbarch *gdbarch, int sp_regnum)
void set_gdbarch_dummy_id(struct gdbarch *gdbarch, gdbarch_dummy_id_ftype dummy_id)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int status
static enum return_value_convention h8300_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
void set_gdbarch_believe_pcc_promotion(struct gdbarch *gdbarch, int believe_pcc_promotion)
struct type * builtin_int16
static struct h8300_frame_cache * h8300_frame_cache(struct frame_info *this_frame, void **this_cache)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
void set_gdbarch_register_sim_regno(struct gdbarch *gdbarch, gdbarch_register_sim_regno_ftype register_sim_regno)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
initialize_file_ftype _initialize_h8300_tdep
int find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr)
LONGEST get_frame_register_signed(struct frame_info *frame, int regnum)
static void h8300_store_return_value(struct type *type, struct regcache *regcache, const void *valbuf)
void set_gdbarch_unwind_pc(struct gdbarch *gdbarch, gdbarch_unwind_pc_ftype unwind_pc)
void set_gdbarch_breakpoint_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_from_pc_ftype breakpoint_from_pc)
int default_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache)
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
enum register_status regcache_raw_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
void set_gdbarch_unwind_sp(struct gdbarch *gdbarch, gdbarch_unwind_sp_ftype unwind_sp)
static int is_h8300smode(struct gdbarch *gdbarch)
static enum return_value_convention h8300h_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
static int h8300_use_struct_convention(struct type *value_type)
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
static CORE_ADDR h8300_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
void set_gdbarch_long_long_bit(struct gdbarch *gdbarch, int long_long_bit)
#define IS_MOVL_Rn24_SP(x)
static struct value * h8300_frame_prev_register(struct frame_info *this_frame, void **this_cache, int regnum)
#define IS_MOVL_Rn16_SP(x)
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
static struct type * h8300_register_type(struct gdbarch *gdbarch, int regno)
static CORE_ADDR h8300_analyze_prologue(struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR current_pc, struct h8300_frame_cache *cache)
static int h8300h_use_struct_convention(struct type *value_type)
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
CORE_ADDR saved_regs[H8300_MAX_NUM_REGS]
#define IS_MOVB_Rn16_SP(x)
static int is_h8300hmode(struct gdbarch *gdbarch)
void set_gdbarch_pseudo_register_read(struct gdbarch *gdbarch, gdbarch_pseudo_register_read_ftype pseudo_register_read)
ULONGEST align_up(ULONGEST v, int n)
void set_gdbarch_char_signed(struct gdbarch *gdbarch, int char_signed)
void print_longest(struct ui_file *stream, int format, int use_c_format, LONGEST val_long)
#define TYPE_CODE(thistype)
enum register_status regcache_raw_read(struct regcache *regcache, int regnum, gdb_byte *buf)
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
struct value * frame_unwind_got_register(struct frame_info *frame, int regnum, int new_regnum)
static int is_h8300_normal_mode(struct gdbarch *gdbarch)
struct type * builtin_data_ptr
void set_gdbarch_int_bit(struct gdbarch *gdbarch, int int_bit)
static const struct frame_unwind h8300_frame_unwind
void regcache_raw_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
void set_gdbarch_num_pseudo_regs(struct gdbarch *gdbarch, int num_pseudo_regs)
void dwarf2_append_unwinders(struct gdbarch *gdbarch)
static const unsigned char * h8300_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
static enum register_status h8300_pseudo_register_read(struct gdbarch *gdbarch, struct regcache *regcache, int regno, gdb_byte *buf)
static struct frame_id h8300_dummy_id(struct gdbarch *gdbarch, struct frame_info *this_frame)
void set_gdbarch_double_format(struct gdbarch *gdbarch, const struct floatformat **double_format)
unsigned long long ULONGEST
enum unwind_stop_reason default_frame_unwind_stop_reason(struct frame_info *this_frame, void **this_cache)
#define IS_MOVB_Rn24_SP(x)
int register_size(struct gdbarch *gdbarch, int regnum)
void set_gdbarch_long_double_bit(struct gdbarch *gdbarch, int long_double_bit)
struct type * value_type(const struct value *value)
void set_gdbarch_long_bit(struct gdbarch *gdbarch, int long_bit)
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype return_value)
static void h8300h_extract_return_value(struct type *type, struct regcache *regcache, void *valbuf)
const struct bfd_arch_info * gdbarch_bfd_arch_info(struct gdbarch *gdbarch)
static void h8300_print_registers_info(struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, int regno, int cpregs)
void set_gdbarch_long_double_format(struct gdbarch *gdbarch, const struct floatformat **long_double_format)
#define TYPE_LENGTH(thistype)
void set_gdbarch_ptr_bit(struct gdbarch *gdbarch, int ptr_bit)
#define E_PSEUDO_EXR_REGNUM(gdbarch)
void set_gdbarch_push_dummy_call(struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype push_dummy_call)
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
static int h8300_is_argument_spill(struct gdbarch *gdbarch, CORE_ADDR pc)
static void raw_from_pseudo_register(struct gdbarch *gdbarch, struct regcache *regcache, const gdb_byte *buf, int raw_regno, int pseudo_regno)
#define IS_PUSHFP_MOVESPFP(x)
void register_gdbarch_init(enum bfd_architecture bfd_architecture, gdbarch_init_ftype *init)
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
void set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype skip_prologue)
#define IS_MOVW_Rn16_SP(x)
enum bfd_endian byte_order
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype register_name)
CORE_ADDR get_frame_func(struct frame_info *this_frame)
void error(const char *fmt,...)
struct gdbarch * gdbarch_alloc(const struct gdbarch_info *info, struct gdbarch_tdep *tdep)
void set_gdbarch_inner_than(struct gdbarch *gdbarch, gdbarch_inner_than_ftype inner_than)
static CORE_ADDR h8300_frame_base_address(struct frame_info *this_frame, void **this_cache)
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
#define H8300_MAX_NUM_REGS
void do_cleanups(struct cleanup *old_chain)
void set_gdbarch_print_insn(struct gdbarch *gdbarch, gdbarch_print_insn_ftype print_insn)
static CORE_ADDR h8300_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)
void regcache_raw_write(struct regcache *regcache, int regnum, const gdb_byte *buf)
const ULONGEST const LONGEST len