AminetAminet
Search:
84782 packages online
About
Recent
Browse
Search
Upload
Setup
Services

dev/gg/ncc-0.5.lha

Mirror:Random
Showing: ppc-morphos icongeneric icon
No screenshot available
Short:NCC - C source program analysis tool for GCC
Author: sxanth at ceid.upatras.gr
Uploader:
Type:dev/gg
Architecture:m68k-amigaos
Date:2002-04-14
Download:dev/gg/ncc-0.5.lha - View contents
Readme:dev/gg/ncc-0.5.readme
Downloads:616

Ported by LouiSe

more info and other AMIGA ports at:
http://louise.amiga.hu

-----------------------------------------

ncc 0.5


WHATIS
======


Basically, ncc is a tool for hackers designed to provide program analysis
data of C source code.  That is program flow and usage of variables.
Some big programs out there are by default obfuscated, either due to extreme
size, programming style, hacks upon hacks and other crazyness.  In order to
do program analysis correctly, there has to be compilation of expressions,
and thus ncc is really a compiler (supporting zero architectures).

At the same time, ncc is small and easy to understand so you can hack it and
add custom features and extensions at any stage of the compilation, to match
what you expect and consider useful as output.  Most common GNU extensions
are supported and there has been an effort be practically useful in the GNU
system (which is not easy because the GNU system is very gcc-friendly).
The goal is to be able to replace 'ncc' in Makefiles and work with the big
open source projects.


INSTALL
=======

'make'

and copy the file doc/nognu to /usr/include.

This file is used to fix some madness of libc header files and remove some
GNU extensions which violate the C grammar and can be removed without
problems.  If you don't want to copy it to /usr/include, edit config.h and
recompile.



USAGE
=====

ncc uses gcc for preprocessing because the standard library headers
eventually need some other architecture specific header which are somewhere
where gcc knows where.  Any options starting with -D and -I will be passed
to gcc for preprocessing.  Generally, because ncc should be able to work
from makefiles instead of gcc, all options unless starting with '-nc'
produce no error (and may be even passed to gcc in a special mode).

The files compiled with ncc, will have the __GCC__ macro defined, because many
programs are written for gcc and take some gcc extensions for granted.
ncc additionally defines __NCC__ macro.

the default output (at stdout) is the report of :function calls, use of global
variables and use of members of structures.

with "-ncmv" each use of global variable or member of structure is reported
multiple times as used.  This is a way to understand better how the code
works, by looking the use of variables between function calls.

with "-nc2dm" the output is suitable for the 2dmap viewer and includes only
the function calls.

with "-nchelp" help is displayed on the -nc options.

with "-ncoo" the output goes to a file sourcefile.c.nccout


HACKING mpg123
==============

