From 59016fd3a1a51edc443df263e5007e07c2e66bbc Mon Sep 17 00:00:00 2001 From: Tat-Chee Wan (USM) Date: Tue, 18 Jan 2011 15:59:01 +0800 Subject: fix error in breakpoint index calculation Register R0 is overwritten in macro call. R1 has to be used instead. --- Debugger/debug_stub.S | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Debugger/debug_stub.S b/Debugger/debug_stub.S index 78a5472..53b4abd 100644 --- a/Debugger/debug_stub.S +++ b/Debugger/debug_stub.S @@ -809,17 +809,17 @@ _exit_dbg__proc_brkpt_params: _dbg__cmd_insert_breakpoint: stmfd sp!, {lr} bl __dbg__cmdParamLen - teq r1, #CMD_BKPT_INSERT_PARAMLEN /* Check for correct length */ - bne __dbg__procCmdParamError /* Unexpected input, report error */ - bl _dbg__proc_brkpt_params /* R0: Breakpoint Address */ + teq r1, #CMD_BKPT_INSERT_PARAMLEN /* Check for correct length */ + bne __dbg__procCmdParamError /* Unexpected input, report error */ + bl _dbg__proc_brkpt_params /* R0: Breakpoint Address */ teq r0, #0 - beq __dbg__procBreakpointAddrError /* Thumb2 instructions, or unknown kind */ - mov r3, r0 /* Keep breakpoint address in R3 */ - mov r0, #0 /* Empty Breakpoint entry */ - bl _dbg_find_breakpoint_slot /* Look for an available breakpoint slot, return index in R0 */ + beq __dbg__procBreakpointAddrError /* Thumb2 instructions, or unknown kind */ + mov r3, r0 /* Keep breakpoint address in R3 */ + mov r0, #0 /* Empty Breakpoint entry */ + bl _dbg_find_breakpoint_slot /* Look for an available breakpoint slot, return index in R0 */ cmp r0, #CMD_BKPT_NOTFOUND beq __dbg__procBreakpointAddrError /* No empty slot! */ - mov r1, r3 /* Move breakpoint address to R1 */ + mov r1, r3 /* Move breakpoint address to R1 */ bl _dbg__install_one_breakpoint /* r0: index, r1: instruction address */ b __dbg__procCmdOk @@ -834,16 +834,17 @@ _dbg__cmd_insert_breakpoint: _dbg__cmd_remove_breakpoint: stmfd sp!, {lr} bl __dbg__cmdParamLen - teq r1, #CMD_BKPT_REMOVE_PARAMLEN /* Check for correct length */ - bne __dbg__procCmdParamError /* Unexpected input, report error */ - bl _dbg__proc_brkpt_params /* R0: Breakpoint Address */ + teq r1, #CMD_BKPT_REMOVE_PARAMLEN /* Check for correct length */ + bne __dbg__procCmdParamError /* Unexpected input, report error */ + bl _dbg__proc_brkpt_params /* R0: Breakpoint Address */ teq r0, #0 - beq __dbg__procBreakpointAddrError /* Thumb2 instructions, or unknown kind */ - bl _dbg_find_breakpoint_slot /* Look for matching breakpoint slot, return index in R0 */ + beq __dbg__procBreakpointAddrError /* Thumb2 instructions, or unknown kind */ + bl _dbg_find_breakpoint_slot /* Look for matching breakpoint slot, return index in R0 */ cmp r0, #CMD_BKPT_NOTFOUND - beq __dbg__procBreakpointAddrError /* Specified Breakpoint not found! */ - _index2bkptindex_addr r0, r0 /* Calculate Breakpoint Entry Address */ - bl _dbg__clear_one_breakpoint /* R0: address of breakpoint to clear */ + beq __dbg__procBreakpointAddrError /* Specified Breakpoint not found! */ + _index2bkptindex_addr r0, r1 /* Calculate Breakpoint Entry Address */ + mov r0, r1 /* Move it to R0 for subroutine call */ + bl _dbg__clear_one_breakpoint /* R0: address of breakpoint to clear */ b __dbg__procCmdOk -- cgit v1.2.3 From 35623e1ac6e1f9b3932e0fe297010ee49e42ef20 Mon Sep 17 00:00:00 2001 From: TC Wan Date: Mon, 24 Jan 2011 09:45:26 +0800 Subject: cleanup syntax --- Host/nxt-gdb-server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Host/nxt-gdb-server.py b/Host/nxt-gdb-server.py index f59de1a..c745f85 100755 --- a/Host/nxt-gdb-server.py +++ b/Host/nxt-gdb-server.py @@ -99,7 +99,7 @@ class NXTGDBServer: if segno >= 0: # Check segno, if non-zero it must be monotonically increasing from 1, otherwise 0 if segno > 0: - assert segno == (prev_segno + 1), "segno = %s, prev_segno = %s" % (segno, prev_segno) + assert segno == prev_segno + 1, "segno = %s, prev_segno = %s" % (segno, prev_segno) prev_segno = segno msg.append(s) except usb.USBError as e: -- cgit v1.2.3 From 447d92e66be8c481db8e066da20fd8186ef78083 Mon Sep 17 00:00:00 2001 From: Tat-Chee Wan (USM) Date: Fri, 11 Feb 2011 17:52:43 +0800 Subject: added preliminary run loop separation --- Debugger/debug_comm.S | 2 +- Debugger/debug_runlooptasks.S | 86 +++++++++++++++++++++++++++++++++++++++++++ Debugger/debug_stub.S | 6 ++- 3 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 Debugger/debug_runlooptasks.S diff --git a/Debugger/debug_comm.S b/Debugger/debug_comm.S index e801479..77b2175 100644 --- a/Debugger/debug_comm.S +++ b/Debugger/debug_comm.S @@ -3,7 +3,7 @@ * */ -/* Copyright (C) 2007-2010 the NxOS developers +/* Copyright (C) 2007-2011 the NxOS developers * * Module Developed by: TC Wan * diff --git a/Debugger/debug_runlooptasks.S b/Debugger/debug_runlooptasks.S new file mode 100644 index 0000000..24f8bfe --- /dev/null +++ b/Debugger/debug_runlooptasks.S @@ -0,0 +1,86 @@ +/** @file debug_runloop.S + * @brief GDB Server platform Run Loop + * + */ + +/* Copyright (C) 2007-2011 the NxOS developers + * + * Module Developed by: TC Wan + * + * See AUTHORS for a full list of the developers. + * + * See COPYING for redistribution license + * + */ + + +/* + * The Debugger has to implement a Run Loop in ABORT mode + * since the hardware is still running. Consequently, + * the communications subsystems such as USB (and Bluetooth?) + * which is used to communicate with the Host needs to be + * serviced in order for actual data transmission and reception + * to take place. Currently we're reusing the platform's + * communication routines to do the actual tx/rx, so it means + * that it is not possible to set breakpoints in those modules. + * In addition, since the platform communication modules may + * handle other tasks, it is currently possible to enter an + * indeterminate state where certain communication messages trigger + * a platform response which cannot be handled by the Debugger Run Loop. + * The alternative is to implement our own communications routines, but + * that will take even more code. + * + * FIXME: It may become necessary to hack the platform communications + * routines to detect that we're in the Debugger Run Loop and not the + * normal run loop to avoid system crashes, but the current goal is to + * have as minimal changes to the platform code as possible. + * + * Since there are two Run Loops for the platform, the way in which + * they interact is as follows: + * + * [Platform Run Loop] - DBG_INIT/ GDB Cmd/ BKPT -> [Debugger Run Loop] + * \ <------ GO/ STEP/ CONT ----- / + * ... ... + * ... Handle GDB Cmd/Resp + * ... ... + * {normal runloop {communications / + * processing} watchdog routines} + * ^-------v v-------^ + * + * The Platform will invoke dbg__bkpt_init() after hardware and system initialization, + * before entering the Platform Run Loop. This switches processing over to the + * Debugger Run Loop which will wait for the GDB command to Go/Step/Cont before + * returning control to the Platform Run Loop. + * + * Subsequently, Debugger Run Loop will be triggered by Breakpoints, or + * when the communications subsystem receives a GDB Command. + * + * The Debugger Run Loop is actually dbg__bkpt_waitCMD(), this file contains + * the Run Loop Tasks which needs to be invoked periodically by the Run Loop, + * to minimize the coupling between the ARMDEBUG modules and the Platform. + * + * Note: The Debugger Run Loop does not handle Hardware Shutdown, it is + * assumed that we wouldn't need to do so in Debug Mode. + * + */ +#define __ASSEMBLY__ + + .global dbg__runloopTasks + + +#ifdef __NXOS__ +/* NxOS Run Loop */ +dbg__runloopTasks: +/* Currently, there's nothing that needs to be done in the NxOS Run Loop */ + bx lr + +#else +/* NXT Firmware Run Loop */ + .extern cCommCtrl + +dbg__runloopTasks: + /* FIXME: Add necessary cXXXCtrl calls here */ + bl cCommCtrl + /* OSWatchdogWrite is a NULL function in the NXT Firmware?! */ + bx lr +#endif diff --git a/Debugger/debug_stub.S b/Debugger/debug_stub.S index 53b4abd..5d4cfff 100644 --- a/Debugger/debug_stub.S +++ b/Debugger/debug_stub.S @@ -3,7 +3,7 @@ * */ -/* Copyright (C) 2007-2010 the NxOS developers +/* Copyright (C) 2007-2011 the NxOS developers * * Module Developed by: TC Wan * @@ -320,6 +320,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__runloopTasks /* Platform specific Run Loop processing */ /* The Debugger Interface can handle a total of (n-1) Breakpoint States and 1 Single Stepping State, @@ -501,7 +502,7 @@ dbg__bkpt_offset_outofrange: * ****************************************************************************/ dbg__bkpt_waitCMD: -1: bl dbg__getDebugMsg /* Read new message from Debugger, message buffer addr in R0, NULL if error */ +1: bl dbg__getDebugMsg /* Read new message from Debugger, message buffer addr in R0, 0 if none, -1 if error */ cmp r0, #0 beq 1b /* No message yet, keep checking */ movlt r0, #MSG_ERRCHKSUM /* Message invalid, checksum error? */ @@ -528,6 +529,7 @@ _dbg__cmdExists: _dbg__cmdError: _dbg_outputMsgStatusErr bl dbg__putDebugMsg /* Send error response to the GDB server */ + bl dbg__runloopTasks /* Execute platform run loop tasks while in ABRT mode */ b dbg__bkpt_waitCMD -- cgit v1.2.3