Analysing source code

Samba is a very large and complex open source project. To make some contribution a new programmer have to learn not so clean internal project structure and read a lot of source code lines. Undoubtedly, source code analysing programs can reduce programmer's "warm-up" time greatly.

Codeviz

Codeviz is a call graph generation utility for C/C++ written by Mel Gorman (the author of well known Understanding the Linux Virtual Memory Manager book). You can find the project home page here - [1]. Applyed to Samba code the ulility can produce very nice call diagrams, like this:

Get share mode lock 2 fwd.png

or reverse call diagrams:

Tdb open.png

Graph generation consists of two steps: building full programm call graph from a source code and fetching subgraphs with interesting functions. Graphviz project is used for building images (png, postscript, etc) for the graphs.

Building full graph

To produce full internall call graph you have to use patched version of gcc compiler. It is made automatically by Codeviz makefiles and can be used by setting up CC=/path/to/patched/gcc enviroment variable. While building Samba compiler will create .cdepn file for every source file. After that special utility genfull builds full program call graph (full.graph by default).

If you have no time to build patched gcc and compile the project, you can download full graph for Samba3-branch (revision number 15129) here - [2] (1 Mb, gzipped file).

Generating call graphs

The second tool gengraph is used for generating call diagrams from the full.graph file.