Creating call graphs for C and FORTRAN programs
Creating a call graph for C or FORTRAN program is pretty simple using GCC.
For both FORTRAN and C programs, the trick is to compile the program using the compiler flag -fdump-rtl-expand (see documentation).
Once the program is compiled, a file with a name like solergya.f.144f.expand will be created.
tar zxvf egypt-1.10.tar.gz cd egypt-1.10 perl Makefile.PL make sudo make install
env = Environment() env.Append(FORTRANFLAGS=["-fdump-rtl-expand"]) env.Program("solergy","solergya.f")
Then, use egypt to convert the RTL file into a nice GraphViz diagram:
egypt solergya.f.144r.expand | dot -Tpng > callgraph.png
The result is a nice callgraph like so:
You can use exactly the same approach for C programs. In the sample SConstruct file, just change FORTRANFLAGS to CFLAGS and change the name of the source code file accordingly.