Program errors come in many forms; most often because the CPU faithfully runs the code that we programmers actually write, instead of the code that we meant to write (“do what I meant, not what I wrote” :) ). An MCU environment provides additional challenges ranging from interrupts occurring to memory limitations. A debugger allows you to pause a program and examine the program’s internal states. This provides insight as to what the program is doing, and sometimes even why it is executing at that location in the first place.
To debug, you typically set breakpoints in the program code prior to running the program under debugger control. When the program execution hits a breakpoint, the CPU pauses execution, and you may then use debugger commands to examine the program states and memory contents. There are many ways to use a debugger, and users develop their own strategies of the most optimal methods for their own use.
The JumpStart Debugger is a source-level debugger. Source-level means that your breakpoints are set on C source lines, and the debugger is aware of the data types of the variables. For example, if you examine the contents of a struct variable, the debugger shows the member field names and their contents. The debugger maintains internal structures by mapping user program source information to the PC location and memory addresses. This information is generated by the compiler tools during the program build process.
A breakpoint stops at the “execution point” associated with a source line. Note that some C source statements may contain multiple execution points, e.g. a for statement for (int i = 0; i < 10; i++) contains 3 execution points, one for each part of the for loop. Setting a breakpoint at a source line with multiple execution points would pause at all execution points of that statement.
The JumpStart Debugger requires a hardware debug pod to provide low-level access to the target device.
Debug functions can be loosely divided into these groups:
· Breakpoints and source line stepping
· Program state viewing
· Data viewing
"Debug->Start/Continue" starts the debugger. Be sure the following are set before starting:
· Debug->active debuggers is set to “Target’s default”
· Project->Debug/download options are set correctly for the target debug hardware
· Settings->Debugger… controls debugger behavior
To stop the debugger, you invoke "Debug->Stop debugger":
Sometimes your program may not behave as expected, and not hit the breakpoints you have set. In that case, "Debug->Break debugger" attempts to pause the CPU. As the CPU may pause at a location that does not have C source level information (e.g. within a library function provided by ImageCraft or some third-party vendor), some of the debug instructions may not be available, and you may have to use the ADT to debug in assembler mode (see below).
This restarts the target device to allow you
to restart debugging.