, , , ,

I was having a look at a code piece authored by someone else. And I wondered if we could have a tool that would at least find out the code flow. I googled for such tool and found “GNU cflow”.

“cflow” is an open source tool, that can facilitate static analysis in form of code-flow of your program. cflow reports are hierarchical, hence very intuitive. If you desire a GUI form of this data, we have another open source utility called Graphviz.

I found it very useful for:

o) Reviewing a new code
o) Understanding legacy C code
o) Remember, it can’t handle function pointers 😦

A typical cflow invocation look like this:

cflow --format=posix --omit-arguments --level-indent='0=\t'
--level-indent='1=\t' --level-indent=start='\t' "source_file" > "out.cf"

Output looks as follows:

$ ./cflow ./my2.c
main() :

By default, “cflow” shows all symbols present in your program. We (Srikanth and I) didn’t like that, and hence changed the “cflow” to accommodate our request to ignore-symbols.

So, you just mention all symbols you’d like to ignore in a file “/tmp/skip_list.txt” in a format like this


The source code and binary are available here.

After collecting the profile, a browser based GUI can be generated with cflow2dot utility.