39 #include "floatformat.h"
56 #define TIC6X_OPCODE_SIZE 4
57 #define TIC6X_FETCH_PACKET_SIZE 32
59 #define INST_S_BIT(INST) ((INST >> 1) & 1)
60 #define INST_X_BIT(INST) ((INST >> 12) & 1)
89 "A0",
"A1",
"A2",
"A3",
90 "A4",
"A5",
"A6",
"A7",
91 "A8",
"A9",
"A10",
"A11",
92 "A12",
"A13",
"A14",
"A15",
93 "B0",
"B1",
"B2",
"B3",
94 "B4",
"B5",
"B6",
"B7",
95 "B8",
"B9",
"B10",
"B11",
96 "B12",
"B13",
"B14",
"B15",
102 static const int arg_regs[] = { 4, 20, 6, 22, 8, 24, 10, 26, 12, 28 };
156 unsigned int src_reg, base_reg, dst_reg;
160 int frame_base_offset_to_sp = 0;
162 int non_stw_insn_counter = 0;
164 if (start_pc >= current_pc)
165 return_pc = current_pc;
176 while (pc < current_pc)
182 if ((inst & 0x1ffc) == 0x1dc0 || (inst & 0x1ffc) == 0x1bc0
183 || (inst & 0x0ffc) == 0x9c0)
196 unsigned int ucst5 = (inst >> 13) & 0x1f;
198 if ((inst & 0x1ffc) == 0x1dc0)
199 frame_base_offset_to_sp += ucst5 << 2;
200 else if ((inst & 0x1ffc) == 0x1bc0)
201 frame_base_offset_to_sp += ucst5 << 1;
202 else if ((inst & 0x0ffc) == 0x9c0)
203 frame_base_offset_to_sp += ucst5;
210 else if ((inst & 0x174) == 0x74)
221 cache->
reg_saved[src_reg] = ((inst >> 13) & 0x1f) << 2;
225 non_stw_insn_counter = 0;
229 non_stw_insn_counter++;
243 if (non_stw_insn_counter >= 2)
260 if ((inst & 0x164) == 0x64
285 cache->
cfa = cache->
base + frame_base_offset_to_sp;
313 if (post_prologue_pc != 0)
314 return max (start_pc, post_prologue_pc);
349 return print_insn_tic6x (memaddr, info);
370 else if ((regnum >= 10 && regnum <= 15) || (regnum >= 26 && regnum <= 31))
401 void **this_prologue_cache)
407 if (*this_prologue_cache)
408 return *this_prologue_cache;
411 (*this_prologue_cache) = cache;
435 if (cache->
base == 0)
441 static struct value *
461 if (regnum < TIC6X_NUM_CORE_REGS && cache->
reg_saved[regnum] != -1)
491 tic6x_frame_base_address
517 if (*this_cache == NULL)
527 void **this_prologue_cache)
565 static const int register_numbers[8] = { -1, 16, 17, 18, 1, 2, 0, -1 };
567 register_number = register_numbers[(inst >> 29) & 7];
568 if (register_number == -1)
572 if ((inst & 0x10000000) != 0)
573 return register_value == 0;
574 return register_value != 0;
583 int r = (reg & 15) | ((crosspath ^ side) << 4);
592 int mask = (1 <<
bits) - 1;
593 int r = (value >> low_bit) & mask;
594 if ((r & (1 << (bits - 1))) != 0)
625 if ((inst & 0x0000007c) == 0x00000010)
632 if ((inst & 0x0f83effc) == 0x00000360)
642 if ((inst & 0x00001ffc) == 0x00001020)
654 if ((inst & 0x00001ffc) == 0x00000120)
661 if ((inst & 0x0f830ffe) == 0x00800362)
669 if ((inst & 0x00001ffc) == 0x00000020)
681 if ((inst & 0xf000007c) == 0x10000010)
722 enum bfd_endian byte_order,
gdb_byte *valbuf)
736 if (len < 3 && byte_order == BFD_ENDIAN_BIG)
749 if (byte_order == BFD_ENDIAN_BIG)
767 enum bfd_endian byte_order,
const gdb_byte *valbuf)
775 if (len < 3 && byte_order == BFD_ENDIAN_BIG)
783 if (byte_order == BFD_ENDIAN_BIG)
897 int stack_offset = 4;
898 int references_offset = 4;
904 int first_arg_on_stack = 10;
930 for (argnum = 0; argnum < nargs; argnum++)
933 if (argnum >= 10 - argreg)
934 references_offset +=
len;
946 for (argnum = 0; argnum < nargs; argnum++)
949 struct value *arg = args[argnum];
958 if (argreg < first_arg_on_stack)
972 if (len < 3 && byte_order == BFD_ENDIAN_BIG)
1001 if (byte_order == BFD_ENDIAN_BIG)
1043 references_offset =
align_up (references_offset, 8);
1045 addr = sp + references_offset;
1047 references_offset +=
align_up (len, 4);
1081 stack_offset =
align_up (stack_offset,
1090 references_offset =
align_up (references_offset, 8);
1092 addr = sp + references_offset;
1096 references_offset +=
align_up (len, 4);
1106 _(
"unexpected type %d of arg %d"),
1111 _(
"unexpected length %d of arg %d"), len, argnum);
1113 addr = sp + stack_offset;
1132 if ((inst & 0x0f83effc) == 0x360)
1177 static struct gdbarch *
1180 struct gdbarch *gdbarch;
1194 if (feature == NULL)
1200 for (i = 0; i < 32; i++)
1220 static const char *
const gp[] =
1222 "A16",
"A17",
"A18",
"A19",
"A20",
"A21",
"A22",
"A23",
1223 "A24",
"A25",
"A26",
"A27",
"A28",
"A29",
"A30",
"A31",
1224 "B16",
"B17",
"B18",
"B19",
"B20",
"B21",
"B22",
"B23",
1225 "B24",
"B25",
"B26",
"B27",
"B28",
"B29",
"B30",
"B31",
1230 for (j = 0; j < 32; j++)
1264 if (has_gp != tdep->
has_gp)
const gdb_byte tic6x_bkpt_illegal_opcode_be[]
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
static int tic6x_extract_signed_field(int value, int low_bit, int bits)
void set_gdbarch_double_bit(struct gdbarch *gdbarch, int double_bit)
void set_gdbarch_frame_align(struct gdbarch *gdbarch, gdbarch_frame_align_ftype frame_align)
void set_gdbarch_float_format(struct gdbarch *gdbarch, const struct floatformat **float_format)
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
CORE_ADDR(* syscall_next_pc)(struct frame_info *frame)
#define TIC6X_FETCH_PACKET_SIZE
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
CORE_ADDR extract_typed_address(const gdb_byte *buf, struct type *type)
void set_gdbarch_get_longjmp_target(struct gdbarch *gdbarch, gdbarch_get_longjmp_target_ftype get_longjmp_target)
CORE_ADDR get_frame_address_in_block(struct frame_info *this_frame)
static unsigned long tic6x_fetch_instruction(struct gdbarch *, CORE_ADDR)
struct type * builtin_func_ptr
void set_gdbarch_float_bit(struct gdbarch *gdbarch, int float_bit)
CORE_ADDR get_frame_pc(struct frame_info *frame)
static int tic6x_software_single_step(struct frame_info *frame)
void gdbarch_init_osabi(struct gdbarch_info info, struct gdbarch *gdbarch)
static CORE_ADDR tic6x_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR start_pc)
static const struct frame_unwind tic6x_frame_unwind
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
struct value * frame_unwind_got_memory(struct frame_info *frame, int regnum, CORE_ADDR addr)
static int tic6x_condition_true(struct frame_info *frame, unsigned long inst)
ULONGEST align_down(ULONGEST v, int n)
ULONGEST frame_unwind_register_unsigned(struct frame_info *frame, int regnum)
void regcache_cooked_write_signed(struct regcache *regcache, int regnum, LONGEST val)
void set_gdbarch_short_bit(struct gdbarch *gdbarch, int short_bit)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
static void initialize_tdesc_tic6x_c64x(void)
void internal_error(const char *file, int line, const char *fmt,...)
static void tic6x_setup_default(struct tic6x_unwind_cache *cache)
void frame_unwind_register(struct frame_info *frame, int regnum, gdb_byte *buf)
const char * tdesc_register_name(struct gdbarch *gdbarch, int regno)
static struct gdbarch * tic6x_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
static int tic6x_arg_type_alignment(struct type *type)
static void tic6x_dwarf2_frame_init_reg(struct gdbarch *gdbarch, int regnum, struct dwarf2_frame_state_reg *reg, struct frame_info *this_frame)
const gdb_byte * breakpoint
static const char * tic6x_register_name(struct gdbarch *gdbarch, int regno)
void regcache_cooked_write_part(struct regcache *regcache, int regnum, int offset, int len, const gdb_byte *buf)
enum language la_language
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 gdbarch_list * next
struct address_space * get_frame_address_space(struct frame_info *frame)
void set_gdbarch_return_in_first_hidden_param_p(struct gdbarch *gdbarch, gdbarch_return_in_first_hidden_param_p_ftype return_in_first_hidden_param_p)
static int tic6x_return_in_first_hidden_param_p(struct gdbarch *gdbarch, struct type *type)
#define bits(obj, st, fn)
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
void tdesc_data_cleanup(void *data_untyped)
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
#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 CORE_ADDR tic6x_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)
static struct tic6x_unwind_cache * tic6x_make_stub_cache(struct frame_info *this_frame)
void set_gdbarch_addr_bit(struct gdbarch *gdbarch, int addr_bit)
int tdesc_numbered_register(const struct tdesc_feature *feature, struct tdesc_arch_data *data, int regno, const char *name)
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
static int tic6x_register_number(int reg, int side, int crosspath)
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype register_type)
struct type * check_typedef(struct type *type)
const gdb_byte * value_contents(struct value *value)
void dwarf2_frame_set_init_reg(struct gdbarch *gdbarch, void(*init_reg)(struct gdbarch *, int, struct dwarf2_frame_state_reg *, struct frame_info *))
void initialize_file_ftype(void)
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
static CORE_ADDR tic6x_frame_base_address(struct frame_info *this_frame, void **this_cache)
void set_gdbarch_stack_frame_destroyed_p(struct gdbarch *gdbarch, gdbarch_stack_frame_destroyed_p_ftype stack_frame_destroyed_p)
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)
static const char *const tic6x_register_names[]
static int tic6x_get_longjmp_target(struct frame_info *frame, CORE_ADDR *pc)
void insert_single_step_breakpoint(struct gdbarch *gdbarch, struct address_space *aspace, CORE_ADDR next_pc)
#define gdb_assert_not_reached(message)
static struct type * tic6x_register_type(struct gdbarch *gdbarch, int regno)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
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)
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)
struct type * builtin_uint32
int default_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache)
#define TIC6X_OPCODE_SIZE
void set_gdbarch_unwind_sp(struct gdbarch *gdbarch, gdbarch_unwind_sp_ftype unwind_sp)
static struct frame_id tic6x_dummy_id(struct gdbarch *gdbarch, struct frame_info *this_frame)
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
static CORE_ADDR tic6x_analyze_prologue(struct gdbarch *gdbarch, const CORE_ADDR start_pc, const CORE_ADDR current_pc, struct tic6x_unwind_cache *cache, struct frame_info *this_frame)
void set_gdbarch_long_long_bit(struct gdbarch *gdbarch, int long_long_bit)
const struct target_desc * target_desc
static int tic6x_stack_frame_destroyed_p(struct gdbarch *gdbarch, CORE_ADDR pc)
void set_gdbarch_software_single_step(struct gdbarch *gdbarch, gdbarch_software_single_step_ftype software_single_step)
static void initialize_tdesc_tic6x_c62x(void)
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
static CORE_ADDR tic6x_unwind_sp(struct gdbarch *gdbarch, struct frame_info *this_frame)
void tdesc_use_registers(struct gdbarch *gdbarch, const struct target_desc *target_desc, struct tdesc_arch_data *early_data)
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
ULONGEST align_up(ULONGEST v, int n)
const struct language_defn * current_language
#define TYPE_TARGET_TYPE(thistype)
static const gdb_byte * tic6x_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *bp_addr, int *bp_size)
#define TYPE_CODE(thistype)
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)
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
CORE_ADDR find_function_addr(struct value *function, struct type **retval_type)
static int in_plt_section(CORE_ADDR pc)
static int tic6x_stub_unwind_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache)
void set_gdbarch_int_bit(struct gdbarch *gdbarch, int int_bit)
CORE_ADDR reg_saved[TIC6X_NUM_CORE_REGS]
static void tic6x_stub_this_id(struct frame_info *this_frame, void **this_cache, struct frame_id *this_id)
static const int arg_regs[]
#define TYPE_NFIELDS(thistype)
void dwarf2_append_unwinders(struct gdbarch *gdbarch)
enum register_status regcache_cooked_read(struct regcache *regcache, int regnum, gdb_byte *buf)
static CORE_ADDR tic6x_unwind_pc(struct gdbarch *gdbarch, struct frame_info *next_frame)
static int tic6x_print_insn(bfd_vma memaddr, disassemble_info *info)
#define CHECK_TYPEDEF(TYPE)
void set_gdbarch_double_format(struct gdbarch *gdbarch, const struct floatformat **double_format)
static void tic6x_frame_this_id(struct frame_info *this_frame, void **this_cache, struct frame_id *this_id)
struct tdesc_arch_data * tdesc_data_alloc(void)
unsigned long long ULONGEST
enum unwind_stop_reason default_frame_unwind_stop_reason(struct frame_info *this_frame, void **this_cache)
const struct tdesc_feature * tdesc_find_feature(const struct target_desc *target_desc, const char *name)
static void initialize_tdesc_tic6x_c64xp(void)
static CORE_ADDR tic6x_frame_align(struct gdbarch *gdbarch, CORE_ADDR addr)
struct type * value_type(const struct value *value)
void set_gdbarch_long_bit(struct gdbarch *gdbarch, int long_bit)
enum register_status regcache_cooked_read_part(struct regcache *regcache, int regnum, int offset, int len, gdb_byte *buf)
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype return_value)
int gdbarch_pc_regnum(struct gdbarch *gdbarch)
#define TYPE_LENGTH(thistype)
void set_gdbarch_ptr_bit(struct gdbarch *gdbarch, int ptr_bit)
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 void tic6x_extract_return_value(struct type *valtype, struct regcache *regcache, enum bfd_endian byte_order, gdb_byte *valbuf)
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)
static struct value * tic6x_frame_prev_register(struct frame_info *this_frame, void **this_cache, int regnum)
static struct gdbarch_data * tdesc_data
PTR xcalloc(size_t number, size_t size)
enum bfd_endian byte_order
static struct tic6x_unwind_cache * tic6x_frame_unwind_cache(struct frame_info *this_frame, void **this_prologue_cache)
initialize_file_ftype _initialize_tic6x_tdep
enum bfd_endian gdbarch_byte_order_for_code(struct gdbarch *gdbarch)
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
static void tic6x_store_return_value(struct type *valtype, struct regcache *regcache, enum bfd_endian byte_order, const gdb_byte *valbuf)
int tdesc_has_registers(const struct target_desc *target_desc)
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype register_name)
static CORE_ADDR tic6x_get_next_pc(struct frame_info *frame, CORE_ADDR pc)
CORE_ADDR get_frame_func(struct frame_info *this_frame)
static enum return_value_convention tic6x_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
enum dwarf2_frame_reg_rule how
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)
const gdb_byte tic6x_bkpt_illegal_opcode_le[]
void regcache_cooked_write(struct regcache *regcache, int regnum, const gdb_byte *buf)
int language_pass_by_reference(struct type *type)
void set_gdbarch_print_insn(struct gdbarch *gdbarch, gdbarch_print_insn_ftype print_insn)
const struct target_desc * gdbarch_target_desc(struct gdbarch *gdbarch)
const ULONGEST const LONGEST len