From 90a30d6380d7e1ffd7cacf3d18423ebe111a6859 Mon Sep 17 00:00:00 2001 From: Tat-Chee Wan (USM) Date: Fri, 1 Apr 2011 11:55:13 +0800 Subject: fixed thumb breakpoint detection logic in undef handler Thumb breakpoints were not handled properly in the Undef instruciton handler previously. This fixes the problem. --- Debugger/debug_stub.S | 23 ++++++++++++----------- Debugger/undef_handler.S | 3 ++- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'Debugger') diff --git a/Debugger/debug_stub.S b/Debugger/debug_stub.S index a82088d..3743b98 100644 --- a/Debugger/debug_stub.S +++ b/Debugger/debug_stub.S @@ -1172,11 +1172,7 @@ _dbg__cont_check_breakpoint_type: teq r0, #DBG_MANUAL_BKPT_ARM beq _dbg__cont_is_manual_bkpt_or_address_specified teq r0, #DBG_MANUAL_BKPT_THUMB - bne _dbg__cont_is_normal_breakpoint - -_dbg__cont_is_manual_bkpt_or_address_specified: - bl _dbg__activate_breakpoints /* Restore exisiting breakpoints */ - b _dbg__switch2undefmode + beq _dbg__cont_is_manual_bkpt_or_address_specified _dbg__cont_is_normal_breakpoint: /* FIXME: _dbg_next_instruction_addr doesn't actually work currently. @@ -1193,6 +1189,10 @@ _dbg__cont_is_normal_breakpoint: bl _dbg__activate_autobreakpoint /* pass next instruction address in r1 */ b _dbg__switch2undefmode +_dbg__cont_is_manual_bkpt_or_address_specified: + bl _dbg__activate_breakpoints /* Restore exisiting breakpoints */ + b _dbg__switch2undefmode + /* _dbg__cmd_Step * Step User Program Execution Command Handler * Setup breakpoints before resuming execution of program. @@ -1230,12 +1230,7 @@ _dbg__step_check_breakpoint_type: teq r0, #DBG_MANUAL_BKPT_ARM beq _dbg__step_is_manual_bkpt teq r0, #DBG_MANUAL_BKPT_THUMB - bne _dbg__step_is_normal_breakpoint - -_dbg__step_is_manual_bkpt: - mov r2, #DBGSTACK_NEXTINSTR_INDEX /* The Next Instruction Pointer for Resume is in index 0 of the Debug Stack */ - _getdbgregisterfromindex r2, r1 /* Retrieve Register contents into R1 */ - b _dbg__step_is_manual_bkpt_or_address_specified + beq _dbg__step_is_manual_bkpt _dbg__step_is_normal_breakpoint: /* FIXME: _dbg_next_instruction_addr doesn't actually work currently. @@ -1246,6 +1241,12 @@ _dbg__step_is_normal_breakpoint: _getdbgregisterfromindex r2, r0 /* Retrieve Register contents into R0 */ mov r2, #DBGSTACK_NEXTINSTR_INDEX /* The Next Instruction Pointer for Resume is in index 0 of the Debug Stack */ _setdbgregisterfromindex r2, r0, r1 /* Set Register contents in R0, using index in R2, and scratch register R1 */ + b _dbg__step_is_manual_bkpt_or_address_specified + +_dbg__step_is_manual_bkpt: + mov r2, #DBGSTACK_NEXTINSTR_INDEX /* The Next Instruction Pointer for Resume is in index 0 of the Debug Stack */ + _getdbgregisterfromindex r2, r1 /* Retrieve Register contents into R1 */ + /* b _dbg__step_is_manual_bkpt_or_address_specified */ _dbg__step_is_manual_bkpt_or_address_specified: /* R1 contains the instruction address to be executed upon return */ diff --git a/Debugger/undef_handler.S b/Debugger/undef_handler.S index b980a5d..23de609 100644 --- a/Debugger/undef_handler.S +++ b/Debugger/undef_handler.S @@ -87,6 +87,7 @@ _is_thumb: teq r2, r1 bne default_undef_handler ldr r1, =BKPT16_ENUM_MASK /* get Thumb BKPT Enum Mask */ + ldr lr, =dbg__thumb_bkpt_handler /* handle BKPT, BKPT index in r0 */ b _exit_undef_handler _is_arm: ldr r0, [r0] /* load UNDEF instruction into r0 */ @@ -96,10 +97,10 @@ _is_arm: teq r2, r1 bne default_undef_handler ldr r1, =BKPT32_ENUM_MASK /* get ARM BKPT Enum Mask */ + ldr lr, =dbg__arm_bkpt_handler /* handle BKPT, BKPT index in r0 */ _exit_undef_handler: and r0, r1, r0 /* Keep index value */ msr cpsr_c, #(MODE_ABT) /* Configure Abort Mode */ - ldr lr, =dbg__arm_bkpt_handler /* handle BKPT, BKPT index in r0 */ mov pc, lr /* Invoke Debugger State (Supervisor Mode) */ .global resume_execution -- cgit v1.2.3