cflow is a call graph generator tool for C and Assembler code. It reads C or Assembler source code files and prints call graphs from the contents. As such it is useful for creating hierarchical trees of function invocations and static variable usage and allows a developer to get a rough overview about the calling hierarchy within the source code files.
At its current stage, cflow supports the K&R, ANSI and ISO C conventions and most of the GNU and NASM Assembler syntax. Additionally it provides some nice features such as
Besides that it is planned to add object file and lex and yacc source code file support to cflow so it is fully compliant with the POSIX.1 sepecification. Though most parts of the specification are already implemented, these three file types still have to be implemented. cflow also ignores the locale settings for e.g. sorting at the moment, which is another requirement of the specification.
The following example creates a call graph for the cgraph application of cflow. cgraph is the C code graph creation utility of cflow. Additionally, ANSI and POSIX keywords (such as malloc, free, strdup, etc.) will be skipped.
cflow -AP cgraph/cgraph.c cgraph/clexer.c common/graph.c common/printgraph.c
The output of that command looks like the contents of the cflow_cg.txt text file. Creating a graphviz call tree for the same source code can be done using
cflow -APg cgraph/cgraph.c cgraph/clexer.c common/graph.c common/printgraph.c
0.0.6 2010-04-03: ----------------- * Fixed operator expressions for ! and |. 0.0.5 2010-01-07: ----------------- * Fixed path bug in cflow script. (thanks Till Plewe) * Removed unimplemented -f flag from cflow manpage.
cflow was primarily developed to match the requirements of the FreeBSD operating system. Due to that its main build system is based on the FreeBSD Makefile infrastructure. If you are not using FreeBSD, you should use the GNU Makefile based build system under gnu/.