Creating Conditional Breakpoints
The following are examples for creating conditional breakpoints:
*This example defines a breakpoint that is reached whenever the counter variable is greater than 20, but less than 25:
if (counter > 20 && counter < 25) $stop;
*This example defines a breakpoint that stops execution every tenth time that TotalView executes the $countfunction
$count 10
*The following example defines a breakpoint with a more complex expression:
$count my_var * 2
When the my_var variable equals 4, the process stops the eighth time it executes the $count function. After the process stops, TotalView reevaluates the expression. If my_var equals 5, the process stops again after the process executes the $count function ten more times.
The TotalViewinternal counter is a static variable, which means that TotalView remembers its value every time it executes the evalpoint. Suppose you create an evalpoint within a loop that executes 120 times and the evalpoint contains $count 100. Also assume that the loop is within a subroutine. As expected, TotalView stops execution the 100th time the evalpoint executes. When you resume execution, the remaining 20 iterations occur.
The next time the subroutine executes, TotalView stops execution after 80 iterations because it will have counted the 20 iterations from the last time the subroutine executed.
There is good reason for this behavior. Suppose you have a function that is called from several places within your program. Because TotalView remembers every time a statement executes, you could, for example, stop execution every 100 times the function is called. In other words, while $count is most often used within loops, you can use it outside of them as well.
For descriptions of the $stop, $count, and variations on $count, see Using Built-in Variables and Statements.