TotalView User Guide : Part II: Debugging Tools and Tasks : Visualizing Programs and Data : Displaying Call Graphs
Displaying Call Graphs
Debugging is an art, not a science. Debugging often requires the intuition to guess what a program is doing and where to look for problems. Just locating a problem can be 90% or more of the effort. The call graph can help you understand what your program is doing so that you can understand how your program is executing.
The call graph shows all currently active routines linked by arrows indicating if one routine is called by another. The call graph is dynamic in that it displays activity at the moment it is created. The Update button recreates the display.
To display a call graph, select Tools > Call Graph from the Process Window. A sample call graph is shown in Figure 145.
Figure 145: Tools > Call Graph Dialog Box
You can display a call graph for specific processes and threads using the controls at the top of this window. By default, TotalView displays a call graph for the group defined in the toolbar of the Process Window. For multi-process or multi-threaded programs, numbers next to the arrows indicate which threads have a routine on their call stack.
Diving on a routine within the call graph creates a group called call_graph, containing all the threads that have the routine you dived on in its call stack. If you look at the Process Window’s Processes tab, you’ll see that the call_graph set is selected in the scope pulldown.
In addition, the context of the Process Window changes to the first thread in the set.
As you begin to understand your program, you will see that it this diagram reflects your program’s rhythm and dynamic. As you examine and understand this structure, you will sometimes see things that don’t look right — these are often places where you should look for problems.
Diving on a routine that doesn’t look right can isolate the processes into their own group so that you can find out what is occurring there. Be aware that diving on a routine overwrites the group, so if you want to preserve the group, use the Groups > Custom Groups command to make a copy.
The call graph can also reveal bottlenecks. For example, if one routine is used by many other routines and controls a shared resource, this thread might be negatively affecting performance.