CALLS(1)                                                              CALLS(1)



NAME
       calls - print out calling pattern of a C program

SYNOPSIS
       calls   [-aeirotTvVx]   [-D   name[=def]]   [-f   function]  [-F  func-
       tion[/file.c]] [-I dir] [-l depth] [-U name] [-w width] [filenames]
       calls -h
       calls -V

DESCRIPTION
       Calls analyzes the flow of a C program by laying out the  functions  in
       one  of  two  hierarchical graphs.  Calls invokes the C preprocessor on
       the named C source files, then prints the  analyzed  calling  graph  on
       standard output.  All filenames given will have their calling sequences
       combined into one graph.  A filename of - is taken  as  standard  input
       (listed in the graph as "stdin").

       Functions called but not defined within the source file are shown as:
              function

       While  functions  defined  in the source files are listed with the file
       they are declared in brackets, as shown:
              function [main.c(1009)] , or
              function [static in main.c(527)]
       or if the function is not being described
              function [see also %d] , or
              function [see below]
              function

       Recursive references are shown as:
              function <<< recursive >>>
       or, if the function is called only by itself, as:
              function <<< isolated recursion >>>

OPTIONS
       -a
              Normally only the first call to a function is recorded  for  any
              given  function, under this option all calls are recorded.  This
              may make the output for some large  programs  very  verbose  and
              these are normally not needed to show the calling structure of a
              program.

       -Dname
       -Dname=def
              Define the name for the preprocessor, as if by #define.   If  no
              definition is given, the name is defined as 1.

       -e
              Normally  an  index  listing does not contain the external func-
              tions called in the program, under this option  these  are  also
              listed.  Note this option also turns on the indexing option, -i.

       -f function
              The named function will be printed as  the  root  of  a  calling
              graph.

       -F function[/file]
              The  named  static  function  (in the given file) is used as the
              base of a calling graph, as above.  This allows closer  examina-
              tion  of  sources  such  as that of dbx(1) that have many static
              functions with the same name.

       -h
              Display only a brief help message.

       -i
              This option produces an index of all the functions  declared  in
              the  processed files.  Optionally all functions mentioned can be
              output; see -e above.

       -I dir
              Change the path for searching for #include files whose names  do
              not  begin  with  slash (/) to look in dir before looking in the
              directories on the standard list.

       -l depth
              Limit the output graph depth to depth.  This option may  prevent
              some recursion from being detected by calls.

       -o
              Do not output any defined functions that were not present in any
              of the output trees.  Note this also turns on the  index  option
              (-i  above).  For a list of all functions called by 'missle' one
              might examine the index output of
                   calls -ot -f missle *.c

       -r
              This option reverses the direction of the calling graph.   Under
              this option the output graph shows who calls the described func-
              tion, not who the function calls.

       -t
              This option instructs calls not to display graphs that were  not
              explicitly  asked for on the command line.  Using this option as
              well as the index option one can produce  just  a  list  of  the
              functions declared in a file.

       -T
              The function graph output is suitable input for tsort(1).

       -U name
              Remove any initial definition of name in the preprocessor.

       -v
              Be  more verbose in the graph.  This option inserts more English
              words in the output and repeats some useful information (such as
              the file a function came from).

       -V     Also  provide  the  variables  used  in  the output graph.  This
              option forces calls to put  ''()''  after  functions  to  disam-
              biguate them from the variables.

       -w width
              Set  the  max  indentation  width  to  width.  The default is 96
              columns.

       -x
              Do not show external functions in the output graphs.

       -z
              Sort the descendant calls in alpha (a to z) order.

EXAMPLE CODE
       Given the file prog.c
              main() {
                   abc();
                   def();
              }
              abc() {
                   ghi();
                   jkl();
              }
              static mno() { }
              ghi() {
                   abc();
                   def();
                   mno();
              }
              dead() { }

       Executing "calls prog.c" will produce:

                  1     dead [prog.c(15)]

                  2     main [prog.c(1)]
                  3          abc [prog.c(5)]
                  4               ghi [prog.c(10)]
                  5                    abc <<< recursive >>>
                  6                    def
                  7                    mno [static in prog.c(9)]
                  8               jkl
                  9          def

       Executing "calls -r prog.c" will produce:
                  1     abc [prog.c(5)]
                  2          main [prog.c(1)]
                  3          ghi [prog.c(10)]
                  4               abc <<< itself >>>

                  5     mno [static in prog.c(9)]
                  6          ghi see line 3

                  7     dead [prog.c(15)]

EXAMPLES
       calls -l 2 main.c misc.c bop.c mop.c
              Show a graph for the given files, but limit the depth to 2  lev-
              els.

       calls -rV *.c
              Show  all  the which routines use which variables in the given C
              source files.

       calls -rtf yylex parser.c
              Show which routines call yylex in parser.c.

BUGS
       Static functions must be declared (in full) before used to  work  prop-
       erly.

       Variables  include  typedef  names,  goto labels, structure members and
       struct or union tags.  This might be a feature too.

       Output width checking is only done on the  first  character  on  a  new
       line.

AUTHOR
       Originally  from  the  net.  Enhanced at Purdue University, still main-
       tained by KS Braunsdorf NPCGuild.org, calls under ksb.npcguild.org

SEE ALSO
       cpp(1), cc(1), ctags(1), tsort(1), lorder(1)



                                     LOCAL                            CALLS(1)

NAME | SYNOPSIS | DESCRIPTION | OPTIONS | EXAMPLE CODE | EXAMPLES | BUGS | AUTHOR | SEE ALSO