How to detect when a variable changes value

tatsuhirosatou picture tatsuhirosatou · Feb 22, 2009 · Viewed 43.1k times · Source

How can I easily detect when a variable changes value? I would like the execution of the program to break on the debugger whenever a specified variable changes value. Right now I'm using Eclipse's debugger.

Answer

Michael Borgwardt picture Michael Borgwardt · Feb 22, 2009

For a class or instance variable

  1. right-click on the variable in the outline view
  2. select "Toggle Watchpoint"
  3. Then, in the breapkoints view, you can right-click on the resulting entry
  4. select "breakpoint properties"
  5. deselect "Field Access".