GNU cflow: A tool to analyze C code flow

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" > ""

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.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: