Print statements are common in debugging, in which you insert printf() or
PRINT statements in your code and then inspect the output. However, using print statements requires that you recompile your program; further, the output may be difficult to navigate as it is likely to be out of order when running multi-process, multi-threaded programs.
While TotalView is far more sophisticated in displaying information, you can still use printf() statements if you wish — but more effectively and without recompiling your program. Simply add a breakpoint that prints information, using the
Action Point Properties, dialog (
Figure 1). This feature allows you to add any code you want to a breakpoint.
A breakpoint with associated code is called an eval point. Here’s where TotalView does things a little differently. When your program reaches this eval point, TotalView executes the code. For instance, in the above case, TotalView prints the value of
i.
Eval points do exactly what you tell them to do. Note that, in Figure 1, TotalView allows your program to continue to execute because you didn’t tell it to stop. In other words, you don’t have to stop program execution just to observe print statement output.
Figure 2 shows two eval points that do stop execution.
The eval point in the foreground uses programming language statements and a built-in debugger function to stop a loop every 100 iterations. It also prints the value of
i. In contrast, the eval point in the background just stops the program every 100 times a statement is executed.
Eval points let you patch your programs and route around code that you want replaced. For example, suppose you need to change several statements. Just add these to an action point, then add a
goto statement that jumps over the code you no longer want executed. For example, the eval point in
Figure 3 executes three statements and then skips to line 656.