Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect when a variable changes value

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.

like image 776
tatsuhirosatou Avatar asked Feb 22 '09 18:02

tatsuhirosatou


People also ask

What happens when the value of variable change?

When you reassign a variable to another value, it simply changes the reference to that new value and becomes bound to it.

Can the value of a variable change?

Remember that a variable holds a value and that value can change or vary.

Which function is used to check whether a variable have value?

The isset() function checks whether a variable is set, which means that it has to be declared and is not NULL. This function returns true if the variable exists and is not NULL, otherwise it returns false.

How do you verify a variable?

Answer: Use the typeof operator If you want to check whether a variable has been initialized or defined (i.e. test whether a variable has been declared and assigned a value) you can use the typeof operator.


2 Answers

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".
like image 56
Michael Borgwardt Avatar answered Oct 21 '22 04:10

Michael Borgwardt


OR Toggle Breakpoint on the line where the variable is declared, then right-click on the resulting entry, select "breakpoint properties" and deselect "Field Access".

like image 43
andreyro Avatar answered Oct 21 '22 03:10

andreyro