34 #include "floatformat.h"
43 #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, alignlen;
292 static const gdb_byte four_zero_words[16] = { 0 };
328 for (j = nargs - 1; j >= i; j--)
335 slacklen =
align_up (typelen, 8) - typelen;
336 val =
xmalloc (typelen + slacklen);
338 memcpy (val, contents, typelen);
339 memset (val + typelen, 0, slacklen);
342 stack_dest -= typelen + slacklen;
348 stack_dest = stack_dest - 16;
381 gdb_byte instbuf[32 * TILEGX_BUNDLE_SIZE_IN_BYTES];
383 unsigned int instbuf_size;
386 struct tilegx_decoded_instruction
387 decoded[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE];
391 new_reverse_frame[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE];
392 int dest_regs[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE];
393 int reverse_frame_valid, prolog_done, branch_seen, lr_saved_on_stack_p;
397 if (start_addr >= end_addr
398 || (start_addr % TILEGX_BUNDLE_ALIGNMENT_IN_BYTES) != 0)
404 memcpy (&reverse_frame, &template_reverse_regs,
sizeof (reverse_frame));
409 lr_saved_on_stack_p = 0;
417 for (next_addr = start_addr;
418 next_addr < end_addr;
419 next_addr += TILEGX_BUNDLE_SIZE_IN_BYTES)
422 if (next_addr - instbuf_start >= instbuf_size)
427 unsigned int size_on_same_page = 4096 - (next_addr & 4095);
429 instbuf_size =
sizeof instbuf;
431 if (instbuf_size > size_on_same_page)
432 instbuf_size = size_on_same_page;
434 instbuf_size =
min (instbuf_size, (end_addr - next_addr));
435 instbuf_start = next_addr;
438 instbuf, instbuf_size);
443 reverse_frame_valid = 0;
448 num_insns = parse_insn_tilegx (bundle, next_addr, decoded);
450 for (i = 0; i < num_insns; i++)
452 struct tilegx_decoded_instruction *this_insn = &decoded[i];
453 int64_t *operands = (int64_t *) this_insn->operand_values;
454 const struct tilegx_opcode *opcode = this_insn->opcode;
456 switch (opcode->mnemonic)
461 && reverse_frame[operands[1]].state
464 LONGEST saved_address = reverse_frame[operands[0]].
value;
465 unsigned saved_register
466 = (unsigned) reverse_frame[operands[1]].
value;
479 lr_saved_on_stack_p = 1;
481 case TILEGX_OPC_ADDI:
482 case TILEGX_OPC_ADDLI:
489 uint64_t hopefully_sp
490 = (unsigned) reverse_frame[operands[1]].
value;
491 short op2_as_short = (short) operands[2];
492 signed char op2_as_char = (
signed char) operands[2];
495 if (opcode->mnemonic == TILEGX_OPC_ADDI)
496 op2_as_short = op2_as_char;
501 new_reverse_frame[i].
value
504 hopefully_sp, prev_sp_value);
508 short op2_as_short = (short) operands[2];
509 signed char op2_as_char = (
signed char) operands[2];
512 if (opcode->mnemonic == TILEGX_OPC_ADDI)
513 op2_as_short = op2_as_char;
515 new_reverse_frame[i] = reverse_frame[operands[1]];
517 new_reverse_frame[i].
value += op2_as_short;
521 reverse_frame_valid |= 1 << i;
522 dest_regs[i] = operands[0];
529 new_reverse_frame[i] = reverse_frame[operands[2]];
530 new_reverse_frame[i].
value
531 += reverse_frame[operands[i]].
value;
538 reverse_frame_valid |= 1 << i;
539 dest_regs[i] = operands[0];
541 case TILEGX_OPC_MOVE:
542 new_reverse_frame[i] = reverse_frame[operands[1]];
543 reverse_frame_valid |= 1 << i;
544 dest_regs[i] = operands[0];
546 case TILEGX_OPC_MOVEI:
547 case TILEGX_OPC_MOVELI:
549 new_reverse_frame[i].
value = operands[1];
550 reverse_frame_valid |= 1 << i;
551 dest_regs[i] = operands[0];
557 new_reverse_frame[i] = reverse_frame[operands[1]];
558 new_reverse_frame[i].
value
559 = reverse_frame[operands[1]].
value | operands[2];
561 else if (operands[2] == 0)
564 new_reverse_frame[i] = reverse_frame[operands[1]];
571 reverse_frame_valid |= 1 << i;
572 dest_regs[i] = operands[0];
576 && reverse_frame[operands[1]].
value == 0)
579 new_reverse_frame[i] = reverse_frame[operands[2]];
582 && reverse_frame[operands[2]].
value == 0)
585 new_reverse_frame[i] = reverse_frame[operands[1]];
592 reverse_frame_valid |= 1 << i;
593 dest_regs[i] = operands[0];
600 new_reverse_frame[i] = reverse_frame[operands[1]];
601 new_reverse_frame[i].
value
602 -= reverse_frame[operands[2]].
value;
609 reverse_frame_valid |= 1 << i;
610 dest_regs[i] = operands[0];
613 case TILEGX_OPC_FNOP:
614 case TILEGX_OPC_INFO:
615 case TILEGX_OPC_INFOL:
625 case TILEGX_OPC_BEQZ:
626 case TILEGX_OPC_BEQZT:
627 case TILEGX_OPC_BGEZ:
628 case TILEGX_OPC_BGEZT:
629 case TILEGX_OPC_BGTZ:
630 case TILEGX_OPC_BGTZT:
631 case TILEGX_OPC_BLBC:
632 case TILEGX_OPC_BLBCT:
633 case TILEGX_OPC_BLBS:
634 case TILEGX_OPC_BLBST:
635 case TILEGX_OPC_BLEZ:
636 case TILEGX_OPC_BLEZT:
637 case TILEGX_OPC_BLTZ:
638 case TILEGX_OPC_BLTZT:
639 case TILEGX_OPC_BNEZ:
640 case TILEGX_OPC_BNEZT:
642 case TILEGX_OPC_IRET:
643 case TILEGX_OPC_JALR:
644 case TILEGX_OPC_JALRP:
647 case TILEGX_OPC_SWINT0:
648 case TILEGX_OPC_SWINT1:
649 case TILEGX_OPC_SWINT2:
650 case TILEGX_OPC_SWINT3:
660 for (j = 0; j < opcode->num_operands; j++)
662 if (this_insn->operands[j]->is_dest_reg)
664 dest_regs[i] = operands[j];
666 reverse_frame_valid |= 1 << i;
675 for (i = 0; i < num_insns; i++)
678 if ((reverse_frame_valid & (1 << i))
680 reverse_frame[dest_regs[i]] = new_reverse_frame[i];
683 if (prev_sp_value != 0)
696 if (prolog_done && prolog_end == end_addr)
704 prolog_end = next_addr;
713 if (prolog_end == end_addr && cache)
722 && reverse_frame[i].
value != i)
724 unsigned saved_register = (unsigned) reverse_frame[i].
value;
732 if (lr_saved_on_stack_p)
757 if (post_prologue_pc != 0)
758 return max (start_pc, post_prologue_pc);
763 end_pc = start_pc + 8 * TILEGX_BUNDLE_SIZE_IN_BYTES;
784 CORE_ADDR addr = func_end - TILEGX_BUNDLE_SIZE_IN_BYTES;
820 #define INT_SWINT_1_SIGRETURN (~0)
849 static const unsigned char *
855 { 0x00, 0x50, 0x48, 0x51, 0xae, 0x44, 0x6a, 0x28 };
857 *lenptr =
sizeof (breakpoint);
946 tilegx_frame_base_address
986 static struct gdbarch *
989 struct gdbarch *gdbarch;
994 arch_size = bfd_get_arch_size (info.
abfd);
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)
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
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)
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 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)
initialize_file_ftype _initialize_tilegx_tdep
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)
void initialize_file_ftype(void)
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)
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)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int status
struct type * value_enclosing_type(struct value *value)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
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 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)
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
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)
static struct tilegx_frame_cache * tilegx_frame_cache(struct frame_info *this_frame, void **this_cache)
static const unsigned char * tilegx_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
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)
struct trad_frame_saved_reg * trad_frame_alloc_saved_regs(struct frame_info *this_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)
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)
#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 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 do_cleanups(struct cleanup *old_chain)
void set_gdbarch_print_insn(struct gdbarch *gdbarch, gdbarch_print_insn_ftype print_insn)
void regcache_raw_write(struct regcache *regcache, int regnum, const gdb_byte *buf)
const ULONGEST const LONGEST len