home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Borland Programmer's Resource
/
Borland_Programmers_Resource_CD_1995.iso
/
utils
/
cxtw104
/
example.doc
< prev
next >
Wrap
Text File
|
1995-05-18
|
24KB
|
794 lines
EXAMPLE.DOC
This file describes the use of CFT and CST, the main parts of
CXT, the C EXPLORATION TOOLS. The example session shows the
processing of a small program composed of two source files X1.C
and X2.C and one include file X.H as listed below. When invoked,
the program produces the following output:
hello world ....................
The source code of the files is as follows:
SOURCE LISTING 1: X1.C
#include <stdio.h>
#include "x.h"
WORD main(void);
VOID x1(void);
WORD main(void)
{
x1();
y1();
return(0);
}
static VOID x2(void)
{
printf("hello ");
}
VOID x1(VOID)
{
x2();
}
END OF SOURCE LISTING 1
SOURCE LISTING 2: X2.C
#include <stdio.h>
#include "x.h"
VOID y1(VOID);
static int x1(void);
static void x3(void);
VOID y1(VOID)
{
x1();
}
static char x2(VOID)
{
printf("world ");
x3();
return(1);
}
- 1 -
static int x1(void)
{
x2();
return(1);
}
static void x3(void)
{
static i = 0;
printf(".");
if (++i < 20)
x3();
}
END OF SOURCE LISTING 2
SOURCE LISTING 3: X.H
typedef void VOID;
typedef char BYTE;
typedef int WORD;
typedef long DWORD;
typedef struct _s_x
{
BYTE a;
WORD b;
BYTE string[20];
FILE *fptr;
} S_XT;
extern VOID y1(VOID);
END OF SOURCE LISTING 3
First of all, the two source files X1.C and X2.C are processed by
CFT to look for the functions and their hierarchy with the
following command line (see documentation for description):
CFT -m -rauspMP -TMSC70,L -cs -Cs -na -Zs -z x?.c
The resulting screen output during processing is shown below.
Besides the default informations about the file actually
processed there are also some warnings given. (NOTE: Some of the
following output lines are truncated due to their length.)
SCREEN OUTPUT
CFT (TM) C FUNCTION TREE GENERATOR 2.12 Copyright (C) J.M 1988-
processing C:/C/CXT/DOC/X1.C
C:/C/CXT/DOC/X1.C(15): warning: function 'x2' definition used as
prototype
processing C:/C/CXT/DOC/X2.C
C:/C/CXT/DOC/X2.C(14): warning: function 'x2' definition used as
prototype
- 2 -
writing output file CFT.LST
END OF SCREEN OUTPUT
The finally generated output file CFT.LST has the following
listed contents. For further informations about the meaning of
the several sections listed in the output file see the CFT and
CST documentation.
CFT OUTPUT: CFT.LST
╔═══════════════════════════════════════════════════════════════
║ CFT (TM) C FUNCTION TREE GENERATOR 2.12 Copyright (C) J.M
╚═══════════════════════════════════════════════════════════════
╔═══════════════════════════════════════════════════════════════
║ CFT is part of CXT - the C EXPLORATION TOOLS
║ You are expressly prohibited from selling this software
║ of it in any form, distributing it with another product
║ removing this notice. This software is Copyright (C)
║ File creation date: Sat Nov 21 13:08:22 1992
╚═══════════════════════════════════════════════════════════════
╔═══════════════════════════════════════════════════════════════
║ EXAMPLE: int test() (9999) <DMPCA> <TEST.C, 100>
║ - int : function return type
║ - test() : function name
║ - (9999) : function cross reference number
║ - <DMPCA> : function found as D=definition, M=macro, P=P
║ C=function call, A=assembler function
║ - <TEST.C, 100>: file name, line number
╚═══════════════════════════════════════════════════════════════
╔═══════════════════════════════════════════════════════════════
║ FUNCTION CALLTREE HIERARCHY LISTING
╚═══════════════════════════════════════════════════════════════
WORD main() (1) <DP> <X1.C, 8>
├ VOID x1() (2) <DPC> <X1.C, 20>
│ └ static VOID x2() (3) <DC> <X1.C, 15>
│ └ int printf() (4) <PC> <?>
│
└ VOID y1() (5) <DPC> <X2.C, 9>
└ static int x1() (6) <DPC> <X2.C, 21>
└ static char x2() (7) <DC> <X2.C, 14>
├ int printf()
└ static void x3() (8) <DPC> <X2.C, 27>
├ int printf()
└ static void x3() ...recursive call of (8)
WORD main() ...relations shown at (1)
int printf() ...relations shown at (4)
- 3 -
VOID x1() ...relations shown at (2)
static int x1() ...relations shown at (6)
static VOID x2() ...relations shown at (3)
static char x2() ...relations shown at (7)
static void x3() ...relations shown at (8)
VOID y1() ...relations shown at (5)
╔═══════════════════════════════════════════════════════════════
║ TOTAL NUMBER OF FUNCTIONS REFERENCED : 8
║ NUMBER OF FUNCTION DEFINITIONS : 7
║ NUMBER OF UNDEFINED FUNCTIONS : 1
║ DIRECTED CALL GRAPH WITH 8 NODES AND 10 CONNECTI
╚═══════════════════════════════════════════════════════════════
╔═══════════════════════════════════════════════════════════════
║ UNDEFINED FUNCTIONS
╚═══════════════════════════════════════════════════════════════
int printf() (4) <PC> ...first found in <STDIO.H, 256>
╔═══════════════════════════════════════════════════════════════
║ FUNCTION CALL STATISTICS
╚═══════════════════════════════════════════════════════════════
VOID x1() (2) <DPC> <1 calls>
static int x1() (6) <DPC> <1 calls>
static VOID x2() (3) <DC> <1 calls>
static char x2() (7) <DC> <1 calls>
VOID y1() (5) <DPC> <1 calls>
static void x3() (8) <DPC> <2 calls>
int printf() (4) <PC> <3 calls>
╔═══════════════════════════════════════════════════════════════
║ FUNCTION CALLER-MEMBER LIST
╚═══════════════════════════════════════════════════════════════
<no callers>
main() (1) <0, 2>
x1() (2) <1>
y1() (5) <1>
- 4 -
main() (1) <1>
x1() (2) <1, 1>
x2() (3) <1>
y1() (5) <1>
x1() (6) <1, 1>
x2() (7) <1>
x1() (2) <1>
x2() (3) <1, 1>
printf() (4) <1>
x1() (6) <1>
x2() (7) <1, 2>
printf() (4) <1>
x3() (8) <1>
main() (1) <1>
y1() (5) <1, 1>
x1() (6) <1>
x2() (7) <1>
x3() (8) <1, recursion>
x3() (8) <2, 2>
printf() (4) <1>
x3() (8) <1, recursion>
x2() (7) <1>
x2() (3) <1>
x3() (8) <1>
printf() (4) <3, 0>
<no members>
╔═══════════════════════════════════════════════════════════════
║ FUNCTION CALL REFERENCE LIST
╚═══════════════════════════════════════════════════════════════
main() (1) [3]: 8
printf() (4) [1]: 256
[3]: 16
[4]: 15 30
x1() (2) [3]: 20
[3]: 9
x1() (6) [4]: 21
[4]: 10
x2() (3) [3]: 15
[3]: 21
x2() (7) [4]: 14
[4]: 22
- 5 -
x3() (8) [4]: 27
[4]: 16 33
y1() (5) [4]: 9
[3]: 10
FILE INDEX LIST
1 G:/C700/INCLUDE/STDIO.H
2 C:/C/CXT/DOC/X.H
3 C:/C/CXT/DOC/X1.C
4 C:/C/CXT/DOC/X2.C
╔═══════════════════════════════════════════════════════════════
║ CRITICAL FUNCTION CALL PATH (NL...nestinglevel)
╚═══════════════════════════════════════════════════════════════
main() (1) (NL 0)
└ y1() (5) (NL 1)
└ x1() (6) (NL 2)
└ x2() (7) (NL 3)
└ x3() (8) (NL 4)
├ printf() (4) (NL 5)
└ x3() ...recursive call of (8)
x2() (3) (NL 0)
└ printf() (NL 1)
x1() (2) (NL 0)
└ x2() ...relations shown at (3) (NL 1)
╔═══════════════════════════════════════════════════════════════
║ SOURCE FILE - INCLUDE FILE DEPENDENCY
╚═══════════════════════════════════════════════════════════════
C:/C/CXT/DOC/X1.C :
G:/C700/INCLUDE/STDIO.H
C:/C/CXT/DOC/X.H
C:/C/CXT/DOC/X2.C :
G:/C700/INCLUDE/STDIO.H
C:/C/CXT/DOC/X.H
╔═══════════════════════════════════════════════════════════════
║ FUNCTION TABLE: C:/C/CXT/DOC/X1.C
╚═══════════════════════════════════════════════════════════════
LINE FUNCTION [SRC BYTES,CMNT BYTES,LINES,BYTES/LINE,FUNCS
CALLED,CTRL STMTS,BRACE LVLS]
8 : WORD main() (1) [29,0,4,7.25,2,0,1]
15 : static VOID x2() (3) [22,0,2,11.00,1,0,1]
20 : VOID x1() (2) [10,0,2,5.00,1,0,1]
- 6 -
[3 FUNCTIONS, AVERAGE VALUES: 20.33, 0.00, 2.67, 7.63, 1.33,
0.00, 1.00]
NOTE: NONE OF THESE FUNCTIONS WILL BE CALLED OUTSIDE THIS FILE!
╔═══════════════════════════════════════════════════════════════
║ FUNCTION TABLE: C:/C/CXT/DOC/X2.C
╚═══════════════════════════════════════════════════════════════
LINE FUNCTION [SRC BYTES,CMNT BYTES,LINES,BYTES/LINE,FUNCS
CALLED,CTRL STMTS,BRACE LVLS]
9 : VOID y1() (5) [10,0,2,5.00,1,0,1]
14 : static char x2() (7) [41,0,4,10.25,2,0,1]
21 : static int x1() (6) [22,0,3,7.33,1,0,1]
27 : static void x3() (8) [58,0,7,8.29,2,1,1]
[4 FUNCTIONS, AVERAGE VALUES: 32.75, 0.00, 4.00, 8.19, 1.50,
0.25, 1.00]
╔═══════════════════════════════════════════════════════════════
║ FILES REFERENCED : 2
║ FUNCTIONS REFERENCED : 7
║ AVERAGE # OF FUNCTIONS/FILE : 3.50
║ AVERAGE # OF BYTES/FUNCTION : 27.43
║ AVERAGE # OF COMMENT BYTES/FUNCTION : 0.00
║ AVERAGE # OF LINES/FUNCTION : 3.43
║ AVERAGE # OF BYTES/LINE : 8.00
║ AVERAGE # OF CONTROL STATEMENTS/FUNCTION : 0.14
║ AVERAGE # OF BRACE LEVELS/FUNCTION : 1.00
╚═══════════════════════════════════════════════════════════════
╔═══════════════════════════════════════════════════════════════
║ FILE INFORMATION
╚═══════════════════════════════════════════════════════════════
FILE SIZE/ SCANNED LINES/SCANNED
STDIO.H : 7467/ 0 bytes, 340/ 0 lines, 0
functions (* included *) <G:/C700/INCLUDE/> (7467, 1.000)
X.H : 217/ 0 bytes, 16/ 0 lines, 0
functions (* included *) <C:/C/CXT/DOC/> (217, 1.000)
X1.C : 212/ 7896 bytes, 23/ 379 lines, 3
functions (* 2 files included *) <C:/C/CXT/DOC/> (212, 1.000)
X2.C : 352/ 8036 bytes, 35/ 391 lines, 4
functions (* 2 files included *) <C:/C/CXT/DOC/> (352, 1.000)
TOTAL : 8248/ 15932 bytes, 414/ 770 lines, 7
functions in 2 of 4 files
2 (* included *) files
program code: 8248 bytes, program comment: 0 bytes
average program code/filesize ratio 1.000
see exact file values above: ... (code bytes, code/filesize
ratio)
END OF CFT OUTPUT: CFT.LST
- 7 -
Second, the two source files are processed by CST to get the data
types and their relations with the following command line:
CST -rapP -TMSC70,L -cs -Cs -na -Zs -z x?.c
The resulting screen output during processing is as follows:
SCREEN OUTPUT
CST (TM) C STRUCTURE TREE GENERATOR 2.12 Copyright (C) J.M 1988
processing C:/C/X1.C
processing C:/C/X2.C
writing output file CST.LST
END OF SCREEN OUTPUT
The contents of the output file CST.LST is listed below:
CST OUTPUT: CST.LST
╔═══════════════════════════════════════════════════════════════
║ CST (TM) C STRUCTURE TREE GENERATOR 2.12 Copyright (C) J.M
╚═══════════════════════════════════════════════════════════════
╔═══════════════════════════════════════════════════════════════
║ CST is part of CXT - the C EXPLORATION TOOLS
║ You are expressly prohibited from selling this software
║ of it in any form, distributing it with another product
║ removing this notice. This software is Copyright (C)
║ File creation date: Sat Nov 21 13:08:25 1992
╚═══════════════════════════════════════════════════════════════
╔═══════════════════════════════════════════════════════════════
║ EXAMPLE: struct _test (9999) <BSUCE> [<TEST.C, 90>] <TEST.C,
║ - struct _test: type specifier
║ - (9999) : data type cross reference number
║ - <BSUCE> : data type: B=basic type, S=struct, U=union, C
║ - <TEST.C, 90>: file name, line number of type definition
║ - <TEST.C, 60>: file name, line number of basic type definiti
╚═══════════════════════════════════════════════════════════════
╔═══════════════════════════════════════════════════════════════
║ DATA STRUCTURE CALLTREE HIERARCHY LISTING
╚═══════════════════════════════════════════════════════════════
BYTE (1) <B> <X.H, 2> <STDIO.H, 44>
DWORD (2) <B> <X.H, 4> <STDIO.H, 105>
FILE (3) <S> <STDIO.H, 50> <STDIO.H, 43>
├ *_ptr ─── char
├ _cnt ──── int
- 8 -
├ *_base ── char
├ _flag ─── char
└ _file ─── char
S_XT (4) <S> <X.H, 7>
├ a ─────────── BYTE
├ b ─────────── WORD
├ string[20] ── BYTE
└ *fptr ─────── FILE ...relations shown at (3)
VOID (5) <B> <X.H, 1>
WORD (6) <B> <X.H, 3> <STDIO.H, 45>
char ...relations shown at (1)
fpos_t ...relations shown at (2)
int ...relations shown at (6)
long ...relations shown at (2)
size_t (7) <B> <STDIO.H, 26>
struct _iobuf ...relations shown at (3)
struct _s_x ...relations shown at (4)
unsigned int ...relations shown at (7)
void ...relations shown at (5)
╔═══════════════════════════════════════════════════════════════
║ TOTAL NUMBER OF DATA TYPES REFERENCED : 7
║ NUMBER OF DATA TYPE DEFINITIONS : 2
║ DIRECTED CALL GRAPH WITH 7 NODES AND 5 CONNECTIO
╚═══════════════════════════════════════════════════════════════
╔═══════════════════════════════════════════════════════════════
║ DATA TYPE CALL STATISTICS
╚═══════════════════════════════════════════════════════════════
DWORD (2) <B> <0 uses>
alias: fpos_t
long
S_XT (4) <S> <0 uses>
alias: struct _s_x
VOID (5) <B> <0 uses>
alias: void
size_t (7) <B> <0 uses>
alias: unsigned int
- 9 -
FILE (3) <S> <1 uses>
alias: struct _iobuf
WORD (6) <B> <2 uses>
alias: int
BYTE (1) <B> <6 uses>
alias: char
╔═══════════════════════════════════════════════════════════════
║ DATA TYPE CALLER-MEMBER LIST
╚═══════════════════════════════════════════════════════════════
<no callers>
DWORD (2) <0, 0>
<no members>
<no callers>
S_XT (4) <0, 4>
BYTE (1) <2>
WORD (6) <1>
FILE (3) <1>
<no callers>
VOID (5) <0, 0>
<no members>
fpos_t ...relations shown at (2)
long ...relations shown at (2)
<no callers>
size_t (7) <0, 0>
<no members>
struct _s_x ...relations shown at (4)
unsigned int ...relations shown at (7)
void ...relations shown at (5)
struct _s_x (4) <1>
FILE (3) <1, 5>
char (1) <4>
int (6) <1>
struct _iobuf ...relations shown at (3)
struct _iobuf (3) <1>
struct _s_x (4) <1>
WORD (6) <2, 0>
<no members>
int ...relations shown at (6)
- 10 -
struct _iobuf (3) <4>
struct _s_x (4) <2>
BYTE (1) <6, 0>
<no members>
char ...relations shown at (1)
╔═══════════════════════════════════════════════════════════════
║ DATA TYPE CALL REFERENCE LIST
╚═══════════════════════════════════════════════════════════════
BYTE (1) [1]: 44
[1]: 44 46 47 48 44 46 47 48
[2]: 8 10 8 10
DWORD (2) [1]: 105
FILE (3) [1]: 43
[2]: 11 11
S_XT (4) [2]: 7
VOID (5) [2]: 1
WORD (6) [1]: 45
[1]: 45 45
[2]: 9 9
char ...relations shown at (1)
fpos_t ...relations shown at (2)
int ...relations shown at (6)
long ...relations shown at (2)
size_t (7) [1]: 26
struct _iobuf ...relations shown at (3)
struct _s_x ...relations shown at (4)
unsigned int ...relations shown at (7)
void ...relations shown at (5)
FILE INDEX LIST
1 G:/C700/INCLUDE/STDIO.H
2 C:/C/CXT/DOC/X.H
3 C:/C/CXT/DOC/X1.C
4 C:/C/CXT/DOC/X2.C
╔═══════════════════════════════════════════════════════════════
- 11 -
║ DATA STRUCTURE NESTING (NL...nestinglevel)
╚═══════════════════════════════════════════════════════════════
S_XT (4) <S> (NL 0)
└ FILE (3) <S> (NL 1)
├ char (1) <B> (NL 2)
└ int (6) <B>
╔═══════════════════════════════════════════════════════════════
║ DATA TYPE TABLE: G:/C700/INCLUDE/STDIO.H
╚═══════════════════════════════════════════════════════════════
LINE DATA TYPE [ELEMENTS,SUBELEMENTS]
43 : FILE (3) <S> [5,0]
alias: struct _iobuf
[1 DATA TYPES, AVERAGE VALUES: 5.00, 0.00]
╔═══════════════════════════════════════════════════════════════
║ DATA TYPE TABLE: C:/C/CXT/DOC/X.H
╚═══════════════════════════════════════════════════════════════
LINE DATA TYPE [ELEMENTS,SUBELEMENTS]
7 : S_XT (4) <S> [4,1]
alias: struct _s_x
[1 DATA TYPES, AVERAGE VALUES: 4.00, 1.00]
╔═══════════════════════════════════════════════════════════════
║ FILES REFERENCED : 2
║ DATA TYPES REFERENCED : 2
║ AVERAGE # OF TYPES/FILE : 1.00
║ AVERAGE # OF ELEMENTS/TYPE : 4.50
║ AVERAGE # OF SUBSTRUCTURES/TYPE : 0.50
╚═══════════════════════════════════════════════════════════════
╔═══════════════════════════════════════════════════════════════
║ FILE INFORMATION
╚═══════════════════════════════════════════════════════════════
FILE SIZE/ SCANNED LINES/SCANNED
STDIO.H : 7467/ 0 bytes, 340/ 0 lines, 1
data types (* included *) <G:/C700/INCLUDE/> (7467, 1.000)
X.H : 217/ 0 bytes, 16/ 0 lines, 1
data types (* included *) <C:/C/CXT/DOC/> (217, 1.000)
X1.C : 212/ 7896 bytes, 23/ 379 lines, 0
data types (* 2 files included *) <C:/C/CXT/DOC/> (212, 1.000)
X2.C : 352/ 8036 bytes, 35/ 391 lines, 0
data types (* 2 files included *) <C:/C/CXT/DOC/> (352, 1.000)
TOTAL : 8248/ 15932 bytes, 414/ 770 lines, 2
data types in 2 of 4 files
2 (* included *) files
- 12 -
program code: 8248 bytes, program comment: 0 bytes
average program code/filesize ratio 1.000
see exact file values above: ... (code bytes, code/filesize
ratio)
END OF CST OUTPUT: CST.LST
This short example session gives only a small overview about the
capabilities of CFT and CST. There is (nearly) no limitation in
the number of files to process, nor is there a limitation in the
complexity of the relationship between the items to analyse and
to display. Test CFT and CST with your own programs or, for
example, with your compiler include files, to get a feeling for
what these tools can be useful to you and your work.
For a complete description of the available commands see the
CFT_CST.DOC file. If you have the BRIEF, MicroEMACS or QEDIT
editor you can use the generated database from CFT and CST and
try the macro functions to access items in multiple files with
just a keystroke.
- 13 -