Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to track at which point a variable gets changed?

I have a BOOL instance variable which -for some reason- some time later always reads NO even if I set it to YES (Yes, I am not so stupid to write or read the wrong variable, trust me). I spent an hour searching my whole project for any possibilities where that variable might be set to NO but can't find it.

Is there a way to trace changes of it's value, i.e. to let the debugger halt at exactly the position where the variable is about to be modified?

like image 571
openfrog Avatar asked Dec 10 '22 06:12

openfrog


1 Answers

Found a solution without hacking the code:

  1. Launch debugger with breakpoints enabled

  2. Set a breakpoint at some point where the variable in question is in scope

  3. Run. When it halts, inspect the debugger and find that variable.

  4. Right-click on it and choose "Watch Variable".

like image 121
openfrog Avatar answered Dec 23 '22 14:12

openfrog