aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTat-Chee Wan (USM)2011-07-13 07:50:49 +0800
committerTat-Chee Wan (USM)2011-07-13 07:50:49 +0800
commitb14d454a454ffc35a94c3f99e176c40a68b31c0f (patch)
treeed94ea085d35f2dfea37bf258f6161285015d6ed
parent47ce28faf2797edf0c3bc7b10f7ae453d1f6a152 (diff)
remote autobreakpoint code from master branch
Autobreakpoint support is not robust. It is removed from the master branch. The autobreakpoint_stub branch contains the old autobreakpoint code.
-rw-r--r--Debugger/debug_internals.h2
-rw-r--r--Debugger/debug_stub.S118
-rw-r--r--Debugger/debug_stub.h4
3 files changed, 24 insertions, 100 deletions
diff --git a/Debugger/debug_internals.h b/Debugger/debug_internals.h
index 74a695c..13efba2 100644
--- a/Debugger/debug_internals.h
+++ b/Debugger/debug_internals.h
@@ -287,7 +287,7 @@ ENUM_END(dbg_state_t)
* The enums must be consecutive, starting from 0
*/
ENUM_BEGIN
-ENUM_VALASSIGN(DBG_AUTO_BKPT,0) /**< Auto Breakpoint (Instruction resume after breakpoint). */
+ENUM_VALASSIGN(DBG_AUTO_BKPT,0) /**< RESERVED: Auto Breakpoint (Instruction resume after breakpoint). */
ENUM_VAL(DBG_MANUAL_BKPT_ARM) /**< Manual ARM Breakpoint. */
ENUM_VAL(DBG_NORMAL_BKPT_ARM) /**< Normal ARM Breakpoint (Single Step, Normal). */
ENUM_VAL(DBG_MANUAL_BKPT_THUMB) /**< Manual Thumb Breakpoint. */
diff --git a/Debugger/debug_stub.S b/Debugger/debug_stub.S
index ed45dd4..136a86c 100644
--- a/Debugger/debug_stub.S
+++ b/Debugger/debug_stub.S
@@ -390,6 +390,16 @@ _dbg__flush_icache:
/* nop */
bx lr
+/* _dbg__switch2undefmode
+ * Common internal routine to return execution to user program
+ */
+_dbg__switch2undefmode:
+ bl _dbg__flush_icache
+ msr cpsr_c, #(MODE_UND | CPSR_FIQ | CPSR_IRQ) /* Configure Undef Mode */
+ _dbg_setmode FALSE /* Debug Mode = False */
+ ldr lr, =resume_execution
+ mov pc, lr /* Exit via UNDEF mode */
+
/* dbg__abort_exception_handler
* Handle Abort Exceptions
* On entry:
@@ -411,24 +421,19 @@ dbg__abort_exception_handler:
*/
.global dbg__thumb_bkpt_handler
dbg__thumb_bkpt_handler:
- and r4, r0, #BKPT16_AUTO_BKPT /* keep AUTO flag value in r4 */
- bic r0, r0, #BKPT16_AUTO_BKPT /* mask out AUTO flag */
+ /* On entry, r0 contains breakpoint index value */
_dbg_setcurrbkpt_index r0 /* keep current breakpoint index in memory */
ldr r1, =BKPT16_MANUAL_BKPT
teq r0, r1
moveq r0, #DBG_MANUAL_BKPT_THUMB /* Manual Thumb Breakpoint, process it */
beq _restore_normal_breakpoints
-_process_normal_or_auto_breakpoint_thumb:
+_process_normal_breakpoint_thumb:
ldr r1, =__breakpoints_num__
cmp r0, r1 /* Sanity check that index is in range */
bhs dbg__bkpt_offset_outofrange /* Exceeded Offset Range */
-
-_check_auto_breakpoint_thumb:
- teq r4, #0 /* Check if AUTO flag set */
- moveq r0, #DBG_NORMAL_BKPT_THUMB /* No, it is a normal breakpoint */
- beq _restore_normal_breakpoints
- b _process_auto_breakpoint
+ mov r0, #DBG_NORMAL_BKPT_THUMB /* It is a valid normal breakpoint */
+ b _restore_normal_breakpoints
/* dbg__arm_bkpt_handler
* GDB handle_exception() routine (ARM Mode)
@@ -440,56 +445,18 @@ _check_auto_breakpoint_thumb:
.global dbg__arm_bkpt_handler
dbg__arm_bkpt_handler:
/* On entry, r0 contains breakpoint index value */
- and r4, r0, #BKPT32_AUTO_BKPT /* keep AUTO flag value in r4 */
- bic r0, r0, #BKPT32_AUTO_BKPT /* mask out AUTO flag */
_dbg_setcurrbkpt_index r0 /* keep current breakpoint index in memory */
ldr r1, =BKPT32_MANUAL_BKPT
teq r0, r1
moveq r0, #DBG_MANUAL_BKPT_ARM /* Manual ARM Breakpoint, process it */
beq _restore_normal_breakpoints
-_process_normal_or_auto_breakpoint_arm:
+_process_normal_breakpoint_arm:
ldr r1, =__breakpoints_num__
cmp r0, r1 /* Sanity check that index is in range */
bhs dbg__bkpt_offset_outofrange /* Exceeded Offset Range */
-
-_check_auto_breakpoint_arm:
- teq r4, #0 /* Check if AUTO flag set */
- moveq r0, #DBG_NORMAL_BKPT_ARM /* No, it is a normal breakpoint */
- beq _restore_normal_breakpoints
-/* b _process_auto_breakpoint */
-
-_process_auto_breakpoint:
- /* Load Auto BKPT for Breakpoint index given in r0 */
- _index2bkptindex_addr r0, r1 /* Calculate Breakpoint Entry Address */
- ldm r1, {r1, r2} /* r1: Breakpoint Address, r2: Breakpoint Instruction */
- teq r1, #0 /* Check that Breakpoint is active */
- beq dbg__bkpt_inactive
- bl _dbg__activate_one_breakpoint
- bl _dbg__restore_singlestep
- bl _dbg__clear_singlestep
- _dbg_set_bkpt_type_val DBG_AUTO_BKPT
-/* b _dbg__switch2undefmode */
-
-/* _dbg__switch2undefmode
- * Common internal routine to return execution to user program
- */
-_dbg__switch2undefmode:
- bl _dbg__flush_icache
- msr cpsr_c, #(MODE_UND | CPSR_FIQ | CPSR_IRQ) /* Configure Undef Mode */
- _dbg_setmode FALSE /* Debug Mode = False */
- ldr lr, =resume_execution
- mov pc, lr /* Exit via UNDEF mode */
-
-#if 0
-_process_manual_breakpoint_thumb:
- mov r0, #DBG_MANUAL_BKPT_THUMB /* Setup Breakpoint type before executing common routine */
- b _restore_normal_breakpoints
-
-_process_normal_breakpoint_thumb:
- mov r0, #DBG_NORMAL_BKPT_THUMB /* Setup Breakpoint type before executing common routine */
-/* b _restore_normal_breakpoints */
-#endif
+ mov r0, #DBG_NORMAL_BKPT_ARM /* It is a valid normal breakpoint */
+/* b _restore_normal_breakpoints */
_restore_normal_breakpoints:
_dbg_set_bkpt_type r0 /* Set Breakpoint Type given value in R0 */
@@ -1108,8 +1075,7 @@ _dbg__cmd_Detach:
*
* If Address is specified, update the next instruction address to specified address
*
- * If this is a Normal Breakpoint, then we need to install an Autobreakpoint at next instruction address
- * and resume from current (Breakpoint) exception address
+ * If this is a Normal Breakpoint, then we resume from current (Breakpoint) exception address
* Else (it is a Manual Breakpoint or Address Specified)
* We need to resume from the next instruction address
* On entry:
@@ -1142,24 +1108,12 @@ _dbg__cont_check_breakpoint_type:
teq r0, #DBG_MANUAL_BKPT_THUMB
beq _dbg__cont_is_manual_bkpt_or_address_specified
-@ FIXME: Need to validate the following code
-/* Autobreakpoint handling is not robust. If there are intervening Exceptions which triggers the
- * Debugger before the Auto Breakpoint is triggered, the Single Step instruction gets lost and
- * the Breakpoint Opcode is left in the code.
- *
- * In addition, GDB knows to Step from a breakpointed instruction before continuing when
- * Continue is issued.
- */
_dbg__cont_is_normal_breakpoint:
_getdbgregister DBGSTACK_USERPC_INDEX, r0 /* Retrieve Aborted Instruction PC from the Debug Stack into R0 */
_setdbgregister DBGSTACK_NEXTINSTR_INDEX, r0, r1 /* Set Next Instruction Pointer for Resume using contents of R0, and scratch register R1 */
-#if 0
- bl dbg_following_instruction_addr /* following instruction address returned in r1 */
- bl dbg__install_singlestep /* Setup Single Step, next instruction address returned in r1 */
- _dbg_getcurrbkpt_index r0 /* load current breakpoint index in memory */
- bl _dbg__activate_autobreakpoint /* pass next instruction address in r1 */
- b _dbg__switch2undefmode
-#endif
+ /* GDB knows to Step from a breakpointed instruction before continuing when
+ * Continue is issued, so it is safe to activate all defined breakpoints and continue.
+ */
_dbg__cont_is_manual_bkpt_or_address_specified:
bl _dbg__activate_breakpoints /* Restore exisiting breakpoints */
b _dbg__switch2undefmode
@@ -1587,33 +1541,3 @@ __dbg__iterate_breakpoint_array:
bhi 4b /* if (pointer > start of Breakpoint Table address), get next slot */
ldmfd sp!, {pc}
-/* _dbg__activate_autobreakpoint
- * Activate all other breakpoints except current breakpoint, activate auto breakpoint in next instr slot
- *
- * On entry:
- * R0: Current Breakpoint index (assumed valid)
- * R1: Next Instruction address (for AUTO Breakpoint) [Not used, assume Single Step Breakpoint already has correct info]
- * On exit:
- * R0-R5: Destroyed
- */
-_dbg__activate_autobreakpoint:
- stmfd sp!, {lr}
- mov r5, r0 /* Keep Current Breakpoint Index in r5 */
- ldr r4, =__breakpoints_end__ /* start from top of the table */
- ldr r0, =__breakpoints_num__ /* Number of Breakpoints (incl Single Step) (Assume Non-Zero) */
-4: subs r0, r0, #1 /* Decrement breakpoint index in r0 */
- ldmea r4!, {r1, r2} /* r1: Breakpoint Address, r2: Breakpoint Instruction */
- bls 5f /* Flag set by subs instruction previously. Reached Single Step, go activate AUTO Breakpoint */
- teq r0, r5 /* Is it the Current Breakpoint? */
- beq 4b /* Yes, so skip */
- teq r1, #0 /* Is it active? */
- blne _dbg__activate_one_breakpoint /* active entry */
- b 4b /* Next iteration */
-5:
-/* Here, r1: Breakpoint Address, r2: Breakpoint Instruction */
- tst r1, #BKPT_STATE_THUMB_FLAG /* Check for Thumb bit -- 1: Thumb instruction */
- orreq r0, r5, #BKPT32_AUTO_BKPT /* Is ARM Instruction, merge AUTO flag with Current Breakpoint Index */
- orrne r0, r5, #BKPT16_AUTO_BKPT /* Is Thumb Instruction, merge AUTO flag with Current Breakpoint Index */
- bl _dbg__activate_one_breakpoint /* Activate AUTO Breakpoint */
- ldmfd sp!, {pc}
-
diff --git a/Debugger/debug_stub.h b/Debugger/debug_stub.h
index 11b348e..6807ac1 100644
--- a/Debugger/debug_stub.h
+++ b/Debugger/debug_stub.h
@@ -34,12 +34,12 @@
#endif
#define BKPT32_ENUM_MASK 0x000FFF0F /* ARM BKPT Enum Mask */
-#define BKPT32_AUTO_BKPT 0x00080000 /* ARM BKPT Auto-Step Flag (for CONT support) */
+#define BKPT32_AUTO_BKPT 0x00080000 /* RESERVED: ARM BKPT Auto-Step Flag (for CONT support) */
#define BKPT32_MANUAL_BKPT 0x0007FF0F /* Manually inserted ARM Breakpoint */
#define BKPT16_INSTR 0xBE00 /* Thumb BKPT instruction */
#define BKPT16_ENUM_MASK 0x00FF /* Thumb BKPT Enum Mask */
-#define BKPT16_AUTO_BKPT 0x0080 /* Thumb BKPT Auto-Step Flag (for CONT support) */
+#define BKPT16_AUTO_BKPT 0x0080 /* RESERVED: Thumb BKPT Auto-Step Flag (for CONT support) */
#define BKPT16_MANUAL_BKPT 0x007F /* Manually inserted Thumb Breakpoint */
/*@}*/