
Debug Support
8-36
Copyright 1999, 2000 ARM Limited. All rights reserved.
ARM DDI 0144B
8.10
The behavior of the program counter during debug
To force the ARM940T to branch back to the place where program flow has been
interrupted by debug, the debugger must keep track of what happens to the PC. There
are six cases:
Breakpoint
on page 8-36
Watchpoint
on page 8-36
Watchpoint with another exception
on page 8-37
Watchpoint and breakpoint
on page 8-37
Debug request
on page 8-37
System speed accesses
on page 8-38.
These cases are described below. In each case the same calculation is used to determine
where to resume execution. This is explained in
Summary of return address calculations
on page 8-38.
8.10.1
Breakpoint
Entry to debug state from a breakpointed instruction advances the PC by 16 bytes in
ARM state, or 8 bytes in Thumb state. Each instruction executed in debug state
advances the PC by one address. The normal way to exit from debug state after a
breakpoint is to remove the breakpoint, and branch back to the previously breakpointed
address.
For example, if the ARM940T entered debug state from a breakpoint set on a given
address and two debug speed instructions were executed, a branch of minus 7 addresses
must occur (four for debug entry, plus two for the instructions, plus one for the final
branch). The following sequence shows ARM instructions scanned into scan chain 1.
This is MSB first, and so the first digit represents the value to be scanned into the
SYSSPEED bit, followed by the instruction:
0 EAFFFFF9
1 E1A00000
; B -7 addresses (two’s complement)
; NOP (MOV r0, r0), SYSSPEED bit is set
For small branches, the final branch can be replaced with a subtract having the PC as
the destination (
SUB PC,PC,#28
for ARM code in the above example).
8.10.2
Watchpoint
Returning to the program execution after entering debug state from a watchpoint is done
in the same way as the procedure described in
Breakpoint
. Debug entry adds four
addresses to the PC, and every instruction adds one address. Because the instruction
after the one that caused the watchpoint has executed, instruction execution resumes at
the one after that.