Next: TUTTI Run time library
Up: TUTTI Reference
Previous: C Library Wrapper
  Contents
  Index
Subsections
depend
This chapters describes how a dependency analysis is made by using the depend compiler and scanner. A dependency analysis is useful to investigate the relation between a software unit and its software environment.
depend_compiler
The depend_compiler script can analyze the dependencies between modules. It as
the same interface as the gnu compiler collection (gcc). The compiler
wrapper will compile the source code using the parameters specified
at command line. It will also invoke nm and ldd to analyze relations
between the various compilation units (modules). This results in an
ASCII file with extension .depend. This ASCII file describes for each
module, which identifiers are defined and which are referred too as an
external identifier.
The results of the dependency analysis are recorded in the .depend files. These files can be analyzed using the depend_scan script. See depend_scan(1).
depend_scan
depend_scan is a script which reads the .depend files resulting from an analysis with depend_compiler. It will generate a graph with the dependency analysis in dot format (send to stdout)dotFile format of the dot tool used to draw graphs. The tool dot comes with graphviz, which is a public domain graph drawing tool . The file can be converted by dot into another graphical format such as postscript or gif:
dot -Tps graph.dot > graph.ps
This will convert the dot-format file into postscript format.
In this example, the use of depend_compiler and depend_scan is demonstrated.
The file test.c contains a call to printf and sin.
$ cat test.c
#include <stdio.h>
#include <math.h>
int main ( void )
{
printf("sine(2) : %f\n", sin(2));
return 0;
}
Compiling this file with depend_compiler results in three .depend files:
$ depend_compiler test.c -lm
$ ls *.depend
libc.so.depend libm.so.depend test.c.depend
$ cat test.c.depend
......
test.c provides __start
test.c provides _etext
test.c provides _ftext
test.c provides _mcount
test.c provides etext
test.c needs exit
test.c provides main
test.c needs printf
test.c needs sin
Using depend_scan and dot converts these dependency file into dot
and postscript file respectively:
$ depend_scan -all | dot -Tps > graph.ps
The graphical output from these commands is depicted by 14.1.
Figure 14.1:
Relations between the test.c, the c library and the math library resulting from dependency analysis with depend_compiler and depend_scan.
|
Next: TUTTI Run time library
Up: TUTTI Reference
Previous: C Library Wrapper
  Contents
  Index
2004-05-28