6

Is there a way, using the eclipse debugger, to break any time a particular variable is written to?

The only thing I can think of is to manually set a breakpoint at every reference but my codebase is several million lines and I really don't want to do that.

Darren Shewry
  • 10,179
  • 4
  • 50
  • 46
ewok
  • 20,148
  • 51
  • 149
  • 254

2 Answers2

6

You can set a watchpoint at the desired variable. Simply click on the line where the variable is declared, and select Run -> Toggle Watchpoint.

The watchpoint can break on either accessing the variable, modifying the variable, or both.

M A
  • 71,713
  • 13
  • 134
  • 174
  • @ewok Is it a local variable or a field? I guess local variables are not supported by watchpoints. – M A Dec 19 '14 at 15:19
  • 2
    Just removed that comment as `Toggle Breakpoint` only adds watchpoints on fields. Can't find a way to enable `Toggle Watchpoint`. – Nick Wilson Dec 19 '14 at 15:38
1

Use the Expressions View functionality from the Eclipse Debugger.

Georgian
  • 8,795
  • 8
  • 46
  • 87