Faster debugging with watchpoints | Interrupt

One of the most challenging types of issues to debug is memory corruption! Memory corruption can be caused for a variety of reasons including when data is used after it has been freed, a read or write goes past the end of a buffer, thread safety constructs are missing, or a linker script is misconfigured. By the time the system finally faults or encounters an error, the original operation which spiraled the system into the bad state is often lost!


This is a companion discussion topic for the original entry at https://interrupt.memfault.com/blog/cortex-m-watchpoints

Excellent post, as always. You have content of incredible high quality here, thank you very much!

There is a question I have since quite some time now: can the DWT unit be used together with SWO for tracing a variable value without interrupting the program flow?

Yes! I allude to it in Profiling Firmware on Cortex-M | Interrupt. You can setup ITM to output data over SWO when the DWT is triggered:

  1. DWT Data trace: When enabled, events are generated when a specific data address (or range of addresses) is accessed. The events contain the PC, the data address, and the data value.

Is there a way to set a data watchpoint in code during execution on ARM926 hardware?