How do I use breakpoints on data?

The Watchpoints are data breakpoints. Instead breaking/stopping the application on an instruction, it allows to stop the CPU on a memory access. The number and capabilities of watchpoints depend on the microcontroller used. Most vendors offer a few watchpoints, and even a single one can save many hours of debugging.

You can set it up to trigger either on read or write access, or both. The hardware implements this typically with an address comparator. If there is a match of the address on the bus, then the CPU gets stopped, or whatever you configure it to do.

To add a watchpoint:

  1. Start a debugging session.
  2. Right-click in the Variables view and select Add Watchpoint (C/C++) from the context-menu.

    The Add Watchpoint dialog box appears.

    Figure 1. Add Watchpoint Dialog Box

    Add Watchpoint Dialog Box

  3. Specify the expression for which you want to add the watchpoint in the Expression to watch textbox.
  4. Select the Memory space, Units and access type as per requirement.
  5. Click Ok .

As the watchpoints are the data breakpoints, the new watchpoint appears in the Breakpoints view.

Similarly you can create a watchpoint on memory in the Memory View. The following figure shows the Memory view with Add Watchpoint (C/C++) option:

Figure 2. Memory View with Add Watchpoint (C/C++) Option

Memory View with Add Watchpoint (C/C++) Option