This one is easy (because it's done "the right way", programs are
exponential: the number of tasks a program can do is N^2 if N are the lines
of code. Thus any program of more than 50000 lines has probably design flaws
(unless it's device drivers))

Anyway, to view the calls of mpg123, the command is:

	for a in *.c; do ncc $a -ncoo -nc2dm; done
	cat *.nccout > code.map
	2dmap



HACKING LARGER PROGRAMS
=======================

The obvious way is to use make with ncc, so that the required -D and -I
options are invoked, and only the right files are compiled (if there
are depenencies).  Normally, changing "CC=gcc" to "CC=ncc -ncoo" would be
enough.  But alas! often it isn't.

So now you have to devise ways to hack the Makefiles or think of other
tricks to get the job done.

Sometimes the make procedure expects object files which ncc does not produce
and it may fail.  Other programs even compile and run helpers in the
procedure of make.  If all else fails, the last resort that always works, is
using the "-ncgcc" option.

with "-ncgcc", ncc will also run gcc in parallel with all it's options except
the -nc ones.  So nobody will understand that ncc was even run and the
makefiles will be happy.  It takes 1000% more time, but computers do get
faster every day.  In this case, it is generally a good idea to remove any
'-O2 -g' options.



BYTECODE
========

with "-nccc", the output is some bytecode for the expressions.
In this mode ncc does full syntax and semantics tests, unlike the other
modes which'd better work with sources known to be correct.

The output is definatelly incomplete and of little use, but its fun to look at.
A tip is that variables are taken one level down : the '&' operator
disappears and an extra '*' goes infront of variables.
The enlightening example is:
---------------------------------
int **pp, *pa [10], a [10][10];

pp[1][1];
pa[1][1];
a[1][1];
---------------------------------

BTW, since in C:  &a == a == &a[0]
for an array 'a', ncc supports &(&(&(&a))) == a
which is mathematically and logically correct as the address-of operator
may have no effect and still be valid (for pointer operands that are not
lvalues).



TROUBLESHOOTING
===============

As this is the first release of ncc, braindead bugs should still be in here.
However, thanks to open source, there are infinitive test cases.
ncc has been tested with:

	linux kernel (partial according to depend), Imagemagick, gcc
	xanim, mpg123, bladeenc, bzip2, gtk, gnu-fileutils,
	less, mpeg_play, nasm, ncftp, vim, sox, bind, gdb

although these programs are correct and ncc lacks testing on finding errors
on wrong programs.

Also read the file doc/TROUBLES



TODO
====

- GNU statements in expressions, are parsed but the return type is not saved 
  and it's done int.  That of course is wrong but since for the moment
  there were no problems during testing it stays.  Will be fixed.

- The bytecode can be : optimized, turned into architecture assembly,
  run with an intepreter, etc.  Bytecode for the statements will be added
  if there is interest for any of the above.

- It is easy to implement parsing structures when lookup for a member is
  done for the first time.  That will save both space and time as more
  structures declared in header files are not used.  But there is no reason
  to get paranoid with optimization.  The major slowdown factor is having
  to use -ncgcc afterall.

- Maybe get into C++.



THEREST
=======

Program written by Stelios Xanthakis.
e-mail: sxanth@ceid.upatras.gr
ncc latest download: http://students.ceid.upatras.gr/~sxanth/ncc/

Check out: http://students.ceid.upatras.gr/~sxanth/PP/
for the solution to symmetrical cryptography.


Contents of dev/gg/ncc-0.5.lha
 PERMSSN    UID  GID    PACKED    SIZE  RATIO     CRC       STAMP          NAME
---------- ----------- ------- ------- ------ ---------- ------------ -------------
[generic]                 2988    8876  33.7% -lh5- 9598 Apr 13  2002 2dmap/2dmap.C
[generic]                  743    2340  31.8% -lh5- 8a53 Apr 10  2002 2dmap/dLIST.C
[generic]                  677    2516  26.9% -lh5- aa4e Apr 10  2002 2dmap/dLIST.h
[generic]                  193     310  62.3% -lh5- a4da Apr 10  2002 2dmap/Makefile
[generic]                  675    1371  49.2% -lh5- 5206 Apr 11  2002 2dmap/README
[generic]                  333     503  66.2% -lh5- c4e9 Apr 12  2002 2dmap/slowcat.c
[generic]                 7091   29504  24.0% -lh5- 77ff Apr 13  2002 ccexpr.C
[generic]                 7576   25667  29.5% -lh5- d35a Apr 12  2002 cdb.C
[generic]                 1275    3437  37.1% -lh5- ebb8 Apr 11  2002 cexpand.C
[generic]                  112     151  74.2% -lh5- f88d Apr 12  2002 config.h
[generic]                 1954    5884  33.2% -lh5- ed61 Mar  3  2002 dbstree.C
[generic]                  500    1371  36.5% -lh5- 39ce Mar 15  2002 dbstree.h
[generic]                  633    1119  56.6% -lh5- 4907 Apr 13  2002 doc/ABANDONWARE_GAMES
[generic]                 4829   13473  35.8% -lh5- 5061 Apr 12  2002 doc/dbstree.tex
[generic]                 2948    6151  47.9% -lh5- 51d1 Apr 13  2002 doc/NCC
[generic]                  209     441  47.4% -lh5- 8ef2 Apr 12  2002 doc/nognu
[generic]                 2209    5471  40.4% -lh5- ae32 Apr 13  2002 doc/TROUBLES
[generic]                 2049    5320  38.5% -lh5- e67a Apr 12  2002 global.h
[generic]                  733    1934  37.9% -lh5- b5c4 Apr  6  2002 inttree.C
[generic]                  216     578  37.4% -lh5- eabc Apr  6  2002 inttree.h
[generic]                 2065    8794  23.5% -lh5- 8249 Apr 13  2002 lex.C
[generic]                 1382    3377  40.9% -lh5- 7764 Apr 13  2002 main.C
[generic]                  442    1265  34.9% -lh5- 5ce3 Apr 13  2002 Makefile
[generic]                58728  132992  44.2% -lh5- b3f4 Apr 13  2002 ncc
[generic]                 3067    6474  47.4% -lh5- c8fd Apr 13  2002 ncc-0.5.readme
[generic]                 1426    4271  33.4% -lh5- 1025 Apr  6  2002 norm.h
[generic]                58728  132992  44.2% -lh5- b3f4 Apr 13  2002 objdir/ncc
[generic]                  163     288  56.6% -lh5- cc9d Mar 22  2002 objdir/suite/asm.c
[generic]                   94     128  73.4% -lh5- 77fb Apr  9  2002 objdir/suite/bf.c
[generic]                  726    1816  40.0% -lh5- c115 Apr 11  2002 objdir/suite/CANAL.i
[generic]                  208     345  60.3% -lh5- 2d3b Apr  9  2002 objdir/suite/csp.c
[generic]                   41      41 100.0% -lh0- 033c Apr 10  2002 objdir/suite/enum.c
[generic]                   78      88  88.6% -lh5- 4711 Apr 10  2002 objdir/suite/err.c
[generic]                  921    2075  44.4% -lh5- 8923 Mar 23  2002 objdir/suite/etest.c
[generic]                  247     425  58.1% -lh5- 8986 Apr  3  2002 objdir/suite/foot.c
[generic]                  118     205  57.6% -lh5- 54c6 Mar 20  2002 objdir/suite/gnuc.c
[generic]                   59      59 100.0% -lh0- e35e Apr  9  2002 objdir/suite/ina.c
[generic]                   66      69  95.7% -lh5- a60f Apr  9  2002 objdir/suite/pp.c
[generic]                   19      19 100.0% -lh0- e57d Apr 10  2002 objdir/suite/README
[generic]                  860    2485  34.6% -lh5- fe92 Apr 11  2002 objdir/suite/t1.c
[generic]                  163     303  53.8% -lh5- 1ca9 Apr  4  2002 objdir/suite/t2.c
[generic]                  200     281  71.2% -lh5- 3b51 Apr  3  2002 objdir/suite/t2.s
[generic]                  211     361  58.4% -lh5- 0871 Apr  7  2002 objdir/suite/t3.c
[generic]                   92     118  78.0% -lh5- 75ff Apr  7  2002 objdir/suite/t4.c
[generic]                  929    1882  49.4% -lh5- 1994 Mar 14  2002 objdir/suite/test.c
[generic]                 8080   31139  25.9% -lh5- 8b6d Apr 13  2002 parser.C
[generic]                 1491    3830  38.9% -lh5- 656b Apr 12  2002 preproc.C
[generic]                 2500    7674  32.6% -lh5- 54b6 Apr 12  2002 space.C
[generic]                  805    2213  36.4% -lh5- 118b Apr 11  2002 stack.h
[generic]                 2735   10728  25.5% -lh5- 539c Apr 12  2002 usage.C
---------- ----------- ------- ------- ------ ---------- ------------ -------------
 Total        50 files  184587  473154  39.0%            Apr 14  2002
Page generated in 0.02 seconds
Aminet © 1992-2024 Urban Müller and the Aminet team. Aminet contact address: <aminetaminet net>