---
name: "prcg"
section: "1"
platform: "linux"
package: "cflow"
version: "2.0-17.1"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/cflow"
---

# prcg(1)

print a function call hierarchy

Part of [cflow(1)](/cflow/1.md).

## NAME

cflow - print a function call hierarchy

## SYNOPSIS

cflow \[-Aagivx\] \[-d n\] \[-w n\] \[-r name\] \[cpp-opts\] files

## DESCRIPTION

The **cflow** command reads *files* as program source and attempts to print a graph of the program's function call hierarchy to the standard output. Called functions are indented with respect to their calling functions, and printed only once, in the order they occur.

The first reference to function *func* is printed with the name of the file and line number where it is defined, e.g.,

func {file.c n}.

Subsequent references are printed as:

func ... {mm},

where mm is the line number in  the graph of *func*'s first reference. Global variable references appear (if invoked with the  *-v* option) as:

var {v file.c n}.

External functions and variables are printed with a null source, i.e.,

func {}.

An ellipsis precedes the name of a function called recursively, e.g.,

 ... func ... {mm}

### OPTIONS

- \-a

  Print a separate call graph for each function.

- \-A

  Eliminate ansi keywords

- \-P

  Eliminate POSIX keywords

- \-d *nn*

  Print the call graph to at most depth *nn*.

- \-g

  Add to the list of C keywords GNU CC keywords.

- \-i

  Print an inverted graph of depth 2, i.e.,  for each function (or variable if used with the *-v* option), print a list of functions which call it.

- \-r *name*

  Print a call graph with function or variable *name* as root (in the case of a variable, this only makes sense if used with the *-i* option).  This option may be repeated.

- \-v

  Print references to global variables.  Only functions calls are printed by default.

- \-x

  Print each sub-graph in full.  This overrides the default format where subsequent references are abbreviated as described above.

- \-D*macro* or -U*macro* or -I*dir*

  Invoke cpp with the corresponding options.  If there is a makefile, then the command *make -n* should indicate the proper flags to invoke *cflow* with.

- \-X

  eliminate header files (empty files are made to a temporary location). This often makes better results occur. Files to look at eliminating are:

  ```
  stdio.h
  errno.h
  ctypes.h
  stdlib.h
  ```

- \-V

  Echo commands as they are being executed.

## AUTHORS

The graph printing command *prcg* is essentially the one in M. M. Taylor's *calls*(1) as posted to the Usenet newsgroup comp.sources.unix. A new parser, *prcc*, is based on Steven Kirkendall's [*ctags*(1)](/ctags/1.md) command which is distributed with the vi-clone [*elvis*(1)](/elvis/1.md).\
 Marty Leisner (leisner@sdsp.mc.xerox.com) got this working on SunOS and Linux, and added a plethora of options to cflow; rewriting cflow to use bash.

## ENVIRONMENT

Uses *$CPP*, which is normally $CC -E. If $CC is not define, use gcc.\
 *PRCG* is defaulted to be the prcg program.\
 *PRCC* is defaulted to be the prcc program.

## HINTS

Sometimes redefine CPP as cat will produce output if you see known.

## BUGS

An extern variable declaration is overridden by an actual (global) variable declaration.  A complaint is written to stderr whether there is a conflict or not.

Function parameters are ignored.  If these parameters share the names of global variables, then references to them are  flagged as external references.

The *static* qualifier is ignored.  Only the first definition of a function or variable is recognized.

It appears a definition like `main() { foo();` causes problems.
