From ccdd31be178b67aac1e814fb694ccd6da427f651 Mon Sep 17 00:00:00 2001 From: Tat-Chee Wan (USM) Date: Mon, 28 Mar 2011 07:05:49 +0800 Subject: work in progress --- Debugger/debug_macros.h | 4 ++-- Debugger/debug_stub.S | 60 ++++++++++++++++++++++++++++++++++++++++--------- Debugger/debug_stub.h | 7 +++--- 3 files changed, 56 insertions(+), 15 deletions(-) (limited to 'Debugger') diff --git a/Debugger/debug_macros.h b/Debugger/debug_macros.h index 0afa0a4..89c7035 100644 --- a/Debugger/debug_macros.h +++ b/Debugger/debug_macros.h @@ -354,7 +354,7 @@ */ .macro _dbg_getcurrbkpt_index reg ldr \reg, =debug_curr_breakpoint - ldr \reg, [\reg] + ldrb \reg, [\reg] .endm /* _dbg_setcurrbkpt_index @@ -364,7 +364,7 @@ */ .macro _dbg_setcurrbkpt_index reg ldr r1, =debug_curr_breakpoint - str \reg, [r1] + strb \reg, [r1] .endm /* _dbg_getabortedinstr_addr diff --git a/Debugger/debug_stub.S b/Debugger/debug_stub.S index 0f7f841..e7749de 100644 --- a/Debugger/debug_stub.S +++ b/Debugger/debug_stub.S @@ -190,8 +190,6 @@ .bss .align 4 -debug_curr_breakpoint: - .word 0x0 debug_InMsgBuf: .space MSGBUF_SIZE,0 debug_OutMsgBuf: @@ -203,6 +201,8 @@ debug_mode: .byte 0x0 /* Boolean variable */ debug_bkpt_type: .byte 0x0 /* bkpt_type_t variable */ +debug_curr_breakpoint: + .byte 0x0 .data .align 4 @@ -1104,28 +1104,28 @@ _dbg__cmd_WriteMem: _dbg__cmd_Continue: /* Don't put anything on the stack, we won't return to the Debugger Run Loop */ bl __dbg__cmdParamLen - cmp r1, #CMD_REG_CONTINUE_PARAMLEN /* Check for correct parameter length */ - beq _check_breakpoint_type /* Continue from current PC */ + cmp r1, #CMD_CONTINUE_MINPARAMLEN /* Check for correct parameter length */ + beq _dbg__cont_check_breakpoint_type /* Continue from current PC */ _dbg__cont_fromAddr: bl ascii2hex_varlen_be /* convert ASCII address to Hex (in R0), R1 has address of next buffer char */ /* Continue from Specified Address */ 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 _is_manual_bkpt_or_address_specified + b _dbg__cont_is_manual_bkpt_or_address_specified -_check_breakpoint_type: +_dbg__cont_check_breakpoint_type: _dbg_get_bkpt_type r0 teq r0, #DBG_MANUAL_BKPT_ARM - beq _is_manual_bkpt_or_address_specified + beq _dbg__cont_is_manual_bkpt_or_address_specified teq r0, #DBG_MANUAL_BKPT_THUMB - bne _is_normal_breakpoint + bne _dbg__cont_is_normal_breakpoint -_is_manual_bkpt_or_address_specified: +_dbg__cont_is_manual_bkpt_or_address_specified: bl _dbg__activate_breakpoints /* Restore exisiting breakpoints */ b _dbg__switch2undefmode -_is_normal_breakpoint: +_dbg__cont_is_normal_breakpoint: /* FIXME: _dbg_next_instruction_addr doesn't actually work currently. This breaks normal breakpoints which need to determine the next instruction to execute (for placing the autobreakpoint) prior to returning. @@ -1150,6 +1150,9 @@ __dbg__sendOkBeforeResume: b __dbg__sendOkBeforeResume /* Retry retransmission */ #endif +/* _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 */ @@ -1157,6 +1160,42 @@ _dbg__switch2undefmode: ldr lr, =resume_execution mov pc, lr /* Exit via UNDEF mode */ +/* _dbg__cmd_Step + * Step User Program Execution Command Handler + * Setup breakpoints before resuming execution of program. + * + * If Address is specified, update the next instruction address + * + * If this is a Normal Breakpoint, then we need to install a Step Breakpoint at next instruction address + * and resume from current (Breakpoint) exception address + * Else (it is a Manual Breakpoint or Address Specified) + * We need to we need to install a Step Breakpoint at next instruction address + * and resume (which will trigger a Breakpoint immediately) + * On entry: + * r0: parameter buffer pointer (contents after '$' and '') + * Optional: AA..AA + * On exit: + * r0, r1, r2: destroyed + * Note: This routine does not return to caller. Instead it switches + * operating mode to UNDEF and returns to previously active program + */ +_dbg__cmd_Step: + /* Don't put anything on the stack, we won't return to the Debugger Run Loop */ + bl __dbg__cmdParamLen + cmp r1, #CMD_STEP_MINPARAMLEN /* Check for correct parameter length */ + beq _dbg__step_check_breakpoint_type /* Step from current PC */ + +_dbg__step_fromAddr: + bl ascii2hex_varlen_be /* convert ASCII address to Hex (in R0), R1 has address of next buffer char */ + /* Step from Specified Address */ + 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_check_breakpoint_type: +@@@@@ +@ WIP + /* _dbg__proc_brkpt_params * Process Breakpoint Parameters * On entry: @@ -1733,6 +1772,7 @@ void __single_step (void) */ _dbg_next_instruction_addr: /* FIXME: This needs a total rewrite */ + mov r1, #0 bx lr /* We assume that any BKPT instructions in the code will be Manual Breakpoints, * i.e., the Debugger does not leave stray Single Step / Auto / Normal breakpoints in memory diff --git a/Debugger/debug_stub.h b/Debugger/debug_stub.h index e95f338..932d450 100644 --- a/Debugger/debug_stub.h +++ b/Debugger/debug_stub.h @@ -107,12 +107,13 @@ #define CMD_MEM_MAXWRITEBYTES ((CMD_MEM_MAXINBUFLEN - CMD_MEM_WRITE_MINPARAMLEN)/2) /*@}*/ -/** @name Debug Continue Command Constants. +/** @name Debug Continue and Step Command Constants. * - * Debug Continue Command + * Debug Continue and Step Command */ /*@{*/ -#define CMD_REG_CONTINUE_PARAMLEN 0 +#define CMD_CONTINUE_MINPARAMLEN 0 +#define CMD_STEP_MINPARAMLEN 0 /*@}*/ -- cgit v1.2.3