--- layout: fc_discuss_archives title: Message 48 from Frama-C-discuss on September 2010 ---
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Frama-c-discuss] Calculation of SW complexity



On Wed, 22 Sep 2010 14:47:05 +0200
"Jean-Pierre Nicolas" <jean.nicolas at gmx.de> wrote:

> Hello,
> 
> Also if I've always got the problem to make the plugin 'hello_world', my interest is to make a plugin on FRAMA-C which analyse the sourcecode C and calculate the SW complexity:
> 
> McCabe's Cyclomatic Complexity(MVG)
> Halstead-Effort
> Halstead-Volume
> Halstead-Difficulty
> Maintenance Index
> Lines of Code(LOC)
> Comment Lines (COM) 
> Fan-In, Fan-Out (FI,FIc,FIv,FO,FOc,FOv)


Sorry for this slightly off-topic reply. (off-topic since outside of
Frama-C, but relevant to your SW complexities goal).

> Is it possible with FRAMA-C? 

Very probably it is possible with Frama-C (developped by my colleagues
from LSL at CEA LIST), and also with other tools. I would dare believe
that Frama-C best strengths (ACSL language, abstract interpretation
lattice framework, ability to plug powerful theorem provers, ...) are
not very relevant for the task of computing SW complexities. 

> 
> To realise my calculation, I must know how i can make a plugin in FRAMA-C.


In addition of all the other replies you did got, you might perhaps
also consider solutions outside of Frama-C. There are probably some
commercial products computing SW complexities (and D.Wheeler's
sloccount tool is GPL-ed and compute LOC & COM).  And recent releases
of GCC compiler (e.g. http://gcc.gnu.org/ GCC 4.5.1 whose source was
released in end of july 2010) have two features which, combined, might
interest you: GCC can now be customized and extended with plugins, and
GCC is now able of link time optimizations (hence processing a whole
program or library and not only a single compilation unit).  I don't
know today about existing GCC plugins computing the SW complexities you
want. But you could develop them.  Developping a GCC plugin or extension
requires first and most importantly to understand the major middle-end
internal representations of GCC (Gimple & Tree, which is the common
middle end representations of C, C++, Ada, ObjectiveC source code
inside GCC). Once you understood GCC internal representations and
passes, you could code a GCC plugin in C.  But C is probably not the
best language to process compiler internal representations.  I have
developped a lispy domain specific language to ease the coding of GCC
extensions, called GCC MELT, which offer features (like pattern
matching & functional/applicative & object programming styles) useful
when handling compiler internal representations.  See my slides on
http://2010.rmll.info/Extending-the-GCC-compiler-with-MELT-to-suit-your-needs.html
and http://gcc.gnu.org/wiki/MELT for more.  This summer, I had an intern
(bachelor level, ie french "license d'informatique", J?r?mie Salvucci),
who was able to code in 3 months, without knowing GCC, Gimple, MELT or
Lisp, an extension dumping Gimple back into low level C code.  Ask me
more -outside of the Frama-C list- about GCC MELT if you want to.

Another advantage of working on a GCC extension (operating on Gimple &
Tree) is that the same extension is able to compute the SW complexities
on any source language accepted by GCC (including C, C++, Objective C,
Fortran, Ada, ...).  Frama-C is only for C and would require enormous
efforts to accept all the languages handled by GCC. And once you
have developped a GCC extension (e.g. in MELT), using it is as simple
as adding several more flags to your GCC inovcation (in practice, just
changing the CC & CFLAGS variables in your Makefile).

Sorry for the noise.

Cheers.

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***