B.2. How the debugger steps and runs code

The following algorithm is used to step code:

  1. If the current instruction has a breakpoint on it, it is removed. If it was a breakpoint you defined, it is put back after the step. If it was a breakpoint from a previous step, it is discarded.

  2. The instruction is read and decoded (the decoding scheme chosen is based upon the current value of the T bit in the CPSR). The address of the next instruction to be executed is calculated and a breakpoint placed on that address. Typically this is pc+4 for ARM code and pc+2 for Thumb® code but if a branch instruction is to be stepped the branch address is calculated.

  3. The processor is restarted. If an interrupt is pending at this point and interrupts are enabled, the interrupt is taken, executed to completion and the single instruction is stepped after the ISR has completed. Consequently, if an ISR fails to complete, the step also fails to complete.

  4. Single stepping a branch to itself is not supported by this algorithm so an error is generated in this case.

The following algorithm is used to run code:

  1. If the current instruction has no breakpoint on it the processor is restarted.

  2. If the current instruction has a stepping breakpoint on it, it is removed and the processor is restarted.

  3. If the current instruction has your breakpoint on it, it is removed and a single step is performed to the next location using the stepping algorithm above. Your breakpoint is put back and the processor is restarted from the new location (unless there is also one of your breakpoints on the new location).

    This is done so that restarting from a breakpoint does not miss any subsequent hits on the same breakpoint. For example, when in a loop, you might execute one pass of the loop by pressing Go. This mechanism ensures that only one loop is executed each time you press Go.

Stepping through high-level language code involves a combination of these techniques.

Note

Multi-ICE does not rewrite software breakpoint instructions every time you press Go in the debugger. This means that if you are using scatter-loaded images or self-modifying code you must manually set and unset software breakpoints around code that changes.

Copyright © 1998-2002 ARM Limited. All rights reserved.ARM DUI 0048F
Non-Confidential