Watch it!

Barry Pretsell's picture

Watching variables is a common task programmers wish to employ when debugging. Usually the scenairo is that you want to know why a certain variable gets a certain value.

To add a variable to the watch list, first select the Watch tab on the bottom left of Komodo. Now click the square dotted icon with the yellow highlight on the top left of it. This will bring up the following dialog. In here type the variable name you wish to add to the watch list.

debugger watch 1
Now we can debug as normal, I've added a breakpoint just after the $return variable gets set.
debugger watch 2
After clicking the Go/Continue debugger command button, the execution breaks at the next break point. Whenever any of our watched variables get changed, the watch window updates. So here we can now see the current value of $return.
debugger watch 3
But that is not all. With Watch we can change the value of a watched variable thus changing how the rest of the program will execute. To do this click on the variable in the Watch window, then click on the pencil icon. (It is the one to the left of the add watch variable icon).
debugger watch 4
Watch is useful though its features are covered by the Locals and Globals tabs, however sometimes you just want to focus on a small subset of variables so watching just the one you are interested in is alot easier than having to watch the whole set of variables in your program.