4

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:

  1. Highlight the variable in the editor, or select it in the Outline view.
  2. Click Run > Toggle Watchpoint.

However, no matter what I do the menu item Toggle Watchpoint is always disabled (greyed out).

Keith Morgan
  • 721
  • 7
  • 17

1 Answers1

5

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:

  1. Define [the watchpoint] via the Breakpoints view (i.e. Drop down menu -> Add Watch point (C/C++)...).
  2. After selecting the text with variable switch active parts to a different view/editor and back. This will enable 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.

Keith Morgan
  • 721
  • 7
  • 17
  • Could you explain this a little better, `2. After selecting the text with variable switch active parts to a different view/editor and back` ? Thanks – champost Nov 17 '18 at 05:21
  • @champost - I added an example explanation; hopefully that helps – Keith Morgan Nov 18 '18 at 13:36
  • This worked for me after opening the Breakpoints view, and messing around the menu options. I don't know the exact steps I took but, suddenly, "Toggle Watchpoint" was not greyed out anymore. – André Santaló Nov 17 '22 at 13:19