12.11.3. Single-stepping

You can use the breakpoint mismatch bit to implement single-stepping on the processor. Unlike high-level stepping, single-stepping implements a low-level step that executes a single instruction at a time. With high-level stepping, the instruction is decoded to determine the address of the next instruction and a breakpoint is set at that address.

Example 12.10 shows the code for single-stepping off an instruction. The processor must be configured for halt-mode debugging.

Example 12.10. Single-stepping off an instruction

SingleStepOff(uint32 address)
{
        bkpt := FindUnusedBreakpointWithMismatchCapability();
        SetComplexBreakpoint(bkpt, address, 4 << 20);
}

Note

In Example 12.10, the third parameter of SetComplexBreakpoint() indicates the value to set DBGBCR[22:20].

This method of single-stepping steps off the instruction that might not necessarily be the same as stepping to the next instruction executed. In certain circumstances, the next instruction executed might be the same instruction being stepped off.

The simplest example of this is a branch to a self instruction such as (B .). In this case, the wanted behavior is most likely to step off the branch to self because this is often used as a means of waiting for an interrupt.

A more complex example is a return from function that returns to the same point. For example, a simple recursive function might terminate with:

BL    ThisFunction
POP    {saved_registers, pc}

In this case, the POP instruction loads a link register that is saved at the start of the function, and if that is the link register created by the BL instruction shown, it points back at the POP instruction. Therefore, this single step code unwinds the entire call stack to the point of the original caller, rather than stepping out a level at a time. It is not possible to single step this piece of code using either the high-level or low-level stepping methods.

Copyright © 2010-2011 ARM. All rights reserved.ARM DDI 0460C
Non-ConfidentialID021511