In this post, we will see how to use gcc, egypt & graphviz to generate call graphs of any C-based source code / multiple source codes. This technique will be helpful if you are working on legacy code and want to have a view of the code architecture at first.
Among the three tools mentioned above, GCC is generally pre-installed in Linux. So You need to install the other two.
Follow the following :
1. Download Egypt from here egypt download and then unzip it
go to the egypt directory then install it by these commands
2. then install graphViz by
Alright then tools are installed So now let's go to the basics
In order to generate call graph, you basically need the following steps
1. compile and generate object files using gcc
2. generate RTL from the object files using gcc
3. generate the call graphs using egypt & graphviz
RTL means Register transfer Language. It is used to describe the data flow at the register transfer level. It is actually a kind of intermediate representation that is very close to assembly language.
First of all compile and run a simple C program with an additional file
$mkdir test
$cd test
$notepadqq hello.h
$notepadqq hello.c
$notepadqq main.c
main.c
hello.h
hello.c
Now let’s compile using GCC
Now generate the RTL expands and run egypt command on the output to get a callgrqaph picture
now open the svg file and you will see the pictorial call graph of the hello application that you made
0 comments:
Post a Comment