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
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.
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.
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.
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).
Table of Contents