Real-Time Breakpoints

STM32CubeIDE & Setting Real-Time Breakpoints

Breakpoints are usually set prior to starting an application but sometimes there is a requirement for the processor to be running when setting a breakpoint i.e. setting in real-time. An example of this might be a streaming communication link. Here there is usually a configuration phase prior to the normal streaming operation. Having a breakpoint set at start-up may result in a time out and prevent streaming from being initiated.

When setting or clearing a breakpoint using STM32CubeIDE (or any other  GDB based debugger) the CPU will be halted for ~50ms whilst the breakpoint is configured. This is not an issue for many situations but for the above example, and others where the application interacts with time sensitive hardware, this may result in a timeout or worse.

As a workaround, breakpoints can be set via the low-level debugger e.g. OpenOCD. The underlying connection allows a breakpoint to be configured without stopping the CPU. The following OpenOCD commands will add and remove a hardware breakpoint:

bp <addr> 2 hw
rbp <addr>

Rather than having to do this manually via a Telnet session, QTrace Analyser can manage this TCP connection and allow breakpoints to be set in the Code Coverage window by right clicking on any source line containing code:

Setting a real-time breakpoint in QTrace Analyser

The breakpoint is highlighted in the code margin:

A real-time breakpoint set in QTrace Analyser

A side effect of bypassing the IDE and GDB is that they have no awareness of these breakpoints and so the IDE does not show the breakpoints. Also, when a breakpoint set in this way is hit, execution cannot be resumed until it is cleared.

To avoid this, QTrace Analyser constantly monitors target execution via the debugger TCP connection and if the CPU stops on one of its breakpoints it will automatically remove the breakpoint via the debugger to allow single stepping in the IDE or for execution to be resumed. The breakpoint will then be marked as disabled in the Code Coverage view:

A real-time breakpoint hit in QTrace Analyser

Note:  QTrace Analyser currently supports real-time breakpoints when OpenOCD is the underlying debugger.