In “Watchpoints: Data Breakpoints” I used the Eclipse based CodeWarrior to set breakpoints so the debugger stops when my application is writing or reading a certain memory location. That CodeWarrior is based on an earlier Eclipse version, and things are different in Eclipse Kepler and not so easy to find. So here is how I can use watchpoints in Eclipse Kepler:
While you technically *could* set a watchpoint on a local variable, it really only makes sense for a global variable (or to a global memory address). The easiest way in Eclipse Kepler is to use the Outline View and to use the ‘Toggle Watchpoint’ context menu:
💡 If the menu is grayed out, then your variable is not really a global variable?
In the dialog I can configure the watchpoint:
It is then listed in the Breakpoints view:
It is possible to set a watchpoint for an address too: instead of using a variable name, use an immediate number for the address:
Another (hidden) way is to use watchpoints directly in the Breakpoints view using that small triangle menu:
To trigger a stop only if the variable has a certain value, I can add a condition like below:
This will halt the target whenever the value of that global Variable changes to 50.
Summary
Using watchpoints is a very powerful way to debug an application, as I can stop the execution on memory read/write accesses. Watchpoint support is rather hidden in Eclipse Kepler, but knowing that it exists and where watchpoints can be enabled can help :-).
Happy Watching 🙂
Thanks! Can you offer any more tips on how the Range and Condition fields are used?
LikeLike
I don’t have much more tips about this. At least not in Eclipse Kepler, as somehow many watchpoint features seem to be broken (conditions seem not to work properly). Not sure why…
LikeLike
Pingback: Tutorial: Catching Rogue Memory Accesses with Eclipse and GDB Watchpoints | MCU on Eclipse