MPLAB® X IDE Call Graph

Last modified by Microchip on 2023/11/09 09:11

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 and 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, 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
Show Call Graph

Show Call Graph

Back to top

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 IDE will then open the .c file where the function was declared.

Function Declaration

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 that 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 that 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.
Expand Callee

Viewing the Parents of the Child Function (Expanding Caller)

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

Back to top

Viewing Recursive Functions in Call Graphs

Recursive functions are detected by MPLAB X IDE and they are shown in the Call Graphs as recursive functions.

Recursive Functions

 
Recursive Functions

Exporting the Call Graph

MPLAB X IDE 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. An Export Graph As window will appear, type a file name for your graph and click Save.

Back to top