Obtain the call graph from C sources.

by groleo

When I have to understand how a C program word from a bird-eye view I usually tend to draw on paper the flow of the program.
I looked around to see if there are any tools to do this automatically and found cflow[1].
The downside is that it doesn’t know about dot[2] format.
I looked around and found cflow2vcg[3] that does exactly that: turns a cflow graph in a dot graph. It’s not available in Ubuntus’ repositories
so you’ll have to compile it by hand.


cflow --cpp --format=posix --omit-arguments --level-indent='0=\t' --level-indent='1=\t' --level-indent=start='\t' YOUR_FILE.C > cflow.tmp
cflow2dot < cflow.dot > cflow.dot
dot -Tjpg -G"300,900" cflow.dot -o cflow.jpg
display cflow.jpg

The -G”300,900″ option works around a ‘dot’ segfault.

Advertisements