Menu

Home

Fabio Visonà

tceetree could be useful for you when:

  • you have the sources of an application written in C language;
  • you would like to have a graphical representation of the entire or partial function call tree.

If this is what you are looking for, follow these steps:

  1. Install (and compile) CScope. A compiled Windows executable can be found here. For a compiled Linux executable search the Web e.g. for a cscope RPM or Debian package.
  2. Install Graphviz.
  3. Go to your sources root directory and do:
    • under Windows: dir /B /S *.c > cscope.files (/B = bare format, no extra info);
    • under Linux: find . -name '*.c' > cscope.files;
      that will recurse subdirectories and list all C files in cscope.files.
  4. execute cscope -b -c -R (build the cross reference only, don't compress it, recurse);
  5. run tceetree with cscope.out as input (default) to get tceetree.out (DOT language representation of function call tree);
  6. execute dot -Tpng -O tceetree.out to get a graphical representation of the tree in tceetree.out.png.

There are a lot of options you can specify when invoking dot to customize the graph, for example:

  • you can change output format e.g. to pdf: dot -Tpdf -O tceetree.out;

  • you may modify layout from left to right instead of top to bottom: dot -Grankdir=LR -Tpng -O tceetree.out;

  • you may modify graph, nodes and edges font: dot -Gfontname=Helvetica -Nfontname=Helvetica -Efontname=Helvetica -Tpng -O tceetree.out;

  • see dot.1.pdf and dotguide.pdf within Graphviz documentation for many other options.

You may wish to give a try to one of the other tools provided by Graphviz instead of dot (see dot.1.pdf for a list).

This is the synopsis of tceetree:

tceetree [-c <depth>] [-C <depth>] [-d <file>] [-f] [-F] [-h] [-i <file>] [-o <file>] [-p <function>] [-r <root>] [-s <style>] [-v] [-V] [-x <function>]</strong></p> <table> <thead> <tr> <th>Option</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><strong>-c <depth></strong></td> <td>Depth of tree for called functions: default is max. <em>Depth is measured starting from root(s) function(s).</em></td> </tr> <tr> <td><strong>-C <depth></strong></td> <td>Depth of tree for calling functions: default is 0. <em>Depth is measured starting from root(s) function(s) in backward direction.</em></td> </tr> <tr> <td><strong>-d <file></strong></td> <td>Output a shortened cscope output file: default is no output. The shortened file includes only function information and can be used as input (-i) for following calls to tceetree to increase speed on big projects.</td> </tr> <tr> <td><strong>-f</strong></td> <td>Print the file name where the call is near to branch.</td> </tr> <tr> <td><strong>-F</strong></td> <td>Group functions into one cluster for each source file.</td> </tr> <tr> <td><strong>-h</strong></td> <td>Print help.</td> </tr> <tr> <td><strong>-i <file></strong></td> <td>Input cscope output file: default is cscope.out.</td> </tr> <tr> <td><strong>-o <file></strong></td> <td>Output file for graphviz: default is tceetree.out.</td> </tr> <tr> <td><strong>-p <function></strong></td> <td>Highlight call path till function. <em>Path starts from root(s) till the specified function (only one), in backward or forward direction.</em></td> </tr> <tr> <td><strong>-r <root></strong></td> <td>Root function of tree: default is main. This option may occur more than once for multiple roots (max 5).</td> </tr> <tr> <td><strong>-s <style></strong></td> <td>Style for highlight call path: 0 = red color (default); 1 = blue color; 2 = green color; 3 = bold; 4 = dashed; 5 = dotted.</td> </tr> <tr> <td><strong>-v</strong></td> <td>Print version.</td> </tr> <tr> <td><strong>-V</strong></td> <td>Verbose output (<em>mainly for debugging purposes</em>).</td> </tr> <tr> <td><strong>-x <function></strong></td> <td>Function to be excluded from tree. This option may occur more than once for multiple functions (max 20). -x LIBRARY is a special case for excluding all library functions, i.e. not found defined in any file. <em>All the functions, called (calling) directly or indirectly from the excluded one(s) only, will be excluded too.</em></td> </tr> </tbody> </table> <p>tceetree can be called with no option at all: default options will be used.</p> <p><strong>Examples:</strong></p> <ul> <li>Screenshot #1 was done with <em>tceetree -F -x LIBRARY</em>;</li> <li>screenshot #2 was done with <em>tceetree -C max -r gettree -p ttreefindnode</em>.</li> </ul></style></root></function></file></file></file></depth></depth>