Keith Morgan
Keith Morgan

Reputation: 741

Eclipse CDT cannot set watchpoint (always disabled - greyed out)

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).

Upvotes: 4

Views: 2343

Answers (1)

Keith Morgan
Keith Morgan

Reputation: 741

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.

Upvotes: 5

Related Questions