Chapter 7. The Call Graph

7.1 Overview
7.2 Opening a call graph
7.3 Call graph layout
7.3.1 How the hierarchy is built
7.3.2 Caller and callee bullets
7.4 The mini-map
7.5 Color coding
7.6 Selection behavior
7.7 Contextual menu options
7.7.1 Showing system and uncalled functions
7.7.2 The caller and callee menu options
7.7.3 Contextual menu selection options
7.7.4 Contextual menu navigation options
7.8 The toolbar
7.9 The outline view

This chapter explores the call graph and the information it provides. It includes a general overview and sections on how to open a call graph, how the call graph is laid out, selection, color-coding, navigating using the mini-map, and contextual menu options.

7.1 Overview

While the function report and call chain lay out every detail of your functions' performance in their comprehensive tables, the call graph's purpose is to show you visually which functions call what and where the hot spots are in the hierarchy. The call graph gives you a visual representation of each functions' timing performance. Curious where the function that caused the biggest performance bottleneck fits in your hierarchy? Hold down the spacebar to turn the cursor into a hand and drag the screen to the function box colored the darkest shade of red.

Figure 7.1. The Call Graph

The call graph is built to remain comprehensible even when the code example is complex. The use of callee and caller bullets eliminates the need for many of the intersecting wires necessary to describe the complex relationships between the functions in your source code. Right-click on the bullet tab to see which functions called, or were called by, the attached function.

7.2 Opening a call graph

The most direct route to an analysis file's call graph is through the summary report's navigation section. The call graph link, presented next to the icon is used to open that analysis file's call graph. In addition to using the navigator link in the summary report, you can also access the call graph from any of the other report types via the contextual menu or one of the other report's toolbar. Right-clicking on a function, or a group of functions, and choosing the 'Select in Call Graph' menu option will open the call graph with the chosen function or functions selected.

7.3 Call graph layout

The call graph provides you with a visual representation of your code hierarchy, laying out each function according to where it is called and using arrows to connect calling functions. The direction of the arrow indicates which function was the calling function. An arrow pointing to a function tells you that function is the callee and the function from which the line originates is the calling function. This section will describe the layout of the call graph in more depth, providing a quick overview of how the hierarchy is built and what the bullets to the right and left of the call graph's functions represent.

7.3.1 How the hierarchy is built

The hierarchy of functions, as presented in the call graph, is built based on the call chain captured during execution. The originating function is placed in the far left column and functions it calls are placed in the column to its right. Functions that these functions call are placed in a column to the right of that and so on down the line, until all of the functions have been placed. There is a caveat to this placing behavior. If a function is called at multiple levels of the hierarchy, it will be placed as far left as possible in the call graph.

To illustrate, if the function main calls function a, which in turn called function b, it would appear as follows in the call graph:

Figure 7.2. A Simple Call Hierarchy

If, in addition to function a, the main function also calls function b, function b would be put in a higher place in the hierarchy, nearer to main:

Figure 7.3. A Call Hierarchy with Multiple Call Paths

The premise is straightforward, but real-world algorithms describe criss-crossing hierarchies far more complex than the example presented in Figures 7.2 and 7.3. Rather than present the call graph with all of these connections visually represented as a spider web of criss-crossing call arrows, RealView Profiler's call graph uses a simple method to determine whether or not a call line will be drawn.

7.3.2 Caller and callee bullets

In cases where the calling function is in the same column or in a column just to the left or right of the called function, a call arrow will be drawn from the caller to the callee. If, however, the called function appears in a column more than one column to the left of the calling function, a bullet will be added to the left of the calling function and to the right of the called function. The number contained in the bullet represents how many calling or called functions are being shown this way.

Figure 7.4. Caller Bullets

Right-click on a caller or callee bullet to see all of the functions contained in it. Choose a function in the contextual menu to select and center that function in the call graph. In this way, all of the calling and called functions are still easily accessible, but call arrows are not used to cross many layers of the hierarchy.

