Next: , Previous: Direct and Reverse, Up: Top


4 Various Output Formats.

The output format described in previous chapters is called GNU Output. Beside this, cflow is also able to produce output format defined in POSIX standard (The Open Group Base Specifications Issue 6: cflow utility). In this format, each line of output begins with a reference number, i.e. the ordinal number of this line in the output, followed by indentation of fixed amount of columns per level (see setting indentation). Following this are the name of the function, a colon and the function definition, if available. The function definition is followed by the location of the definition (file name and line number). Both definition and location are enclosed in angle brackets. If the function definition is not found, the line ends with an empty pair of angle brackets.

This output format is used when either a command line option --format=posix (-f posix) has been given, or environment variable POSIXLY_CORRECT was set.

The output graph in POSIX format for our sample whoami.c file will look as follows:

     $ cflow --format=posix whoami.c
         1 main: int (int argc,char **argv), <whoami.c 26>
         2     fprintf: <>
         3     who_am_i: int (void), <whoami.c 8>
         4         getpwuid: <>
         5         geteuid: <>
         6         getenv: <>
         7         fprintf: <>
         8         printf: <>

It is not clear from the POSIX specification whether the output should contain argument lists in function declarations, or not. By default cflow will print them. However, some programs, analyzing cflow output expect them to be absent. If you use such a program, add --omit-arguments option to cflow command line (see omit signature parts).

Future versions of cflow will offer more output formats, including XML and HTML outputs. Currently, you can use VCG tool (http://rw4.cs.uni-sb.de/users/sander/html/gsvcg1.html) to create graphical representation of the produced graphs. To transform cflow output to xvcg input syntax, use cflow2vcg program (http://cflow2vcg.sourceforge.net/). Both programs are available under GPL.

Cflow2vcg expects POSIX call graphs, indented with exactly one horizontal tabulation character per nesting level, with an additional tab character for zeroth level and without argument lists in function declaration. So, to produce an output suitable for cflow2vcg, invoke cflow as follows1:

     cflow --format=posix --omit-arguments \
           --level-indent='0=\t' --level-indent='1=\t' \
           --level-indent=start='\t'

You can use the following script to visualize call graphs using the three tools:

     #! /bin/sh
     
     cflow --format=posix --omit-arguments \
           --level-indent='0=\t' --level-indent='1=\t' \
           --level-indent=start='\t' $* |
       cflow2vcg | xvcg -

Footnotes

[1] (See level-indent, for the detailed description of --level-indent option