Skip to main content

IAR Embedded Workbench for Arm 9.70.x

Breakpoint types

In this section:

Depending on the C-SPY driver you are using, C-SPY supports different types of breakpoints.

Code breakpoints

Code breakpoints are used for code locations to investigate whether your program logic is correct or to get trace printouts. Code breakpoints are triggered when an instruction is fetched from the specified location. If you have set the breakpoint on a specific machine instruction, the breakpoint will be triggered and the execution will stop, before the instruction is executed.

Log breakpoints

Log breakpoints provide a convenient way to add trace printouts without having to add any code to your application source code. Log breakpoints are triggered when an instruction is fetched from the specified location. If you have set the breakpoint on a specific machine instruction, the breakpoint will be triggered and the execution will temporarily stop and print the specified message in the C-SPY Debug Log window.

Trace Start/Stop Trigger breakpoints

Trace Start Trigger and Trace Stop Trigger breakpoints start and stop trace data collection—a convenient way to analyze instructions between two execution points.

Data breakpoints

Data breakpoints are primarily useful for variables that have a fixed address in memory. If you set a breakpoint on an accessible local variable, the breakpoint is set on the corresponding memory location. The validity of this location is only guaranteed for small parts of the code. Data breakpoints are triggered when data is accessed at the specified location.

The execution will usually stop directly after the instruction that accessed the data has been executed. However, on some newer Arm devices like Cortex-M55, data breakpoints might not stop the execution until several instructions later. Moreover, if the CPU is halted for any reason, any such “delayed” data breakpoint will never have any effect. Examples: If two consecutive instructions read from two different locations that both have a data breakpoint, the second one will not have any effect. Likewise, if a data breakpoint is immediately followed by a code breakpoint, then that data breakpoint will not have any effect.

Data Log breakpoints

Data log breakpoints are triggered when a specified variable is accessed. A log entry is written in the SWO Trace window (Trace window in the simulator) for each access. A log message can also be displayed in the Data Log window. Data logs can also be displayed on the Data Log graph in the Timeline window, if that window is enabled. However, these log messages require that you have set up trace data in the SWO Configuration dialog box, see SWO Configuration dialog box.

You can set data log breakpoints using the Breakpoints window, the Memory window, and the editor window.

Using a single instruction, the microcontroller can only access values that are four bytes or less. If you specify a data log breakpoint on a memory location that cannot be accessed by one instruction, for example a double or a too large area in the Memory window, the result might not be what you intended.

Immediate breakpoints

For some cores and devices, the C-SPY simulator lets you set immediate breakpoints, which will halt instruction execution only temporarily. This allows a C-SPY macro function to be called when the simulated processor is about to read data from a location or immediately after it has written data. Instruction execution will resume after the action.

This type of breakpoint is useful for simulating memory-mapped devices of various kinds (for instance serial ports and timers). When the simulated processor reads from a memory-mapped location, a C-SPY macro function can intervene and supply appropriate data. Conversely, when the simulated processor writes to a memory-mapped location, a C-SPY macro function can act on the value that was written.

JTAG watchpoints

The C-SPY J-Link/J-Trace driver can take advantage of the JTAG watchpoint mechanism in Arm7/9 cores.

The watchpoints are implemented using the functionality provided by the Arm EmbeddedICE™ macrocell. The macrocell is part of every Arm core that supports the JTAG interface. The EmbeddedICE watchpoint comparator compares the address bus, data bus, CPU control signals and external input signals with the defined watchpoint in real time. When all defined conditions are true, the program will break.

The watchpoints are implicitly used by C-SPY to set code breakpoints or data breakpoints in the application. When setting breakpoints in read/write memory, only one watchpoint is needed by the debugger. When setting breakpoints in read-only memory, one watchpoint is needed for each breakpoint. Because the macrocell only implements two hardware watchpoints, the maximum number of breakpoints in read-only memory is two.

For a more detailed description of the Arm JTAG watchpoint mechanism, refer to these documents from Arm Limited:

  • ARM7TDMI (rev 3) Technical Reference Manual: Chapter 5, Debug Interface, and Appendix B, Debug in Depth

  • Application Note 28, The ARM7TDMI Debug Architecture

Flash breakpoints

Software code breakpoints (breakpoints that rely on writing breakpoint instructions into memory) can be set in flash memory or other non-volatile executable memory using the flash breakpoint mechanism. This involves programming of the flash memory using a flash loader in the same way as is done when downloading an application.

This breakpoint type is available for the C-SPY I-jet driver. Other debug probes might offer the possibility to set breakpoints in flash memory using other mechanisms. J-Link, for example, is one of these.