Skip to main content

IAR Embedded Workbench for RISC-V 3.40

Introduction to using trace

In this section:

See also:

Reasons for using trace

By using trace, you can inspect the program flow up to a specific state, for instance an application crash, and use the trace data to locate the origin of the problem. Trace data can be useful for locating programming errors that have irregular symptoms and occur sporadically.

Briefly about trace

To use trace in C-SPY requires that your target system can generate trace data. Once generated, C-SPY can collect it and you can visualize and analyze the data in various windows and dialog boxes.

C-SPY supports collecting trace data from these target systems:

  • SiFive devices with support for Nexus-based trace

  • The C-SPY simulator

External trace

External real-time trace is a continuously collected sequence of every executed instruction for a selected portion of the execution. The trace buffer is located in the debug probe and is continuously consumed by the C-SPY driver. However, if the data rate is too high, the data transfer will stall and the trace buffer could eventually fill up. The trace buffer collects trace data in real time, but the data is not displayed in the C-SPY windows until after the execution has stopped.

Note

Collecting this type of trace data requires an I-jet Trace debug probe.

RAM trace

RAM trace uses a designated on-chip trace buffer. The trace buffer collects trace data in real time, but the data is not displayed in the C-SPY windows until after the execution has stopped.

Note

The amount of trace data (including code coverage and function profiling) that can be collected is limited by the size of the on-chip trace RAM buffer.

Serial trace

Serial trace is a sequence of events of various kinds, generated by the on-chip debug hardware. The most important events are:

  • PC sampling

    The hardware can sample and transmit the value of the program counter at regular intervals.

  • Interrupt logs

    The hardware can generate and transmit data related to the execution of interrupts.

  • Data logs

    Using Data Log breakpoints, the hardware can be configured to generate and transmit events whenever a certain variable, or simply an address range, is accessed by the CPU.

Note

Collecting this type of trace data requires a combination of debug probe and target hardware that support it.

Trace features in C-SPY

In C-SPY, you can use the trace-related windows—Trace, Function Trace, Timeline, and Find in Trace.

Requirements for using trace

The C-SPY simulator supports trace-related functionality, and there are no further specific requirements.

Requirements for using Nexus-based trace

To use Nexus-based trace, you need an I-jet or I-jet Trace debug probe and an appropriate adapter. SRAM-based and External trace is supported. External trace requires an I-jet Trace debug probe.