diff options
Diffstat (limited to 'gdb/microblaze-tdep.c')
-rw-r--r-- | gdb/microblaze-tdep.c | 281 |
1 files changed, 140 insertions, 141 deletions
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c index 723dc7c..eafe260 100644 --- a/gdb/microblaze-tdep.c +++ b/gdb/microblaze-tdep.c @@ -41,7 +41,7 @@ #include "features/microblaze-with-stack-protect.c" #include "features/microblaze.c" - + /* Instruction macros used for analyzing the prologue. */ /* This set of instruction macros need to be changed whenever the prologue generated by the compiler could have more instructions or @@ -65,28 +65,25 @@ /* The registers of the Xilinx microblaze processor. */ -static const char * const microblaze_register_names[] = -{ - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", - "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", - "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", - "rpc", "rmsr", "rear", "resr", "rfsr", "rbtr", - "rpvr0", "rpvr1", "rpvr2", "rpvr3", "rpvr4", "rpvr5", "rpvr6", - "rpvr7", "rpvr8", "rpvr9", "rpvr10", "rpvr11", - "redr", "rpid", "rzpr", "rtlbx", "rtlbsx", "rtlblo", "rtlbhi", - "rslr", "rshr" -}; +static const char *const microblaze_register_names[] + = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", + "r7", "r8", "r9", "r10", "r11", "r12", "r13", + "r14", "r15", "r16", "r17", "r18", "r19", "r20", + "r21", "r22", "r23", "r24", "r25", "r26", "r27", + "r28", "r29", "r30", "r31", "rpc", "rmsr", "rear", + "resr", "rfsr", "rbtr", "rpvr0", "rpvr1", "rpvr2", "rpvr3", + "rpvr4", "rpvr5", "rpvr6", "rpvr7", "rpvr8", "rpvr9", "rpvr10", + "rpvr11", "redr", "rpid", "rzpr", "rtlbx", "rtlbsx", "rtlblo", + "rtlbhi", "rslr", "rshr" }; #define MICROBLAZE_NUM_REGS ARRAY_SIZE (microblaze_register_names) - + static unsigned int microblaze_debug_flag = 0; -#define microblaze_debug(fmt, ...) \ +#define microblaze_debug(fmt, ...) \ debug_prefixed_printf_cond_nofunc (microblaze_debug_flag, "MICROBLAZE", \ - fmt, ## __VA_ARGS__) + fmt, ##__VA_ARGS__) - /* Return the name of register REGNUM. */ static const char * @@ -109,7 +106,6 @@ microblaze_register_type (struct gdbarch *gdbarch, int regnum) return builtin_type (gdbarch)->builtin_int; } - /* Fetch the instruction at PC. */ static unsigned long @@ -124,12 +120,11 @@ microblaze_fetch_instruction (CORE_ADDR pc) return extract_unsigned_integer (buf, 4, byte_order); } - + constexpr gdb_byte microblaze_break_insn[] = MICROBLAZE_BREAKPOINT; typedef BP_MANIPULATION (microblaze_break_insn) microblaze_breakpoint; - /* Allocate and initialize a frame cache. */ static struct microblaze_frame_cache * @@ -186,7 +181,7 @@ microblaze_alloc_frame_cache (void) of "real" code (i.e., the end of the prologue). */ static CORE_ADDR -microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, +microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR current_pc, struct microblaze_frame_cache *cache) { @@ -206,10 +201,10 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, if (current_pc < pc) return current_pc; - /* Initialize info about frame. */ - cache->framesize = 0; - cache->fp_regnum = MICROBLAZE_SP_REGNUM; - cache->frameless_p = 1; + /* Initialize info about frame. */ + cache->framesize = 0; + cache->fp_regnum = MICROBLAZE_SP_REGNUM; + cache->frameless_p = 1; /* Start decoding the prologue. We start by checking two special cases: @@ -225,15 +220,15 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, insn = microblaze_fetch_instruction (pc); op = microblaze_decode_insn (insn, &rd, &ra, &rb, &imm); - if (IS_RETURN(op)) + if (IS_RETURN (op)) return pc; /* Start at beginning of function and analyze until we get to the current pc, or the end of the function, whichever is first. */ stop = (current_pc < func_end ? current_pc : func_end); - microblaze_debug ("Scanning prologue: name=%s, func_addr=%s, stop=%s\n", - name, paddress (gdbarch, func_addr), + microblaze_debug ("Scanning prologue: name=%s, func_addr=%s, stop=%s\n", + name, paddress (gdbarch, func_addr), paddress (gdbarch, stop)); for (addr = func_addr; addr < stop; addr += INST_WORD_SIZE) @@ -245,18 +240,18 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, /* This code is very sensitive to what functions are present in the prologue. It assumes that the (addi, addik, swi, sw) can be the only instructions in the prologue. */ - if (IS_UPDATE_SP(op, rd, ra)) + if (IS_UPDATE_SP (op, rd, ra)) { microblaze_debug ("got addi r1,r1,%d; contnuing\n", imm); if (cache->framesize) - break; /* break if framesize already computed. */ + break; /* break if framesize already computed. */ cache->framesize = -imm; /* stack grows towards low memory. */ - cache->frameless_p = 0; /* Frame found. */ + cache->frameless_p = 0; /* Frame found. */ save_hidden_pointer_found = 0; non_stack_instruction_found = 0; continue; } - else if (IS_SPILL_SP(op, rd, ra)) + else if (IS_SPILL_SP (op, rd, ra)) { /* Spill stack pointer. */ cache->register_offsets[rd] = imm; /* SP spilled before updating. */ @@ -267,7 +262,7 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, non_stack_instruction_found = 0; continue; } - else if (IS_SPILL_REG(op, rd, ra)) + else if (IS_SPILL_REG (op, rd, ra)) { /* Spill register. */ cache->register_offsets[rd] = imm - cache->framesize; @@ -278,7 +273,7 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, non_stack_instruction_found = 0; continue; } - else if (IS_ALSO_SPILL_REG(op, rd, ra, rb)) + else if (IS_ALSO_SPILL_REG (op, rd, ra, rb)) { /* Spill register. */ cache->register_offsets[rd] = 0 - cache->framesize; @@ -289,7 +284,7 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, non_stack_instruction_found = 0; continue; } - else if (IS_SETUP_FP(op, ra, rb)) + else if (IS_SETUP_FP (op, ra, rb)) { /* We have a frame pointer. Note the register which is acting as the frame pointer. */ @@ -300,7 +295,7 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, non_stack_instruction_found = 0; continue; } - else if (IS_SPILL_REG_FP(op, rd, ra, cache->fp_regnum)) + else if (IS_SPILL_REG_FP (op, rd, ra, cache->fp_regnum)) { /* reg spilled after updating. */ cache->register_offsets[rd] = imm - cache->framesize; @@ -311,7 +306,7 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, non_stack_instruction_found = 0; continue; } - else if (IS_SAVE_HIDDEN_PTR(op, rd, ra, rb)) + else if (IS_SAVE_HIDDEN_PTR (op, rd, ra, rb)) { /* If the first argument is a hidden pointer to the area where the return structure is to be saved, then it is saved as part of the @@ -341,14 +336,14 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, instruction. */ { - unsigned ctrl_op = (unsigned)insn >> 26; + unsigned ctrl_op = (unsigned) insn >> 26; /* continue if not control flow (branch, return). */ if (ctrl_op != 0x26 && ctrl_op != 0x27 && ctrl_op != 0x2d && ctrl_op != 0x2e && ctrl_op != 0x2f) continue; else if (ctrl_op == 0x2c) - continue; /* continue if imm. */ + continue; /* continue if imm. */ } /* This is not a prologue insn, so stop here. */ @@ -401,13 +396,12 @@ microblaze_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) { sal = find_pc_line (func_start, 0); - if (sal.end < func_end - && start_pc <= sal.end) + if (sal.end < func_end && start_pc <= sal.end) start_pc = sal.end; } - ostart_pc = microblaze_analyze_prologue (gdbarch, func_start, 0xffffffffUL, - &cache); + ostart_pc + = microblaze_analyze_prologue (gdbarch, func_start, 0xffffffffUL, &cache); if (ostart_pc > start_pc) return ostart_pc; @@ -444,10 +438,10 @@ microblaze_frame_cache (frame_info_ptr next_frame, void **this_cache) static void microblaze_frame_this_id (frame_info_ptr next_frame, void **this_cache, - struct frame_id *this_id) + struct frame_id *this_id) { - struct microblaze_frame_cache *cache = - microblaze_frame_cache (next_frame, this_cache); + struct microblaze_frame_cache *cache + = microblaze_frame_cache (next_frame, this_cache); /* This marks the outermost frame. */ if (cache->base == 0) @@ -457,11 +451,11 @@ microblaze_frame_this_id (frame_info_ptr next_frame, void **this_cache, } static struct value * -microblaze_frame_prev_register (frame_info_ptr this_frame, - void **this_cache, int regnum) +microblaze_frame_prev_register (frame_info_ptr this_frame, void **this_cache, + int regnum) { - struct microblaze_frame_cache *cache = - microblaze_frame_cache (this_frame, this_cache); + struct microblaze_frame_cache *cache + = microblaze_frame_cache (this_frame, this_cache); if (cache->frameless_p) { @@ -469,44 +463,36 @@ microblaze_frame_prev_register (frame_info_ptr this_frame, regnum = 15; if (regnum == MICROBLAZE_SP_REGNUM) regnum = 1; - return trad_frame_get_prev_register (this_frame, - cache->saved_regs, regnum); + return trad_frame_get_prev_register (this_frame, cache->saved_regs, + regnum); } else return trad_frame_get_prev_register (this_frame, cache->saved_regs, regnum); - } -static const struct frame_unwind microblaze_frame_unwind = -{ - "microblaze prologue", - NORMAL_FRAME, - default_frame_unwind_stop_reason, - microblaze_frame_this_id, - microblaze_frame_prev_register, - NULL, - default_frame_sniffer -}; - +static const struct frame_unwind microblaze_frame_unwind + = { "microblaze prologue", + NORMAL_FRAME, + default_frame_unwind_stop_reason, + microblaze_frame_this_id, + microblaze_frame_prev_register, + NULL, + default_frame_sniffer }; + static CORE_ADDR -microblaze_frame_base_address (frame_info_ptr next_frame, - void **this_cache) +microblaze_frame_base_address (frame_info_ptr next_frame, void **this_cache) { - struct microblaze_frame_cache *cache = - microblaze_frame_cache (next_frame, this_cache); + struct microblaze_frame_cache *cache + = microblaze_frame_cache (next_frame, this_cache); return cache->base; } -static const struct frame_base microblaze_frame_base = -{ - µblaze_frame_unwind, - microblaze_frame_base_address, - microblaze_frame_base_address, - microblaze_frame_base_address -}; - +static const struct frame_base microblaze_frame_base + = { µblaze_frame_unwind, microblaze_frame_base_address, + microblaze_frame_base_address, microblaze_frame_base_address }; + /* Extract from an array REGBUF containing the (raw) register state, a function return value of TYPE, and copy that into VALBUF. */ static void @@ -518,22 +504,22 @@ microblaze_extract_return_value (struct type *type, struct regcache *regcache, /* Copy the return value (starting) in RETVAL_REGNUM to VALBUF. */ switch (type->length ()) { - case 1: /* return last byte in the register. */ - regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM, buf); - memcpy(valbuf, buf + MICROBLAZE_REGISTER_SIZE - 1, 1); - return; - case 2: /* return last 2 bytes in register. */ - regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM, buf); - memcpy(valbuf, buf + MICROBLAZE_REGISTER_SIZE - 2, 2); - return; - case 4: /* for sizes 4 or 8, copy the required length. */ - case 8: - regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM, buf); - regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM + 1, buf+4); - memcpy (valbuf, buf, type->length ()); - return; - default: - internal_error (_("Unsupported return value size requested")); + case 1: /* return last byte in the register. */ + regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM, buf); + memcpy (valbuf, buf + MICROBLAZE_REGISTER_SIZE - 1, 1); + return; + case 2: /* return last 2 bytes in register. */ + regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM, buf); + memcpy (valbuf, buf + MICROBLAZE_REGISTER_SIZE - 2, 2); + return; + case 4: /* for sizes 4 or 8, copy the required length. */ + case 8: + regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM, buf); + regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM + 1, buf + 4); + memcpy (valbuf, buf, type->length ()); + return; + default: + internal_error (_ ("Unsupported return value size requested")); } } @@ -554,15 +540,15 @@ microblaze_store_return_value (struct type *type, struct regcache *regcache, int len = type->length (); gdb_byte buf[8]; - memset (buf, 0, sizeof(buf)); + memset (buf, 0, sizeof (buf)); /* Integral and pointer return values. */ if (len > 4) { - gdb_assert (len == 8); - memcpy (buf, valbuf, 8); - regcache->cooked_write (MICROBLAZE_RETVAL_REGNUM+1, buf + 4); + gdb_assert (len == 8); + memcpy (buf, valbuf, 8); + regcache->cooked_write (MICROBLAZE_RETVAL_REGNUM + 1, buf + 4); } else /* ??? Do we need to do any sign-extension here? */ @@ -590,28 +576,46 @@ microblaze_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type) return (type->length () == 16); } - -static int dwarf2_to_reg_map[78] = -{ 0 /* r0 */, 1 /* r1 */, 2 /* r2 */, 3 /* r3 */, /* 0- 3 */ - 4 /* r4 */, 5 /* r5 */, 6 /* r6 */, 7 /* r7 */, /* 4- 7 */ - 8 /* r8 */, 9 /* r9 */, 10 /* r10 */, 11 /* r11 */, /* 8-11 */ - 12 /* r12 */, 13 /* r13 */, 14 /* r14 */, 15 /* r15 */, /* 12-15 */ - 16 /* r16 */, 17 /* r17 */, 18 /* r18 */, 19 /* r19 */, /* 16-19 */ - 20 /* r20 */, 21 /* r21 */, 22 /* r22 */, 23 /* r23 */, /* 20-23 */ - 24 /* r24 */, 25 /* r25 */, 26 /* r26 */, 27 /* r27 */, /* 24-25 */ - 28 /* r28 */, 29 /* r29 */, 30 /* r30 */, 31 /* r31 */, /* 28-31 */ - -1 /* $f0 */, -1 /* $f1 */, -1 /* $f2 */, -1 /* $f3 */, /* 32-35 */ - -1 /* $f4 */, -1 /* $f5 */, -1 /* $f6 */, -1 /* $f7 */, /* 36-39 */ - -1 /* $f8 */, -1 /* $f9 */, -1 /* $f10 */, -1 /* $f11 */, /* 40-43 */ - -1 /* $f12 */, -1 /* $f13 */, -1 /* $f14 */, -1 /* $f15 */, /* 44-47 */ - -1 /* $f16 */, -1 /* $f17 */, -1 /* $f18 */, -1 /* $f19 */, /* 48-51 */ - -1 /* $f20 */, -1 /* $f21 */, -1 /* $f22 */, -1 /* $f23 */, /* 52-55 */ - -1 /* $f24 */, -1 /* $f25 */, -1 /* $f26 */, -1 /* $f27 */, /* 56-59 */ - -1 /* $f28 */, -1 /* $f29 */, -1 /* $f30 */, -1 /* $f31 */, /* 60-63 */ - -1 /* hi */, -1 /* lo */, -1 /* accum*/, 33 /* rmsr */, /* 64-67 */ - -1 /* $fcc1*/, -1 /* $fcc2*/, -1 /* $fcc3*/, -1 /* $fcc4*/, /* 68-71 */ - -1 /* $fcc5*/, -1 /* $fcc6*/, -1 /* $fcc7*/, -1 /* $ap */, /* 72-75 */ - -1 /* $rap */, -1 /* $frp */ /* 76-77 */ +static int dwarf2_to_reg_map[78] = { + 0 /* r0 */, 1 /* r1 */, + 2 /* r2 */, 3 /* r3 */, /* 0- 3 */ + 4 /* r4 */, 5 /* r5 */, + 6 /* r6 */, 7 /* r7 */, /* 4- 7 */ + 8 /* r8 */, 9 /* r9 */, + 10 /* r10 */, 11 /* r11 */, /* 8-11 */ + 12 /* r12 */, 13 /* r13 */, + 14 /* r14 */, 15 /* r15 */, /* 12-15 */ + 16 /* r16 */, 17 /* r17 */, + 18 /* r18 */, 19 /* r19 */, /* 16-19 */ + 20 /* r20 */, 21 /* r21 */, + 22 /* r22 */, 23 /* r23 */, /* 20-23 */ + 24 /* r24 */, 25 /* r25 */, + 26 /* r26 */, 27 /* r27 */, /* 24-25 */ + 28 /* r28 */, 29 /* r29 */, + 30 /* r30 */, 31 /* r31 */, /* 28-31 */ + -1 /* $f0 */, -1 /* $f1 */, + -1 /* $f2 */, -1 /* $f3 */, /* 32-35 */ + -1 /* $f4 */, -1 /* $f5 */, + -1 /* $f6 */, -1 /* $f7 */, /* 36-39 */ + -1 /* $f8 */, -1 /* $f9 */, + -1 /* $f10 */, -1 /* $f11 */, /* 40-43 */ + -1 /* $f12 */, -1 /* $f13 */, + -1 /* $f14 */, -1 /* $f15 */, /* 44-47 */ + -1 /* $f16 */, -1 /* $f17 */, + -1 /* $f18 */, -1 /* $f19 */, /* 48-51 */ + -1 /* $f20 */, -1 /* $f21 */, + -1 /* $f22 */, -1 /* $f23 */, /* 52-55 */ + -1 /* $f24 */, -1 /* $f25 */, + -1 /* $f26 */, -1 /* $f27 */, /* 56-59 */ + -1 /* $f28 */, -1 /* $f29 */, + -1 /* $f30 */, -1 /* $f31 */, /* 60-63 */ + -1 /* hi */, -1 /* lo */, + -1 /* accum*/, 33 /* rmsr */, /* 64-67 */ + -1 /* $fcc1*/, -1 /* $fcc2*/, + -1 /* $fcc3*/, -1 /* $fcc4*/, /* 68-71 */ + -1 /* $fcc5*/, -1 /* $fcc6*/, + -1 /* $fcc7*/, -1 /* $ap */, /* 72-75 */ + -1 /* $rap */, -1 /* $frp */ /* 76-77 */ }; static int @@ -625,12 +629,10 @@ microblaze_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int reg) static void microblaze_register_g_packet_guesses (struct gdbarch *gdbarch) { - register_remote_g_packet_guess (gdbarch, - 4 * MICROBLAZE_NUM_CORE_REGS, + register_remote_g_packet_guess (gdbarch, 4 * MICROBLAZE_NUM_CORE_REGS, tdesc_microblaze); - register_remote_g_packet_guess (gdbarch, - 4 * MICROBLAZE_NUM_REGS, + register_remote_g_packet_guess (gdbarch, 4 * MICROBLAZE_NUM_REGS, tdesc_microblaze_with_stack_protect); } @@ -654,8 +656,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) int valid_p; int i; - feature = tdesc_find_feature (tdesc, - "org.gnu.gdb.microblaze.core"); + feature = tdesc_find_feature (tdesc, "org.gnu.gdb.microblaze.core"); if (feature == NULL) return NULL; tdesc_data = tdesc_data_alloc (); @@ -664,17 +665,15 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) for (i = 0; i < MICROBLAZE_NUM_CORE_REGS; i++) valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i, microblaze_register_names[i]); - feature = tdesc_find_feature (tdesc, - "org.gnu.gdb.microblaze.stack-protect"); + feature + = tdesc_find_feature (tdesc, "org.gnu.gdb.microblaze.stack-protect"); if (feature != NULL) { valid_p = 1; valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), - MICROBLAZE_SLR_REGNUM, - "rslr"); + MICROBLAZE_SLR_REGNUM, "rslr"); valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), - MICROBLAZE_SHR_REGNUM, - "rshr"); + MICROBLAZE_SHR_REGNUM, "rshr"); } if (!valid_p) @@ -692,8 +691,8 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_register_type (gdbarch, microblaze_register_type); /* Register numbers of various important registers. */ - set_gdbarch_sp_regnum (gdbarch, MICROBLAZE_SP_REGNUM); - set_gdbarch_pc_regnum (gdbarch, MICROBLAZE_PC_REGNUM); + set_gdbarch_sp_regnum (gdbarch, MICROBLAZE_SP_REGNUM); + set_gdbarch_pc_regnum (gdbarch, MICROBLAZE_PC_REGNUM); /* Map Dwarf2 registers to GDB registers. */ set_gdbarch_dwarf2_reg_to_regnum (gdbarch, microblaze_dwarf2_reg_to_regnum); @@ -702,8 +701,8 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_call_dummy_location (gdbarch, ON_STACK); set_gdbarch_return_value (gdbarch, microblaze_return_value); - set_gdbarch_stabs_argument_has_addr - (gdbarch, microblaze_stabs_argument_has_addr); + set_gdbarch_stabs_argument_has_addr (gdbarch, + microblaze_stabs_argument_has_addr); set_gdbarch_skip_prologue (gdbarch, microblaze_skip_prologue); @@ -737,6 +736,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } void _initialize_microblaze_tdep (); + void _initialize_microblaze_tdep () { @@ -746,12 +746,11 @@ _initialize_microblaze_tdep () initialize_tdesc_microblaze (); /* Debug this files internals. */ add_setshow_zuinteger_cmd ("microblaze", class_maintenance, - µblaze_debug_flag, _("\ -Set microblaze debugging."), _("\ -Show microblaze debugging."), _("\ + µblaze_debug_flag, _ ("\ +Set microblaze debugging."), + _ ("\ +Show microblaze debugging."), + _ ("\ When non-zero, microblaze specific debugging is enabled."), - NULL, - NULL, - &setdebuglist, &showdebuglist); - + NULL, NULL, &setdebuglist, &showdebuglist); } |