summaryrefslogtreecommitdiff
path: root/AT91SAM7S256/armdebug/Debugger
diff options
context:
space:
mode:
authorTat-Chee Wan (USM)2011-04-01 12:13:46 +0800
committerTat-Chee Wan (USM)2011-04-01 12:13:46 +0800
commita49b11a219f6876e63844c2b89f45122f64ab702 (patch)
tree47ddbff09837ea1262431a8fe5d6f479219a7e3f /AT91SAM7S256/armdebug/Debugger
parent5fdfaa83874590fcd9082659a55abd5dcca05c4f (diff)
parent1783911a091554b2fec8acbf10f46a3e6fb02575 (diff)
Merge branch 'master' of ssh://svc.cs.usm.my/~/gitrepo-bare/armdebug
Diffstat (limited to 'AT91SAM7S256/armdebug/Debugger')
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_comm.S15
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_macros.h14
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_stub.S121
-rw-r--r--AT91SAM7S256/armdebug/Debugger/undef_handler.S5
4 files changed, 103 insertions, 52 deletions
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_comm.S b/AT91SAM7S256/armdebug/Debugger/debug_comm.S
index 6635618..740fa3e 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_comm.S
+++ b/AT91SAM7S256/armdebug/Debugger/debug_comm.S
@@ -765,6 +765,9 @@ _hasMsg2Copy:
/* Need to account for Packet Acknowledgement */
1: ldrb r0, [r5]
+ teq r0, #MSGBUF_CTRLC /* Look for Ctrl-C */
+ moveq r0, r4 /* If found, set R0 to current message length */
+ beq exit_dbg__getDebugMsg /* and return */
teq r0, #MSGBUF_NAKCHAR /* Look for '-' */
beq exit_dbg__getMsgError /* FIXME: We can't handle retransmission, flag message error */
teq r0, #MSGBUF_ACKCHAR /* Look for '+' */
@@ -960,17 +963,19 @@ exit_dbg__putMsgError:
exit_dbg__putDebugMsg:
ldmfd sp!, {r4,r5,pc}
- .global dbg__requestRetransmission
-/* dbg__requestRetransmission
- * Request for Retransmission due to received message Checksum error (Blocking) .
+ .global dbg__sendAckOrNak
+/* dbg__sendAckOrNak
+ * Send Ack (for successful receipt of message)
+ * or Nak (for Retransmission due to received message Checksum error) (Blocking) .
* On entry:
* No parameters (assume pointers were initialized previously using dbg__comm_init)
* On exit:
* r0: status (0: success, -1: error)
* r1: destroyed
- * Note: A Retransmission is indicated by '-', which is prepended with the USB header and sent (without checksum)
+ * Note: An Ack Or Nak is indicated by '+' or '-', which is prepended with the USB header and sent (without checksum)
+ * Sending Ack is only done for Continue and Step commands, where GDB does not expect any replies.
*/
-dbg__requestRetransmission:
+dbg__sendAckOrNak:
stmfd sp!, {lr}
ldr r1, =debug_msgTxBufPtr /* R2: data structure base pointer */
ldr r0, [r1] /* Tx buffer Start Address */
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_macros.h b/AT91SAM7S256/armdebug/Debugger/debug_macros.h
index 89c7035..e71d9ca 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_macros.h
+++ b/AT91SAM7S256/armdebug/Debugger/debug_macros.h
@@ -121,6 +121,20 @@
bne 1b
.endm
+/* _dbg_outputAckOnlyFlag
+ * Return Flag ('+') for Continue or Step
+ * On exit:
+ * R0: Pointer to Output Buffer ASCIIZ location
+ * R1: destroyed
+ * R2: destroyed
+ */
+ .macro _dbg_outputAckOnlyFlag
+ ldr r0, =debug_OutMsgBuf
+ ldr r1, =debug_AckOnlyFlag /* ASCIIZ terminated */
+ _dbg_stpcpy r0, r1, r2
+ .endm
+
+
/* _dbg_outputRetransmitFlag
* Return Flag ('-') for Checksum Error (retransmission needed)
* On exit:
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_stub.S b/AT91SAM7S256/armdebug/Debugger/debug_stub.S
index 4520c32..3743b98 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_stub.S
+++ b/AT91SAM7S256/armdebug/Debugger/debug_stub.S
@@ -210,6 +210,9 @@ debug_curr_breakpoint:
debug_RetransmitFlag:
.byte '-',0
+debug_AckOnlyFlag:
+ .byte '+',0
+
debug_ValidResponsePrefix:
.byte '+','$',0
@@ -362,7 +365,7 @@ debug_armComplexCCTable:
.extern dbg__hasDebugMsg /* Check for message from the communications link */
.extern dbg__getDebugMsg /* Read a message from the communications link */
.extern dbg__putDebugMsg /* Write a message to the communications link */
- .extern dbg__requestRetransmission /* Request Retransmission due to Checksum Error */
+ .extern dbg__sendAckOrNak /* Send Ack or Nak to indicate success/failure of message receipt */
.extern dbg__runloopTasks /* Platform specific Run Loop processing */
@@ -482,7 +485,7 @@ dbg__bkpt_init:
bl _dbg__clear_breakpoints
mov r2, #0
ldr r1, =debug_curr_breakpoint
- str r2, [r1]
+ strb r2, [r1]
ldr r0, =debug_InMsgBuf
strb r2, [r0]
ldr r1, =debug_OutMsgBuf
@@ -574,7 +577,9 @@ _process_auto_breakpoint:
* Common internal routine to return execution to user program
*/
_dbg__switch2undefmode:
- bl _dbg__flush_icache
+ bl __dbg__procAckOnly /* send Ack to keep GDB server happy */
+ bl dbg__runloopTasks /* Service run loop tasks */
+ 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
@@ -617,10 +622,21 @@ dbg__bkpt_waitCMD_cont:
bl dbg__getDebugMsg /* Read new message from Debugger, buflen in R0, 0 if none, -1 if error, msgbuf pointer in R1 */
cmp r0, #0
beq dbg__bkpt_waitCMD_cont /* No message yet, do housekeeping tasks */
- blt __dbg__procChecksumError /* Message invalid, checksum error? */
-/* Message now has $<packet info>\0 */
+ bgt _proc_command /* valid message, process it */
+ bl __dbg__procChecksumError /* Message invalid, checksum error? */
+ b dbg__bkpt_waitCMD_cont
+
+_proc_command:
+/* Message now has Ctrl-C or $<packet info>\0 */
mov r4, r1 /* Use R4 as buffer pointer */
- ldrb r0, [r4], #1 /* Look for '$' */
+ ldrb r0, [r4], #1 /* Look for Ctrl-C or '$' */
+ teq r0, #MSGBUF_CTRLC
+ bne _dbg_check_gdb_command
+ /* Ctrl-C detected, do nothing (wait for next command from GDB) */
+ bl __dbg__procAckOnly /* send Ack */
+ b dbg__bkpt_waitCMD_cont
+
+_dbg_check_gdb_command:
teq r0, #MSGBUF_STARTCHAR
movne r0, #MSG_ERRFORMAT /* Message Format invalid (not '$') */
bne _dbg__cmdError /* Shouldn't happen */
@@ -644,19 +660,45 @@ _dbg__cmdExists:
_dbg_jumpTableHandler debug_cmdJumpTable, r2, r3 /* Call Command Handler Routine, use R2 as jump address pointer */
b dbg__bkpt_waitCMD_cont
-__dbg__procChecksumError:
- _dbg_outputRetransmitFlag
- bl dbg__requestRetransmission /* Request message retransmission from GDB server */
- cmp r0, #0
- beq dbg__bkpt_waitCMD_cont /* Sending of retransmission request succeeded */
- bl dbg__runloopTasks /* Service run loop tasks */
- b __dbg__procChecksumError /* Retry retransmission */
-
_dbg__cmdError:
_dbg_outputMsgStatusErr
bl dbg__putDebugMsg /* Send error response to the GDB server */
b dbg__bkpt_waitCMD_cont
+
+/* __dbg__procAckOnly
+ * Send Ack to GDB due to Continue or Step
+ * On entry:
+ * None
+ * On exit:
+ * r0-r3: destroyed
+ */
+__dbg__procAckOnly:
+ stmfd sp!, {lr}
+ _dbg_outputAckOnlyFlag
+ b _cont_sendAckOrNak /* Acknowledge Continue or Step command from GDB server */
+
+/* __dbg__procChecksumError
+ * Request Retransmission from GDB due to Checksum error
+ * On entry:
+ * None
+ * On exit:
+ * r0-r3: destroyed
+ */
+__dbg__procChecksumError:
+ stmfd sp!, {lr}
+ _dbg_outputRetransmitFlag
+ /* b _cont_sendAckOrNak */ /* Acknowledge Continue or Step command from GDB server */
+
+_cont_sendAckOrNak:
+ bl dbg__sendAckOrNak /* send Ack or Nak to GDB server */
+ cmp r0, #0
+ beq _cont_sendAckOrNak_exit /* Sending of Ack or Nak succeeded */
+ bl dbg__runloopTasks /* Service run loop tasks */
+ b _cont_sendAckOrNak /* Retry Ack or Nak transmission */
+_cont_sendAckOrNak_exit:
+ ldmfd sp!, {pc}
+
/* _dbg__cmdChar2Index
* Convert Command Character to Jump Table Index
* On entry:
@@ -1130,39 +1172,27 @@ _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.
This breaks normal breakpoints which need to determine the next instruction to execute
(for placing the autobreakpoint) prior to returning.
*/
- mov r2, #DBGSTACK_USERPC_INDEX /* Retrieve Aborted Instruction PC from the Debug Stack */
+ mov r2, #DBGSTACK_USERPC_INDEX /* Retrieve Aborted Instruction PC from the Debug Stack */
_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 */
+ 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 */
- bl _dbg_next_instruction_addr /* next instruction address returned in r1 */
- bl _dbg__install_singlestep /* Setup Single Step, next instruction address returned in r1 */
+ bl _dbg_next_instruction_addr /* next 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 */
-
-#if 0
-/* Not part of the GDB Remote Protocol spec. Messages are sent only when system halts, not when we resume */
-__dbg__sendOkBeforeResume:
- _dbg_outputMsgStatusOk
- bl dbg__putDebugMsg /* Send Ok response to the GDB server */
- cmp r0, #0
- beq _dbg__switch2undefmode /* Sending of retransmission request succeeded */
- bl dbg__runloopTasks /* Service run loop tasks */
- b __dbg__sendOkBeforeResume /* Retry retransmission */
-#endif
-
+ 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.
@@ -1197,15 +1227,10 @@ _dbg__step_fromAddr:
_dbg__step_check_breakpoint_type:
_dbg_get_bkpt_type r0
- 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
+ teq r0, #DBG_MANUAL_BKPT_ARM
+ beq _dbg__step_is_manual_bkpt
+ teq r0, #DBG_MANUAL_BKPT_THUMB
+ beq _dbg__step_is_manual_bkpt
_dbg__step_is_normal_breakpoint:
/* FIXME: _dbg_next_instruction_addr doesn't actually work currently.
@@ -1216,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/AT91SAM7S256/armdebug/Debugger/undef_handler.S b/AT91SAM7S256/armdebug/Debugger/undef_handler.S
index b980a5d..f185fbd 100644
--- a/AT91SAM7S256/armdebug/Debugger/undef_handler.S
+++ b/AT91SAM7S256/armdebug/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 r2, =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,11 +97,11 @@ _is_arm:
teq r2, r1
bne default_undef_handler
ldr r1, =BKPT32_ENUM_MASK /* get ARM BKPT Enum Mask */
+ ldr r2, =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) */
+ mov pc, r2 /* Invoke Debugger State (Supervisor Mode) */
.global resume_execution