cflow

cflow is a call graph generator tool for C and Assembler code. It reads C or Assembler source code files prints call graphs from its 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.

Status

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

  • keyword filters for ANSI, C99, POSIX and GCC in C source code files
  • dot graph creation for graphviz output
  • C preprocessor support
  • reversed calling hierarchies
  • graph creation for multiple files at once

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.

Example

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

Output: cflow_gv.dot, graphics: cflow_gv.png

Version History

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.

Notes

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/.

Download

cflow is distributed under a 2-clause BSD license and as such suitable for nearly any task and project. You can download it from the projects directory.

For the most recent development version, you also can use the Bazaar repository using

bzr branch http://sysfault.org/projects/cflow
projects/cflow.txt · Last modified: 2010/04/03 12:12 by marcusva
Driven by DokuWiki Blog RSS feed