An example software sequence to
perform PC Trace operation is as follows:
- Initialize the PC Trace module by
writing 1 to PCTRACE_GLOBAL.INIT. The trace initialize operation resets the
buffer pointer and overflow flags, and clears the values of the
PCTRACE_LOGPC_SOFTENABLE and PCTRACE_LOGPC_SOFTDISABLE registers.
- Start the PC Trace operation by
writing 1 to PCTRACE|_GLOBAL.EN.
- Execute the desired code sequence
to be profiled.
- Stop the PC Trace operation by
writing 0 to PCTRACE_GLOBAL.EN. This step is optional, as the PC Trace buffer
can be read while trace operation is active.
- To determine if there are valid
entries in the trace buffer and how many:
- Examine the buffer
pointer by reading PCTRACE_BUFFER.PTR. If the pointer value is 0, then
no discontinuities have been detected since PC Trace was initialized. A
non-zero value indicates the number of locations in the buffer that
contain valid entries. For instance, PTR = 4 indicates that locations 0,
1, 2, and 3 contain valid entries (SRC, DST, SRC, DST).
- Examine the BUFFER_FULL
bit in the PCTRACE_BUFFER register. If BUFFER_FULL = 1, then the
following possibilities apply:
- If PTR = 0, then
the buffer is simply full and contains the maximum number of
entries possible.
- If PTR > 0,
then a buffer overflow has occurred. The value of PTR indicates
by how many entries the buffer has overflowed: this is a
circular buffer.
- Read PCTRACE_LOGPC_SOFTENABLE
(and optionally PCTRACE_LOGPC_SOFTDISABLE) if needed to determine the bounding
addresses of the trace operation, in case the code sequence being traced does
not begin or end at a discontinuity boundary (for example, partial function
trace).
- Trace discontinuities are
recorded in the trace buffer in pairs (SRC, DST). Use this data to reconstruct
the code execution sequence. While reading the trace buffer, be sure to examine
the BLOCKED status bit to confirm the validity of each trace entry.