This section describes how to debug your application at the register and instruction level. Debugging at a high level is all very well, but there are occasions where you need to look a little more closely into the way that your program executes to track down the causes of difficult-to-find bugs and CrossStudio provides the tools you need to do just this.
Setting up again
What we'll now do is run the sample application, but look at how it executes at the machine level. If you haven't done so already, stop the program executing by typing Shift+F5, by selecting Stop from the Debug menu, or clicking the Stop Debugging button on the Debug tool bar. Now run the program so that it stops at the first breakpoint again.
You can see the current processor state in the Register windows. To show the first registers window, do one of the following:
- From the Debug menu, click Debug Windows, Registers then Registers 1.
—or—
- Type Ctrl+T, R, 1.
The registers window can be used to view CPU and peripheral registers. To display the state of the registers for the active processor mode, select CPU - Current Mode from the Groups dropdown.
This register view is displaying the registers for the active processor mode. You can also display the entire set of ARM registers, to do this select CPU - ALL from the Groups menu on the toolbar.
Your registers window will look something like this:
There are four register windows so you can open and display four sets of CPU and peripheral registers at the same time. You can configure which registers and peripherals to display in the Registers windows individually. As you single step the program, the contents of the Registers window updates automatically and any change in a register value is highlighted in red.
Disassembly
The disassembly window can be used to debug your program at the instruction level. It displays a disassembly of the instructions around the currently located instruction interleaved with the source code of the program when available. When the disassembly window is focused, all single stepping is done one instruction at a time. The disassembly window also allows you to set breakpoints on individual instructions, you can do this by clicking in the gutter of the line containing the instruction you want to set the breakpoint on.
Stopping and starting debugging
You can stop debugging using Debug > Stop. If you wish to restart debugging without reloading the program then you can use Debug > Debug From Reset. Note that when you debug from reset no loading takes place so it is expected that your program is built in a way such that any resetting of data values is done as part of the program startup. You can also attach the debugger to a running target using the Target > Attach Debugger.