37 #include "opcodes/microblaze-opcm.h" 38 #include "opcodes/microblaze-dis.h" 50 #define IS_RETURN(op) (op == rtsd || op == rtid) 51 #define IS_UPDATE_SP(op, rd, ra) \ 52 ((op == addik || op == addi) && rd == REG_SP && ra == REG_SP) 53 #define IS_SPILL_SP(op, rd, ra) \ 54 ((op == swi || op == sw) && rd == REG_SP && ra == REG_SP) 55 #define IS_SPILL_REG(op, rd, ra) \ 56 ((op == swi || op == sw) && rd != REG_SP && ra == REG_SP) 57 #define IS_ALSO_SPILL_REG(op, rd, ra, rb) \ 58 ((op == swi || op == sw) && rd != REG_SP && ra == 0 && rb == REG_SP) 59 #define IS_SETUP_FP(op, ra, rb) \ 60 ((op == add || op == addik || op == addk) && ra == REG_SP && rb == 0) 61 #define IS_SPILL_REG_FP(op, rd, ra, fpregnum) \ 62 ((op == swi || op == sw) && rd != REG_SP && ra == fpregnum && ra != 0) 63 #define IS_SAVE_HIDDEN_PTR(op, rd, ra, rb) \ 64 ((op == add || op == addik) && ra == MICROBLAZE_FIRST_ARGREG && rb == 0) 70 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
71 "r8",
"r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15",
72 "r16",
"r17",
"r18",
"r19",
"r20",
"r21",
"r22",
"r23",
73 "r24",
"r25",
"r26",
"r27",
"r28",
"r29",
"r30",
"r31",
74 "rpc",
"rmsr",
"rear",
"resr",
"rfsr",
"rbtr",
75 "rpvr0",
"rpvr1",
"rpvr2",
"rpvr3",
"rpvr4",
"rpvr5",
"rpvr6",
76 "rpvr7",
"rpvr8",
"rpvr9",
"rpvr10",
"rpvr11",
77 "redr",
"rpid",
"rzpr",
"rtlbx",
"rtlbsx",
"rtlblo",
"rtlbhi",
81 #define MICROBLAZE_NUM_REGS ARRAY_SIZE (microblaze_register_names) 86 microblaze_debug (const
char *fmt, ...)
145 microblaze_alloc_frame_cache (
void)
167 #define MICROBLAZE_MY_FRAME_IN_SP 0x1 174 #define MICROBLAZE_MY_FRAME_IN_FP 0x2 203 CORE_ADDR func_addr, func_end, addr, stop, prologue_end_addr = 0;
206 enum microblaze_instr op;
208 int save_hidden_pointer_found = 0;
209 int non_stack_instruction_found = 0;
236 op = microblaze_decode_insn (insn, &rd, &ra, &rb, &imm);
243 stop = (current_pc < func_end ? current_pc : func_end);
245 microblaze_debug (
"Scanning prologue: name=%s, func_addr=%s, stop=%s\n",
252 op = microblaze_decode_insn (insn, &rd, &ra, &rb, &imm);
260 microblaze_debug (
"got addi r1,r1,%d; contnuing\n", imm);
265 save_hidden_pointer_found = 0;
266 non_stack_instruction_found = 0;
274 microblaze_debug (
"swi r1 r1 %d, continuing\n", imm);
275 save_hidden_pointer_found = 0;
277 non_stack_instruction_found = 0;
285 microblaze_debug (
"swi %d r1 %d, continuing\n", rd, imm);
286 save_hidden_pointer_found = 0;
288 non_stack_instruction_found = 0;
296 microblaze_debug (
"sw %d r0 r1, continuing\n", rd);
297 save_hidden_pointer_found = 0;
299 non_stack_instruction_found = 0;
309 microblaze_debug (
"Found a frame pointer: r%d\n", cache->
fp_regnum);
310 save_hidden_pointer_found = 0;
312 non_stack_instruction_found = 0;
320 microblaze_debug (
"swi %d %d %d, continuing\n", rd, ra, imm);
321 save_hidden_pointer_found = 0;
323 non_stack_instruction_found = 0;
332 microblaze_debug (
"add %d %d %d, continuing\n", rd, ra, rb);
333 save_hidden_pointer_found = 1;
335 non_stack_instruction_found = 0;
344 if (!non_stack_instruction_found)
345 prologue_end_addr = addr;
346 non_stack_instruction_found = 1;
356 unsigned op = (unsigned)insn >> 26;
359 if (op != 0x26 && op != 0x27 && op != 0x2d && op != 0x2e && op != 0x2f)
366 microblaze_debug (
"insn is not a prologue insn -- ending scan\n");
370 microblaze_debug (
"done analyzing prologue\n");
371 microblaze_debug (
"prologue end = 0x%x\n", (
int) addr);
375 if (save_hidden_pointer_found)
378 return prologue_end_addr;
404 CORE_ADDR func_start, func_end, ostart_pc;
415 if (sal.
end < func_end
416 && start_pc <= sal.
end)
423 if (ostart_pc > start_pc)
440 cache = microblaze_alloc_frame_cache ();
464 if (cache->
base == 0)
470 static struct value *
472 void **this_cache,
int regnum)
547 _(
"Unsupported return value size requested"));
568 memset (buf, 0,
sizeof(buf));
575 memcpy (buf, valbuf, 8);
580 memcpy (buf + 4 - len, valbuf, len);
676 "org.gnu.gdb.microblaze.core");
686 "org.gnu.gdb.microblaze.stack-protect");
735 microblaze_breakpoint::kind_from_pc);
737 microblaze_breakpoint::bp_from_kind);
772 Set microblaze debugging."),
_(
"\ 773 Show microblaze debugging."),
_(
"\ 774 When non-zero, microblaze specific debugging is enabled."),
struct gdbarch * target_gdbarch(void)
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
#define IS_SPILL_REG(op, rd, ra)
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)
CORE_ADDR get_frame_address_in_block(struct frame_info *this_frame)
#define IS_SPILL_REG_FP(op, rd, ra, fpregnum)
struct type * builtin_func_ptr
struct trad_frame_saved_reg * saved_regs
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)
struct target_desc * tdesc_microblaze_with_stack_protect
void set_gdbarch_write_pc(struct gdbarch *gdbarch, gdbarch_write_pc_ftype write_pc)
static int dwarf2_to_reg_map[78]
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
static CORE_ADDR microblaze_analyze_prologue(struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR current_pc, struct microblaze_frame_cache *cache)
void * memset(T *s, int c, size_t n)=delete
void internal_error(const char *file, int line, const char *fmt,...)
void frame_unwind_register(struct frame_info *frame, int regnum, gdb_byte *buf)
#define MICROBLAZE_NUM_REGS
void set_gdbarch_stabs_argument_has_addr(struct gdbarch *gdbarch, gdbarch_stabs_argument_has_addr_ftype stabs_argument_has_addr)
struct gdbarch_list * gdbarch_list_lookup_by_info(struct gdbarch_list *arches, const struct gdbarch_info *info)
#define IS_SPILL_SP(op, rd, ra)
typedef BP_MANIPULATION(microblaze_break_insn)
int gdbarch_num_regs(struct gdbarch *gdbarch)
#define MICROBLAZE_MY_FRAME_IN_FP
void set_gdbarch_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, gdbarch_dwarf2_reg_to_regnum_ftype dwarf2_reg_to_regnum)
static CORE_ADDR microblaze_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR start_pc)
static void microblaze_frame_this_id(struct frame_info *next_frame, void **this_cache, struct frame_id *this_id)
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)
static void microblaze_register_g_packet_guesses(struct gdbarch *gdbarch)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
#define IS_UPDATE_SP(op, rd, ra)
static CORE_ADDR microblaze_unwind_pc(struct gdbarch *gdbarch, struct frame_info *next_frame)
int target_read_code(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
void add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
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 unsigned long microblaze_fetch_instruction(CORE_ADDR pc)
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype register_type)
const struct frame_base * dwarf2_frame_base_sniffer(struct frame_info *this_frame)
#define IS_SETUP_FP(op, ra, rb)
void register_remote_g_packet_guess(struct gdbarch *gdbarch, int bytes, const struct target_desc *tdesc)
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
static void initialize_tdesc_microblaze(void)
static void initialize_tdesc_microblaze_with_stack_protect(void)
#define MICROBLAZE_REGISTER_SIZE
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
void set_gdbarch_sp_regnum(struct gdbarch *gdbarch, int sp_regnum)
static const struct frame_base microblaze_frame_base
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
static void ATTRIBUTE_PRINTF(1, 2)
struct target_desc * tdesc_microblaze
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)
static CORE_ADDR microblaze_frame_base_address(struct frame_info *next_frame, void **this_cache)
int default_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache)
void printf_unfiltered(const char *format,...)
struct cmd_list_element * setdebuglist
constexpr gdb_byte microblaze_break_insn[]
static struct microblaze_frame_cache * microblaze_frame_cache(struct frame_info *next_frame, void **this_cache)
void set_gdbarch_breakpoint_kind_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_kind_from_pc_ftype breakpoint_kind_from_pc)
static const char * microblaze_register_names[]
struct trad_frame_saved_reg * trad_frame_alloc_saved_regs(struct gdbarch *gdbarch)
void set_gdbarch_frame_args_skip(struct gdbarch *gdbarch, CORE_ADDR frame_args_skip)
const struct target_desc * target_desc
static int microblaze_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, int reg)
void vprintf_unfiltered(const char *format, va_list args)
#define IS_SAVE_HIDDEN_PTR(op, rd, ra, rb)
void _initialize_microblaze_tdep(void)
static struct value * microblaze_frame_prev_register(struct frame_info *this_frame, void **this_cache, int regnum)
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)
static enum return_value_convention microblaze_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
static const char * microblaze_register_name(struct gdbarch *gdbarch, int regnum)
int frame_relative_level(struct frame_info *fi)
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
struct type * builtin_data_ptr
static void microblaze_write_pc(struct regcache *regcache, CORE_ADDR pc)
void dwarf2_append_unwinders(struct gdbarch *gdbarch)
enum register_status regcache_cooked_read(struct regcache *regcache, int regnum, gdb_byte *buf)
struct tdesc_arch_data * tdesc_data_alloc(void)
void frame_base_append_sniffer(struct gdbarch *gdbarch, frame_base_sniffer_ftype *sniffer)
void set_gdbarch_call_dummy_location(struct gdbarch *gdbarch, int call_dummy_location)
#define MICROBLAZE_MY_FRAME_IN_SP
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)
void set_gdbarch_long_double_bit(struct gdbarch *gdbarch, int long_double_bit)
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype return_value)
struct cmd_list_element * showdebuglist
static void microblaze_store_return_value(struct type *type, struct regcache *regcache, const gdb_byte *valbuf)
#define TYPE_LENGTH(thistype)
static void microblaze_extract_return_value(struct type *type, struct regcache *regcache, gdb_byte *valbuf)
static struct gdbarch * microblaze_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
#define IS_ALSO_SPILL_REG(op, rd, ra, rb)
static struct type * microblaze_register_type(struct gdbarch *gdbarch, int regnum)
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 set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype skip_prologue)
static struct gdbarch_data * tdesc_data
static const struct frame_unwind microblaze_frame_unwind
int register_offsets[MICROBLAZE_NUM_REGS]
static int microblaze_stabs_argument_has_addr(struct gdbarch *gdbarch, struct type *type)
static unsigned int microblaze_debug_flag
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
int tdesc_has_registers(const struct target_desc *target_desc)
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_cooked_write(struct regcache *regcache, int regnum, const gdb_byte *buf)
struct type * builtin_int
#define MICROBLAZE_BREAKPOINT