After setting a watch on a variable, how can a watch variable in debugger be evaluated or modified?
There is the Evaluate/Modify feature in the debugger but how is this used?
Evaluate/Modify
Note: This extended Toad feature is only available in Toad for Oracle editions that include debugging functionality. Currently this is not available in JDWP debugging (v9.0+).
The Evaluate/Modify window lets you view the value of a variable on the fly, without having to set a watch. It also lets you change the value of a variable and continue executing. This is useful for advancing a loop variable to the end of a "FOR COUNTER_VAR IN 1..500 LOOP" loop. In this case, evaluate Counter_Var, and set its new value to 499. So, you do not have to step through the loop the extra 498 times. If you want to change a date variable, enter the new date in format DD-MON-YY or DD-MON-YYYY with single quotes surrounding the date: for example, '31-DEC-99'.
Check the Package Variable check box if the variable to evaluate is a package level variable, and not a local variable.
The Evaluate/Modify window is not dockable with the rest of the debug windows.
Making the watch variable editable while debugging/stepping through code:
1. Set a watch on a variable in the code.
2. In the Watch tab, right click over the watch variable.
The Evaluate/Modify window will open and it will allow you to view and reset the value of any variable in the code on the fly.
Evaluate/Modify window:
You can only open the Evaluate/Modify window once you've started debugging and have stepped into the code. If working with the feature without watch variables, go to Debug menu and choose Evaluate/Modify to bring up the window.
Evaluating a Variable:
1. Launch the Evaluate/Modify window.
2. In the window, type in the variable to be evaluated in the Expression field of the window.
3. Click the Evaluate icon in the upper left corner of the Evaluate/Modify window to see what the value is for that variable at that moment.
You can continue stepping through the code with the debugger. At any point you can change the variable you want to check by changing the value in the Expression field. At any point you can click the Evaluate icon to re-evaluate the value of the variable.
Note, you will need to re-evaluate the variable to view changes to the value since it will not automatically updated like a watch.
Modifying a Variable:
1. Launch the Evaluate/Modify window.
2. In the window, type in the variable to be modified in the Expression field of the window.
3. Click the Modify icon in the upper left corner of the Evaluate/Modify window to re-set the value of that variable.
Note, the modify action only affects the one noted variable. Modifying one variable will reinitialize it, but will accordingly reinitialize other variables that may be dependent on it.
Example: In the case of a loop, a loop is originally set to start at 1 and max out at 100 loops. The loop's counter variable can be modified on the fly to start at 20 instead of 1. The code can be stepped though and will work with this change. But any variables set before this loop will not be adjusted for first 20 loops that the loop counter change skipped. Any values incremented within the loop will only be incremented 80 times and may not reflect the true outcome in a real run of 1 to 100 loops.