7.5.4. Tracing return from an exception

In ARM architectures other than ARMv7-M, returning from an exception is performed by executing the special RFE or ERET instructions, or by moving the value required for the return address into the PC. In versions prior to ETMv3.5, the ETM traces these returns as simple indirect branches. For more information on tracing return from an exception on these processors, see Tracing of exception return, ETMv3.5.

The ARMv7-M architecture extends the possible methods of returning from an exception, by extending the meaning of some existing instructions. In simple terms, if one of these instructions results in a transfer of a particular predefined value into the PC then this is treated as a return from exception event. This event causes eight registers to be popped from the stack, and has other minor effects. The instructions that can be used in this way are:

In ARMv7-M processors, this method is always used to return from an exception. For more information see the ARMv7-M Architecture Reference Manual.

These command extensions mean that the effect of a particular command can vary enormously, depending on whether it is used normally or to cause a return from exception. Therefore, ETMv3.4 introduces a new packet that is used to identify the return from exception use of these commands. This is the Return from exception packet.

When one of the extended instructions causes a return from exception event, a Return from exception packet is inserted in the trace, between the P-header for the instruction and the branch packet for the branch to the return address. This means that the trace for the command, when causing a return from exception, is:

Figure 7.39 shows the format of the Return from exception packet.

Figure 7.39. Return from exception packet, ETMv3.4 and later

To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.


When tracing the use of one of these commands for a Return from exception, the branch packet output depends on whether or not the return is from a tail-chained exception handler. See Automatic stack push on exception entry and pop on exception exit for an explanation of tail-chaining.

Note

A Return from exception packet is always output when one of the extended commands is used to cause a return from exception, regardless of any tail-chaining effects. This means that a Return from exception packet is not always associated with a pop and restore of the registers, because there is no pop and restore on a return from a tail-chained exception handler.

If cycle-accurate tracing is enabled, outputting the Return from exception packet has no effect on the current cycle count, and does not imply the occurrence of any W, E or N atoms.

Tracing might be enabled while a stack pop is in progress, either because of exit from an overflow condition or from a normal trace-on occurrence. In this situation, tracing must be enabled immediately:

If a new higher priority exception stops the stack pop by preemption, the branch to the new exception handler must indicate that the last instruction was canceled, with no resumption information. This means that the Can bit is set to 1, and Resume[3:0] = b0000. This indicates that the Return from exception packet was canceled, but the return from exception instruction was not canceled. The presence of a Return from exception packet in the trace output stream indicates that the instruction causing the return from exception completed.

Data tracing of return from exception

If data tracing is enabled, the data transfers of the stack pop must be traced. However, these transfers do not have a parent instruction. When a stack pop is performed, the data transfers are associated with the appropriate Return from exception packet. These transfers are traced in the same way as a normal LDM instruction.

Note

As stated earlier in this section, a Return from exception is always output when one of the extended commands is used to cause a return from exception, regardless of any tail-chaining effects. However, no stack pop is performed on a return from a tail-chained exception. This means that, when data tracing is enabled, there can be Return from exception packets with no associated data transfers.

Copyright © 1999-2002, 2004-2009, 2011 ARM Limited. All rights reserved.ARM IHI 0014Q
Non-ConfidentialID101211