This section describes how to debug your application at the register and instruction level. Debugging at a high level is fine, but sometimes you need to look more closely into the way your program executes to track down the causes of difficult-to-find bugs. CrossWorks provides the tools you need to do so.

Setting up again

Next, we'll run the sample application again and 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 Debug > Stop, or by clicking the Stop Debugging button on the Debug tool bar. Now, run the program until it stops at the first breakpoint again.

You can see the current processor state in the Register windows. To show the first Registers window:

The Registers window can be used to view CPU and peripheral registers. To display the state of the registers for the active processor mode, use the Registers 1 window's Register Groups menu to select CPU - Current Mode.

This 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 Register Groups menu. 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 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, if the source is available. When the Disassembly window has focus, all single-stepping is done one instruction at a time. This window also allows you to set breakpoints by clicking in the gutter of lines containing instructions on which you want to set a breakpoint.

Stopping and starting debugging