"Fossies" - the Fresh Open Source Software Archive

Member "ncc-2.8/README.1.8.rw" (27 Dec 2004, 1641 Bytes) of package /linux/privat/old/ncc-2.8.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 
    2 It is very very useful to know "which functions modify a variable".
    3 [variable: noun. member of structure or global variable]
    4 
    5 when in the ncc analysis is detected that a variable is definitelly
    6 modified, that is reported accordingly. There are of course cases
    7 where a variable is indirectly modified and it can't be detected.
    8 Such a case which escapes ncc analysis is for example:
    9 
   10 	*(&x) = 3;
   11 
   12 ncc only reports the cases where a variable is in the lvalue
   13 of an assignment (=, +=, -=, etc) or the ++, -- operators
   14 are applied on it.
   15 
   16 That is Good Enough.
   17 
   18 
   19 A Sample Program (analyse this):
   20 
   21 	//-------------start------------
   22 	int GLOBAL;
   23 	typedef struct { int x; } S;
   24 
   25 	int foo ()
   26 	{
   27 		S s;
   28 		s.x++;
   29 		GLOBAL++;
   30 	}
   31 
   32 	int bar ()
   33 	{
   34 		int x;
   35 		S s;
   36 
   37 		x = GLOBAL;
   38 		x = s.x;
   39 	}
   40 
   41 	int zoo ()
   42 	{
   43 		S s;
   44 
   45 		!GLOBAL;
   46 		GLOBAL = 12;
   47 		s.x = GLOBAL;
   48 		GLOBAL = s.x;
   49 	}
   50 	//--------------end--------------
   51 
   52 If this program is compiled with ncc, the output is:
   53 
   54 
   55 	D: foo()
   56 	S: S.x
   57 	G: GLOBAL
   58 
   59 	D: bar()
   60 	g: GLOBAL
   61 	s: S.x
   62 
   63 	D: zoo()
   64 	g: GLOBAL
   65 	G: GLOBAL
   66 	S: S.x
   67 	s: S.x
   68 
   69 	P: rr.c
   70 	L: foo() 6 11
   71 	L: bar() 13 20
   72 	L: zoo() 22 30
   73 
   74 Capital 'S' and 'G' denote that the variable is not modified.
   75 The interesting thing is to view this with 'nccnav'.
   76 
   77 1. Run nccnav on the above output data.
   78 
   79 2. Press <enter> on the file.
   80 
   81 3. Press <enter> on function "bar()".
   82 
   83 4. Press <enter> on "GLOBAL".
   84 
   85 Here is the interesting stuff. The resource of study at
   86 this point is the variable GLOBAL. Functions "bar()" and "zoo()"
   87 are painted blue and are above it. Functions "zoo()" and "foo()"
   88 are painted sandy brown and are below it. Happy Hacking!
   89 
   90 ------------------
   91