Call Graph Drawing Interface Page

( A gprof - VCG interface ) 

What is it ?

#include <stdlib.h>
class A {
public:
  void a();
  void b();
  void c();
};

void A::a(){b();}
void A::b(){}
void A::c(){}

int main()
  {A t;
   t.a();
   t.c();
   exit(0);}
A C or C++ program 
The tool creates a graph with function names and call arcs. You can show it, save, modify and print out. 

See also a larger (52K) example. 

Why you need it

For any program consisting of more than 10-15 functions it becomes difficult to keep track of calling relations between them. Programmers draw a call graph when they design their code, and they do this with paper and pen. But such call graph helps you a lot when you modify, test, document, explain and maintain your code or read other's code. This call graph can easily be generated automatically.

Call graph drawing utilities can be found in various commercial CASE tools and programming environments. But if you work without any CASE tools, and use just traditional compilers, you can find a simple and cheap solution here. 

What it does ?

First you compile (with a special flag) and execute your C or C++ program. The profile information generated by the executed program and processed by gprof is filtered and passed to graph drawing tool VCG . You have the option to show either all function calls in your program or all calls executed at least once . You can also control the filter in order to skip various library functions. 

You need gprof !

Yes, you need the gprof tool.

This tool produces call graph profile of your program. First you compile and execute the program, and then a detailed text file is produced.

There are two ways you can get it:

BE AWARE that the above mentioned gprofs are different, they work with different input and output format and don't mix them !

Let me know if there are other gprof implementations available. 


You need VCG !

The VCG tool reads a textual and readable specification of a graph and visualizes the graph using advanced layout algorithms. The software is free and you can find and download it from Visualization of Compiler Graphs Page.

Call Graph Drawing Interface

If you already have gprof and VCG then you just need to download two additional small filter programs written in C++. Unzip and utar the archive and run make in order to compile and test them.

It is FREE, but, please, do not forget to fill in the FEEDBACK FORM.


How To Work With It ?

First you obtain the call graph textual profile of your program. It appears as standard output of gprof .

Using SUN Microsystems gprof

You compile your The -g is necessary in order to prevent inlining of some simple functions that may happen automatically.

Sometimes additional library should be added by flag -ldl.

When your program runs it always produces the file gmon.out.

You start gprof -C program-name gmon.out if you want to display all calls that were executed at least once.

You start gprof -C -c -z program-name gmon.out if you want to display all the calls in the code. Due to bugs I haven't checked it yet. 


Using GNU gprof

You compile your When your program runs it always produces the file gmon.out.

You start gprof program-name gmon.out if you want to display all calls that were executed at least once.

You start gprof -c -z program-name gmon.out if you want to display all the calls in the code. Due to bugs I haven't checked it yet. 


Work with call graph textual profile.



Info for HP-UX users:


The programs didn't quite work for HP-UX, so I made some changes
and managed to get a working version. I thought you might be
interested, so here are the changes:

vco.cc,line 135
 while(exc)       ->   while(!exc.eof())

g2v.cc, line 59
 add '|| s[0]==12'

In addition, compilation should be done with '-G -g', instead of the
'-pg -g' for Sun and Gnu.

I hope this information is of interest to you.

Richard Schaaf - Richard.Schaaf@vrijuit.nl

Info for cflow users

This directory contains scripts useful for cflow users. Please contact Bodo Meissner for support.

Help with testing and porting

It would be great if someone can support this tool since it need to be tested and ported for various versions of GPROFS, various variations of UNIX-es and LINUX-es.

I have no time to support it anymore. The tool is under GPL - Gnu Public License now.

If interested please mail to .


Feedback and more...

This interface and WWW page is designed by Vadim Engelson .

Send me questions, bug reports etc by e-mail .

Page created: 16 Aug 1996
Last change: 26 May 2003