To create a watchpoint expression with the CLI, use the -e argument on the dwatch command, and enter an expression. The expression is compiled into interpreted code that is executed each time the watchpoint triggers.
CLI: dwatch -e expr
TotalView has two variables used exclusively with watchpoint expressions:
• $oldval: The value of the memory locations before a change is made.
• $newval: The value of the memory locations after a change is made.
NOTE >> Watchpoints are not available on the Mac OS X platform.
For example:
{if ($newval > 2) $stop}
This watchpoint triggers when the updated value of the variable arg_count equals more than two.
At this point, you can see in the VAR panel that arg_count equals 1:
The watchpoint is now reflected in the Action Points view with the watchpoint icon:
When you advance the program by choosing Go, Next or Step, for instance, TotalView stops at this watchpoint when the value of arg_count has been incremented past 2.
• The Processes & Threads view reports the Process State stopped at this watchpoint.
• The Source view identifies the location of the PC.
• The VAR panel reports that arg_count’s value is at 3.
• The Command Line view reports that watchpoint 2 has been hit.
• The Action Point view displays a pale yellow background to identify the stopped watchpoint.