DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

cflow(CP)


cflow -- generate C flowgraph

Syntax

cflow [-r] [-ix] [-i_] [-dnum] files

Description

The cflow(CP) command analyzes a collection of C, yacc(CP), lex(CP), assembler, and object files and builds a graph charting the external function references. Files suffixed with .y, .l, and .c are processed by yacc, lex, and the C compiler as appropriate. The results of the preprocessed files, and files suffixed with .i, are then run through the first pass of lint. Files suffixed with .s are assembled. Assembled files, and files suffixed with .o, have information extracted from their symbol tables. The results are collected and turned into a graph of external references that is written on the standard output. cflow processes supplementary code set characters in literals and constants according to the locale specified in the LC_CTYPE environment variable (see LANG in environ(M)).

Each line of output begins with a reference number, followed by a suitable number of tabs indicating the level, then the name of the global symbol followed by a colon and its definition. Normally only function names that do not begin with an underscore are listed (see the -i options below). For information extracted from C source, the definition consists of a function's return type (for example, char *), followed by the name of the source file and the line number where the definition was found, delimited by angle brackets.

Definitions extracted from object files indicate the filename and location counter under which the symbol appeared (for example, text). If the compilation system adds a leading underscore to external names, it is removed.

Once a definition of a name has been printed, subsequent references to that name contain only the reference number of the line where the definition may be found. For undefined references, only <> is printed.

In addition to the -D, -I, and -U options (which are interpreted just as they are by cc(CP), the following options are interpreted by cflow:


-r
Reverse the ``caller:callee'' relationship producing an inverted listing showing the callers of each function. The listing is also sorted in lexicographical order by callee.

-ix
Include external and static data symbols. The default is to include only functions in the flowgraph.

-i_
Include names that begin with an underscore. The default is to exclude these functions (and data if -ix is used).

-dnum
The num decimal integer indicates the depth at which the flowgraph is cut off. By default this number is very large. Attempts to set the cutoff depth to a non-positive integer will be ignored.

Exit values

Upon successful completion, the exit status of cflow is 0, otherwise the exit status is non-zero.

Diagnostics

cflow complains about multiple definitions and only accepts the first one. Other messages may come from the various programs used (for example, the C preprocessor).

Warning

Do not feed cflow with the output files produced by lex(CP) and yacc(CP). Input the lex and yacc source files directly to cflow. Otherwise, you may get incorrect results because yacc or lex may reorder the line number declarations in their output files.

Examples

As an example, suppose the following code is in file.c:

   int	i;
   

main() { f(); g(); f(); }

f() { i = h(); }

The command

cflow -ix file.c

produces the output

   1	main: int(), <file.c 4>
   2		f: int(), <file.c 11>
   3			h: <>
   4			i: int, <file.c 1>
   5		g: <>

When the nesting level becomes too deep, the output of cflow can be piped to the pr(C) command, using the -e option of pr, to compress the tab expansion to something less than eight spaces.

Files


/bin/cflow

See also

as(CP), cc(CP), cpp(CP), environ(M), lex(CP), lint(CP), nm(CP), pr(C), yacc(CP)

Standards conformance

cflow(CP) is conformant with:

X/Open Portability Guide, Issue 3, 1989 .


© 2005 Commands for Programming (CP)
SCO OpenServer Release 6.0.0 -- 02 June 2005