7.4 The mini-map

In the bottom left hand corner of the call graph is a mini-map that can be used to easily navigate around the call graph when the hierarchies are too large to fit in the editor section of Eclipse.

Figure 7.5. The Call Graph Mini-map

When inside the mini-map, but outside the draggable view area, the cursor will change into crosshair. Click on a location in the mini-map and that section will immediately be centered in view. If you hover over the draggable area box within the mini-map, the cursor will change into a hand that allows you to click and drag the view area. Panning the view area in this manner enables you to quickly scan sections of the hierarchy without using the scroll bars.

The objects in the mini-map have the same color coding as the functions in the call graph itself. The bright red function in the hierarchy will appear as bright red in the mini-map so that you can use the mini-map to quickly zoom to your code's bottleneck. Selected functions will also appear dark blue in the mini-map.

You can hide the mini-map by using the hide mini-map toolbar button, located just to the left of the help icon.

7.5 Color coding

You can use the drop-down menu in the call graph's toolbar to choose one of the two following options for color-coding the function boxes:

7.6 Selection behavior

Left-clicking on any function in the hierarchy will select it. In addition to coloring the function's rectangle dark blue it will also darken all of that function's call arrows to black, giving you a clear picture of what the selected function is connected to.

Figure 7.6. A Selected Function

Selecting a function will also change any connected caller or callee bullets from gray to black.

7.7 Contextual menu options

Right-click on any function in the call graph to open a contextual menu, which will present you with a list of selection and navigation options so that you have easy access to that function's calling and called functions, as well as detailed statistics for that function via the table reports. Without a function selected, right-clicking in between functions in the call graph will open a contextual menu, but it will contain only two options, 'Show System Functions' and 'Show Uncalled Functions', which have the same functionality as the and menu bar buttons. This section contains a description of this and every other option contained in a call graph contextual menu.

7.7.1 Showing system and uncalled functions

You can use these contextual menu items, only available if you right-click on an area outside of the function rectangles, to show or hide the system and the uncalled functions.

RealView Profiler classifies all functions that begin with either an underscore or 'std::' as system functions, and will, by default, hide all of these functions in the call graph. You can, however, show them by choosing the 'Show System Functions' drop-down menu option. All orphaned functions that are no longer connected to the tree when the system functions are hidden are shown as unconnected boxes at the bottom of the call graph. If this option is currently active, the contextual menu option changes to 'Hide System Functions'.

The 'Show Uncalled Functions' drop-down menu option works in much the same manner as the 'Show/Hide System Functions' option. Select it and all of the functions contained in your code that were not called during the captured execution will appear as disconnected boxes in the bottom of the hierarchy.

7.7.2 The caller and callee menu options

The two menu options that appear at the top of any function's contextual menu are the caller and callee functions:

7.7.3 Contextual menu selection options

After the 'Callers' and 'Callees' options in a function's contextual menu are the options that allow you to select a group of functions relating to the selected functions:

7.7.4 Contextual menu navigation options

The call graph's function contextual menu also enables you to look at the selected functions in other report types:

7.8 The toolbar

The call graph's toolbar contains the same set of navigation options that appear in the report types and adds the 'Show System Functions' button that enables you to view how system functions fit in your hierarchy. A button will be disabled if the current selection makes their use invalid. Here is a description of each button in the call graph's toolbar:

7.9 The outline view

The outline view in the call graph works in much the same way as the outline view in the table reports. It presents every function from the source code, in an alphabetical list. Select any function from the outline view and the call graph will select that function and bring it to view so that you do not have to hunt for a particular function if you know what you are looking for.

To open the outline view, select Window > Show View > Outline from Eclipse's menu. By default, the outline view will appear to the right of the editor section, but, like all Eclipse views, you can dock it anywhere.

Copyright © 2007 ARM Limited. All rights reserved. ARM DUI 0412A