TotalView User Guide : Part V: Debugging : Setting Action Points : Defining Eval Points and Conditional Breakpoints : Creating Conditional Breakpoint Examples

Creating Conditional Breakpoint Examples
The following are examples that show how you can create conditional breakpoints:
*
The following 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;
*
$count 10
*
$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 TotalView internal counter is a static variable, which means that TotalView remembers its value every time it executes the eval point. Suppose you create an eval point within a loop that executes 120 times and the eval point contains $count 100. Also assume that the loop is within a subroutine. As expected, TotalView stops execution the 100th time the eval point 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 lots of different places from 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”.

Rogue Wave Software, Inc.
Voice: (303) 473-9118
rwonlinedocs@roguewave.com