Call Graph

Step-by-Step Directions

What is a Call Graph?

A Call Graph allows the user to view the relationship between Parents and Child subroutines in their program. In essence, Each node in the Call Graph represents a function (f) and each edge represents the function (g) being called by (f). A node can be thought of as the "Parent function" and each node as the "Child function".

Working with Call Graphs in MPLAB® X IDE

Call Graph functionality is supported by the IDE. To view its functionality, go to the toolbar click on Window-> Output-> Call Graph.

An empty (Call Graph) window should appear below your code.
To populate the Call Graph window, we must first highlight a function in your code, do a right-click and select "Show Call Graph". At this point you should see the Call Graph Window populated with a graphical image showing the relationship between the selected Parent function and its Children functions.

The Call Graph allows you to perform certain functionalities such as:

  • Viewing the function declaration
  • View the child of the parent function
  • View the parents of the child function
  • Exporting the Call Graph
callgraph1.png
Figure 1.1—Show Call Graph

Viewing Function Declaration

The IDE allows you to view the declaration of the selected function using Call Graphs. The Call Graph window is divided into two sections. The left hand side of the call graph window shows a Collapsing/Expanding tree menu of the Parent and Children function. The right hand side of the Call Graph window shows a graphical representation of the Parent/Children functions. To view the declaration of the function, hover over the desired function, right click on it and select "Go to Declaration" . MPLAB X will then open the .c file where the function was declared.

callgraph2.png
Figure 1.2—Function Declaration

Viewing "The children of the parent function" (Expanding Callee)

There are two ways to view what functions are being called from the selected function. These two methods are explained below:

Viewing "The children of the parent function" using the tree menu

Select a function whom you wish to know its children functions. Click on the (+) sign to expand the menu tree. A list of children functions should appear in the menu tree as well as in the Graphical representation of the call graph.

Viewing "The children of the parent function" using the graphical representation

Select a function whom you wish to know its children functions. Right click on the function and select "Expand Callee". A list of children functions should appear in the menu tree as well as in the Graphical representation of the call graph.

callgraph3.png
Figure 1.3—Expand Callee

Viewing "The Parents of the child function" (Expanding Caller)

In the graphical representation of the Call Graph, select a function whom you wish to know its parent function. Right click on the function and select "Expand Callers". A graphical representation of all the parents functions calling the selected function should appear in the Call Graph window.

callgraph4.png
Figure 1.4—Expand Caller

Exporting the Call Graph

MPLAB X allows you to export the Call Graph in a .png file. To export the Call Graph, right click anywhere in the Call Graph window and select "Export". A "Export Graph As" window will appear, type a file name for your graph and click Save.

Viewing Recursive Functions in Call Graphs

Recursive functions are detected by MPLAB X and they are shown in the Call Graphs as recursive functions (See Figure 1.5 & 1.6).

callgraph5.png
Figure 1.5—Recursive Functions
callgraph6.png
Figure 1.6—Recursive Functions
© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.