I cannot set a watchpoint in Eclipse (Photon) using CDT.
According to this answer to this question about setting memory breakpoints in CDT, one should be able to set a watchpoint by doing the following:
Run > Toggle Watchpoint
.However, no matter what I do the menu item Toggle Watchpoint is always disabled (greyed out).
After banging my head against the wall for a while, I finally found this bug report from 2013. This is a known issue (apparently for a long time). According to the bug report there are two workarounds:
Drop down menu -> Add Watch point (C/C++)...
).Run -> Toggle Watchpoint
The second workaround worked for me.
For example, if I wanted to add a watchpoint on the variable x
in foo.c, I would highlight x
in the editor for foo.c, then switch to another editor (e.g. bar.c) and then switch back to the editor for foo.c.