41 #include "opcode/tilegx.h" 147 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
148 "r8",
"r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15",
149 "r16",
"r17",
"r18",
"r19",
"r20",
"r21",
"r22",
"r23",
150 "r24",
"r25",
"r26",
"r27",
"r28",
"r29",
"r30",
"r31",
151 "r32",
"r33",
"r34",
"r35",
"r36",
"r37",
"r38",
"r39",
152 "r40",
"r41",
"r42",
"r43",
"r44",
"r45",
"r46",
"r47",
153 "r48",
"r49",
"r50",
"r51",
"r52",
"tp",
"sp",
"lr",
154 "sn",
"idn0",
"idn1",
"udn0",
"udn1",
"udn2",
"udn3",
"zero",
160 "tilegx_register_name: invalid register number %d",
163 return register_names[
regnum];
280 struct value *
function,
291 int typelen, slacklen;
292 static const gdb_byte four_zero_words[16] = { 0 };
328 for (j = nargs - 1; j >= i; j--)
333 slacklen =
align_up (typelen, 8) - typelen;
335 memcpy (val.data (), contents, typelen);
336 memset (val.data () + typelen, 0, slacklen);
339 stack_dest -= typelen + slacklen;
340 write_memory (stack_dest, val.data (), typelen + slacklen);
344 stack_dest = stack_dest - 16;
374 gdb_byte instbuf[32 * TILEGX_BUNDLE_SIZE_IN_BYTES];
376 unsigned int instbuf_size;
379 struct tilegx_decoded_instruction
380 decoded[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE];
384 new_reverse_frame[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE];
385 int dest_regs[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE];
386 int reverse_frame_valid, prolog_done, branch_seen, lr_saved_on_stack_p;
390 if (start_addr >= end_addr
391 || (start_addr % TILEGX_BUNDLE_ALIGNMENT_IN_BYTES) != 0)
402 lr_saved_on_stack_p = 0;
410 for (next_addr = start_addr;
411 next_addr < end_addr;
412 next_addr += TILEGX_BUNDLE_SIZE_IN_BYTES)
415 if (next_addr - instbuf_start >= instbuf_size)
420 unsigned int size_on_same_page = 4096 - (next_addr & 4095);
422 instbuf_size =
sizeof instbuf;
424 if (instbuf_size > size_on_same_page)
425 instbuf_size = size_on_same_page;
427 instbuf_size = std::min ((
CORE_ADDR) instbuf_size,
428 (end_addr - next_addr));
429 instbuf_start = next_addr;
432 instbuf, instbuf_size);
437 reverse_frame_valid = 0;
442 num_insns = parse_insn_tilegx (bundle, next_addr, decoded);
444 for (i = 0; i < num_insns; i++)
446 struct tilegx_decoded_instruction *this_insn = &decoded[i];
447 long long *operands = this_insn->operand_values;
448 const struct tilegx_opcode *opcode = this_insn->opcode;
450 switch (opcode->mnemonic)
455 && reverse_frame[operands[1]].state
458 LONGEST saved_address = reverse_frame[operands[0]].
value;
459 unsigned saved_register
460 = (unsigned) reverse_frame[operands[1]].
value;
473 lr_saved_on_stack_p = 1;
475 case TILEGX_OPC_ADDI:
476 case TILEGX_OPC_ADDLI:
483 uint64_t hopefully_sp
484 = (unsigned) reverse_frame[operands[1]].
value;
485 short op2_as_short = (short) operands[2];
486 signed char op2_as_char = (
signed char) operands[2];
489 if (opcode->mnemonic == TILEGX_OPC_ADDI)
490 op2_as_short = op2_as_char;
495 new_reverse_frame[i].
value 498 hopefully_sp, prev_sp_value);
502 short op2_as_short = (short) operands[2];
503 signed char op2_as_char = (
signed char) operands[2];
506 if (opcode->mnemonic == TILEGX_OPC_ADDI)
507 op2_as_short = op2_as_char;
509 new_reverse_frame[i] = reverse_frame[operands[1]];
511 new_reverse_frame[i].
value += op2_as_short;
515 reverse_frame_valid |= 1 << i;
516 dest_regs[i] = operands[0];
523 new_reverse_frame[i] = reverse_frame[operands[2]];
524 new_reverse_frame[i].
value 525 += reverse_frame[operands[i]].
value;
532 reverse_frame_valid |= 1 << i;
533 dest_regs[i] = operands[0];
535 case TILEGX_OPC_MOVE:
536 new_reverse_frame[i] = reverse_frame[operands[1]];
537 reverse_frame_valid |= 1 << i;
538 dest_regs[i] = operands[0];
540 case TILEGX_OPC_MOVEI:
541 case TILEGX_OPC_MOVELI:
543 new_reverse_frame[i].
value = operands[1];
544 reverse_frame_valid |= 1 << i;
545 dest_regs[i] = operands[0];
551 new_reverse_frame[i] = reverse_frame[operands[1]];
552 new_reverse_frame[i].
value 553 = reverse_frame[operands[1]].
value | operands[2];
555 else if (operands[2] == 0)
558 new_reverse_frame[i] = reverse_frame[operands[1]];
565 reverse_frame_valid |= 1 << i;
566 dest_regs[i] = operands[0];
570 && reverse_frame[operands[1]].
value == 0)
573 new_reverse_frame[i] = reverse_frame[operands[2]];
576 && reverse_frame[operands[2]].
value == 0)
579 new_reverse_frame[i] = reverse_frame[operands[1]];
586 reverse_frame_valid |= 1 << i;
587 dest_regs[i] = operands[0];
594 new_reverse_frame[i] = reverse_frame[operands[1]];
595 new_reverse_frame[i].
value 596 -= reverse_frame[operands[2]].
value;
603 reverse_frame_valid |= 1 << i;
604 dest_regs[i] = operands[0];
607 case TILEGX_OPC_FNOP:
608 case TILEGX_OPC_INFO:
609 case TILEGX_OPC_INFOL:
619 case TILEGX_OPC_BEQZ:
620 case TILEGX_OPC_BEQZT:
621 case TILEGX_OPC_BGEZ:
622 case TILEGX_OPC_BGEZT:
623 case TILEGX_OPC_BGTZ:
624 case TILEGX_OPC_BGTZT:
625 case TILEGX_OPC_BLBC:
626 case TILEGX_OPC_BLBCT:
627 case TILEGX_OPC_BLBS:
628 case TILEGX_OPC_BLBST:
629 case TILEGX_OPC_BLEZ:
630 case TILEGX_OPC_BLEZT:
631 case TILEGX_OPC_BLTZ:
632 case TILEGX_OPC_BLTZT:
633 case TILEGX_OPC_BNEZ:
634 case TILEGX_OPC_BNEZT:
636 case TILEGX_OPC_IRET:
637 case TILEGX_OPC_JALR:
638 case TILEGX_OPC_JALRP:
641 case TILEGX_OPC_SWINT0:
642 case TILEGX_OPC_SWINT1:
643 case TILEGX_OPC_SWINT2:
644 case TILEGX_OPC_SWINT3:
654 for (j = 0; j < opcode->num_operands; j++)
656 if (this_insn->operands[j]->is_dest_reg)
658 dest_regs[i] = operands[j];
660 reverse_frame_valid |= 1 << i;
669 for (i = 0; i < num_insns; i++)
672 if ((reverse_frame_valid & (1 << i))
674 reverse_frame[dest_regs[i]] = new_reverse_frame[i];
677 if (prev_sp_value != 0)
690 if (prolog_done && prolog_end == end_addr)
698 prolog_end = next_addr;
707 if (prolog_end == end_addr && cache)
716 && reverse_frame[i].
value != i)
718 unsigned saved_register = (unsigned) reverse_frame[i].
value;
726 if (lr_saved_on_stack_p)
751 if (post_prologue_pc != 0)
752 return std::max (start_pc, post_prologue_pc);
757 end_pc = start_pc + 8 * TILEGX_BUNDLE_SIZE_IN_BYTES;
777 CORE_ADDR addr = func_end - TILEGX_BUNDLE_SIZE_IN_BYTES;
813 #define INT_SWINT_1_SIGRETURN (~0) 842 { 0x00, 0x50, 0x48, 0x51, 0xae, 0x44, 0x6a, 0x28 };
978 arch_size = bfd_get_arch_size (info.
abfd);
1048 tilegx_breakpoint::kind_from_pc);
1050 tilegx_breakpoint::bp_from_kind);
static struct gdbarch * tilegx_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
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_cannot_fetch_register(struct gdbarch *gdbarch, gdbarch_cannot_fetch_register_ftype cannot_fetch_register)
static CORE_ADDR tilegx_frame_base_address(struct frame_info *this_frame, void **this_cache)
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
void set_gdbarch_get_longjmp_target(struct gdbarch *gdbarch, gdbarch_get_longjmp_target_ftype get_longjmp_target)
static CORE_ADDR tilegx_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)
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 tilegx_cannot_reference_register(struct gdbarch *gdbarch, int regno)
void gdbarch_init_osabi(struct gdbarch_info info, struct gdbarch *gdbarch)
struct value * trad_frame_get_prev_register(struct frame_info *this_frame, struct trad_frame_saved_reg this_saved_regs[], int regnum)
static int tilegx_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, int num)
void trad_frame_set_value(struct trad_frame_saved_reg this_saved_regs[], int regnum, LONGEST val)
void set_gdbarch_write_pc(struct gdbarch *gdbarch, gdbarch_write_pc_ftype write_pc)
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
struct type * value_enclosing_type(const struct value *value)
ULONGEST frame_unwind_register_unsigned(struct frame_info *frame, int regnum)
void set_gdbarch_short_bit(struct gdbarch *gdbarch, int short_bit)
static void tilegx_extract_return_value(struct type *type, struct regcache *regcache, gdb_byte *valbuf)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
void * memset(T *s, int c, size_t n)=delete
void internal_error(const char *file, int line, const char *fmt,...)
#define obj_section_endaddr(s)
static CORE_ADDR tilegx_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR start_pc)
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
static CORE_ADDR tilegx_frame_align(struct gdbarch *gdbarch, CORE_ADDR addr)
static const struct frame_unwind tilegx_frame_unwind
void set_gdbarch_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, gdbarch_dwarf2_reg_to_regnum_ftype dwarf2_reg_to_regnum)
static void tilegx_write_pc(struct regcache *regcache, CORE_ADDR pc)
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
#define FRAME_OBSTACK_ZALLOC(TYPE)
void set_gdbarch_addr_bit(struct gdbarch *gdbarch, int addr_bit)
void memory_error(enum target_xfer_status err, CORE_ADDR memaddr)
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
static struct frame_id tilegx_unwind_dummy_id(struct gdbarch *gdbarch, struct frame_info *this_frame)
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype register_type)
const gdb_byte * value_contents(struct value *value)
static const struct frame_base tilegx_frame_base
void set_gdbarch_stack_frame_destroyed_p(struct gdbarch *gdbarch, gdbarch_stack_frame_destroyed_p_ftype stack_frame_destroyed_p)
static CORE_ADDR tilegx_unwind_sp(struct gdbarch *gdbarch, struct frame_info *next_frame)
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
int safe_frame_unwind_memory(struct frame_info *this_frame, CORE_ADDR addr, gdb_byte *buf, int len)
static CORE_ADDR tilegx_analyze_prologue(struct gdbarch *gdbarch, CORE_ADDR start_addr, CORE_ADDR end_addr, struct tilegx_frame_cache *cache, struct frame_info *next_frame)
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)
typedef BP_MANIPULATION(tilegx_break_insn)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
void set_gdbarch_cannot_store_register(struct gdbarch *gdbarch, gdbarch_cannot_store_register_ftype cannot_store_register)
int find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr)
void _initialize_tilegx_tdep(void)
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 enum return_value_convention tilegx_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
struct trad_frame_saved_reg * saved_regs
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
static int tilegx_get_longjmp_target(struct frame_info *frame, CORE_ADDR *pc)
void set_gdbarch_unwind_sp(struct gdbarch *gdbarch, gdbarch_unwind_sp_ftype unwind_sp)
static void tilegx_store_return_value(struct type *type, struct regcache *regcache, const void *valbuf)
struct obj_section * find_pc_section(CORE_ADDR pc)
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
void set_gdbarch_breakpoint_kind_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_kind_from_pc_ftype breakpoint_kind_from_pc)
struct trad_frame_saved_reg * trad_frame_alloc_saved_regs(struct gdbarch *gdbarch)
void set_gdbarch_long_long_bit(struct gdbarch *gdbarch, int long_long_bit)
static void tilegx_frame_this_id(struct frame_info *this_frame, void **this_cache, struct frame_id *this_id)
static CORE_ADDR tilegx_unwind_pc(struct gdbarch *gdbarch, struct frame_info *next_frame)
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
ULONGEST align_up(ULONGEST v, int n)
static struct value * tilegx_frame_prev_register(struct frame_info *this_frame, void **this_cache, int regnum)
static int tilegx_use_struct_convention(struct type *type)
#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)
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
void set_gdbarch_int_bit(struct gdbarch *gdbarch, int int_bit)
static struct type * tilegx_register_type(struct gdbarch *gdbarch, int regnum)
constexpr gdb_byte tilegx_break_insn[]
void set_gdbarch_num_pseudo_regs(struct gdbarch *gdbarch, int num_pseudo_regs)
void dwarf2_append_unwinders(struct gdbarch *gdbarch)
static int tilegx_type_is_scalar(struct type *t)
gdb::def_vector< gdb_byte > byte_vector
static const struct tilegx_reverse_regs template_reverse_regs[TILEGX_NUM_PHYS_REGS]
#define INT_SWINT_1_SIGRETURN
unsigned long long ULONGEST
enum unwind_stop_reason default_frame_unwind_stop_reason(struct frame_info *this_frame, void **this_cache)
void set_gdbarch_long_double_bit(struct gdbarch *gdbarch, int long_double_bit)
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)
#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)
static int tilegx_stack_frame_destroyed_p(struct gdbarch *gdbarch, CORE_ADDR pc)
struct type * builtin_uint64
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)
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)
enum bfd_endian byte_order
static const char * tilegx_register_name(struct gdbarch *gdbarch, int regnum)
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)
void regcache_raw_write(struct regcache *regcache, int regnum, const gdb_byte *buf)