40 #include "opcode/ft32.h" 43 #include "gdb/sim-ft32.h" 46 #define RAM_BIAS 0x800000 84 static const char *
const ft32_register_names[] =
87 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
88 "r8",
"r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15",
89 "r16",
"r17",
"r18",
"r19",
"r20",
"r21",
"r22",
"r23",
90 "r24",
"r25",
"r26",
"r27",
"r28",
"cc",
101 if (reg_nr >= FT32_NUM_REGS)
103 return ft32_register_names[reg_nr];
111 if (reg_nr == FT32_PC_REGNUM)
113 else if (reg_nr == FT32_SP_REGNUM || reg_nr == FT32_FP_REGNUM)
154 *isize = ft32_decode_shortcode (a4, inst, sc) ? 2 : 4;
156 return sc[1 & (a >> 1)];
178 const int first_saved_reg = 13;
194 char prolog_symbol[32];
196 snprintf (prolog_symbol,
sizeof (prolog_symbol),
"__prolog_$r%02d",
205 if (start_addr >= end_addr)
209 for (next_addr = start_addr; next_addr < end_addr; next_addr += isize)
213 if (FT32_IS_PUSH (inst))
215 pushreg = FT32_PUSH_REG (inst);
219 else if (FT32_IS_CALL (inst))
223 if ((4 * (inst & 0x3ffff)) == prologs[
regnum])
225 for (pushreg = first_saved_reg; pushreg <=
regnum;
248 if (next_addr < end_addr)
251 if (FT32_IS_LINK (inst))
261 cache->
framesize += FT32_LINK_SIZE (inst);
275 const char *func_name;
284 if (post_prologue_pc != 0)
285 return std::max (pc, post_prologue_pc);
295 memset (&cache, 0,
sizeof cache);
305 if (sal.
end && sal.
end < func_end)
350 if (dwarf2_addr_class == 1)
377 if (strcmp (
name,
"flash") == 0)
423 bfd_byte *valbuf = dst;
454 if (writebuf != NULL)
470 for (i = 0; i < FT32_NUM_REGS; ++i)
492 if (cache->
base == 0)
508 for (i = 0; i < FT32_NUM_REGS; ++i)
528 void **this_prologue_cache,
struct frame_id *this_id)
531 this_prologue_cache);
534 if (cache->
base == 0)
542 static struct value *
544 void **this_prologue_cache,
int regnum)
547 this_prologue_cache);
605 struct type *void_type;
606 struct type *func_void_type;
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
void set_gdbarch_frame_align(struct gdbarch *gdbarch, gdbarch_frame_align_ftype frame_align)
void set_gdbarch_address_class_type_flags_to_name(struct gdbarch *gdbarch, gdbarch_address_class_type_flags_to_name_ftype address_class_type_flags_to_name)
void _initialize_ft32_tdep(void)
static void ft32_write_pc(struct regcache *regcache, CORE_ADDR val)
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
static void ft32_frame_this_id(struct frame_info *this_frame, void **this_prologue_cache, struct frame_id *this_id)
struct type * arch_type(struct gdbarch *gdbarch, enum type_code code, int bit, const char *name)
CORE_ADDR get_frame_pc(struct frame_info *frame)
void gdbarch_init_osabi(struct gdbarch_info info, struct gdbarch *gdbarch)
struct value * frame_unwind_got_memory(struct frame_info *frame, int regnum, CORE_ADDR addr)
#define BMSYMBOL_VALUE_ADDRESS(symbol)
static struct value * ft32_frame_prev_register(struct frame_info *this_frame, void **this_prologue_cache, int regnum)
void set_gdbarch_overlay_update(struct gdbarch *gdbarch, gdbarch_overlay_update_ftype overlay_update)
void set_gdbarch_write_pc(struct gdbarch *gdbarch, gdbarch_write_pc_ftype write_pc)
static CORE_ADDR ft32_frame_align(struct gdbarch *gdbarch, CORE_ADDR sp)
ULONGEST frame_unwind_register_unsigned(struct frame_info *frame, int regnum)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
void * memset(T *s, int c, size_t n)=delete
struct type * make_function_type(struct type *type, struct type **typeptr)
static struct frame_id ft32_dummy_id(struct gdbarch *gdbarch, struct frame_info *this_frame)
struct gdbarch_list * gdbarch_list_lookup_by_info(struct gdbarch_list *arches, const struct gdbarch_info *info)
CORE_ADDR skip_prologue_using_sal(struct gdbarch *gdbarch, CORE_ADDR func_addr)
struct block_symbol lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
static CORE_ADDR ft32_pointer_to_address(struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf)
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
static struct ft32_frame_cache * ft32_alloc_frame_cache(void)
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
CORE_ADDR saved_regs[FT32_NUM_REGS]
struct type * builtin_int32
#define FRAME_OBSTACK_ZALLOC(TYPE)
struct value * frame_unwind_got_constant(struct frame_info *frame, int regnum, ULONGEST val)
ULONGEST read_code_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
static CORE_ADDR ft32_unwind_pc(struct gdbarch *gdbarch, struct frame_info *next_frame)
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
#define TYPE_INSTANCE_FLAGS(thistype)
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype register_type)
typedef BP_MANIPULATION(ft32_break_insn)
static CORE_ADDR ft32_unwind_sp(struct gdbarch *gdbarch, struct frame_info *next_frame)
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
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)
static CORE_ADDR ft32_frame_base_address(struct frame_info *this_frame, void **this_cache)
static ULONGEST ft32_fetch_instruction(CORE_ADDR a, int *isize, enum bfd_endian byte_order)
void set_gdbarch_dummy_id(struct gdbarch *gdbarch, gdbarch_dummy_id_ftype dummy_id)
static enum return_value_convention ft32_return_value(struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
struct type * arch_pointer_type(struct gdbarch *gdbarch, int bit, const char *name, struct type *target_type)
static void ft32_extract_return_value(struct type *type, struct regcache *regcache, gdb_byte *dst)
int find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr)
static struct ft32_frame_cache * ft32_frame_cache(struct frame_info *this_frame, void **this_cache)
void set_gdbarch_unwind_pc(struct gdbarch *gdbarch, gdbarch_unwind_pc_ftype unwind_pc)
int default_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache)
static struct gdbarch * ft32_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
static CORE_ADDR ft32_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
void set_gdbarch_read_pc(struct gdbarch *gdbarch, gdbarch_read_pc_ftype read_pc)
void simple_overlay_update(struct obj_section *osect)
void set_gdbarch_pointer_to_address(struct gdbarch *gdbarch, gdbarch_pointer_to_address_ftype pointer_to_address)
void set_gdbarch_unwind_sp(struct gdbarch *gdbarch, gdbarch_unwind_sp_ftype unwind_sp)
#define TYPE_ADDRESS_CLASS_1(t)
static const char * ft32_address_class_type_flags_to_name(struct gdbarch *gdbarch, int type_flags)
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
constexpr gdb_byte ft32_break_insn[]
void set_gdbarch_breakpoint_kind_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_kind_from_pc_ftype breakpoint_kind_from_pc)
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
void set_gdbarch_address_class_type_flags(struct gdbarch *gdbarch, gdbarch_address_class_type_flags_ftype address_class_type_flags)
static const struct frame_base ft32_frame_base
void set_gdbarch_address_class_name_to_type_flags(struct gdbarch *gdbarch, gdbarch_address_class_name_to_type_flags_ftype address_class_name_to_type_flags)
struct value * frame_unwind_got_register(struct frame_info *frame, int regnum, int new_regnum)
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
struct type * builtin_data_ptr
struct minimal_symbol * minsym
#define SYMBOL_LANGUAGE(symbol)
static CORE_ADDR ft32_analyze_prologue(CORE_ADDR start_addr, CORE_ADDR end_addr, struct ft32_frame_cache *cache, struct gdbarch *gdbarch)
static void ft32_store_return_value(struct type *type, struct regcache *regcache, const gdb_byte *valbuf)
unsigned long long ULONGEST
enum unwind_stop_reason default_frame_unwind_stop_reason(struct frame_info *this_frame, void **this_cache)
static const char * ft32_register_name(struct gdbarch *gdbarch, int reg_nr)
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype return_value)
static int ft32_address_class_type_flags(int byte_size, int dwarf2_addr_class)
#define TYPE_LENGTH(thistype)
static int ft32_address_class_name_to_type_flags(struct gdbarch *gdbarch, const char *name, int *type_flags_ptr)
void set_gdbarch_sw_breakpoint_from_kind(struct gdbarch *gdbarch, gdbarch_sw_breakpoint_from_kind_ftype sw_breakpoint_from_kind)
void register_gdbarch_init(enum bfd_architecture bfd_architecture, gdbarch_init_ftype *init)
static struct type * ft32_register_type(struct gdbarch *gdbarch, int reg_nr)
static const struct frame_unwind ft32_frame_unwind
void set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype skip_prologue)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
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)
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)
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
static CORE_ADDR ft32_read_pc(struct regcache *regcache)
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)