--- layout: fc_discuss_archives title: Message 40 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



Hello,

Le 22/09/2010 14:47, Jean-Pierre Nicolas a ?crit :
> 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)

COM should be quite difficult to implement in Frama-C since this 
platform does not keep comments in the AST, excepted the special ACSL ones.

> Fan-In, Fan-Out (FI,FIc,FIv,FO,FOc,FOv)

> Is it possible with FRAMA-C?

Even it is possible to implement pure syntactic static analysers as 
Frama-C plug-ins, the main targets of Frama-C are semantic static 
analysers. Within the last distributed version (Frama-C Boron), some 
syntactic analyses are actually difficult to implement (or even 
impossible without modifying the Frama-C kernel), since the original C 
source code is syntactically modified by Frama-C itself in order to ease 
the implementation of semantic analysers.

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

The so-called "Plug-in Development Guide" is what you need. It is freely 
available from the Frama-C website:
http://frama-c.com/download/plugin-developer-Boron-20100401.pdf.

> If I have understood correctly, I must write a sourcecode in OCaml for the calculation and also a Makefile to install the Ocaml-sourcecode in FRAMA-C.
> But I don't know how a Makefile must be written.

No particular knowledge of make is required in order to write a Frama-C 
plug-in Makefile. Mainly you just have to modify the Makefile of the 
"Hello World" plug-in. Read the "Plug-in Development Guide" for details.

> I've started to learn OCaml since 7 weeks. It's absolutely different than C or Java. This functional language isn't easy to learn. After searching I found a little programm which calculate some of the results under the terminal of Ubuntu.

The WWW contains plenty resources about OCaml.

If I change the code of the files and the Makefile, it would be possible 
to make a plugin, wouldn't it?

You must know OCaml in order to write a Frama-C plug-in. But an OCaml 
code must follow ad-hoc Frama-C idioms to be a valid Frama-C plug-in. 
Explaining these idioms is the raison d'?tre of the Plug-in Development 
Guide. Once again read it for details. But before, I copy-paste some 
parts of its introduction:

"This guide does not introduce neither the use of Frama-C which is the 
purpose of the user manual [4], nor the use of plug-ins which should be 
introduced in separated and dedicated manuals. We assume that the reader 
of this guide already reads the Frama-C user manual and knows the main 
Frama-C concepts.
[...]
Frama-C is fully developed within the Objective Caml programming 
language (aka OCaml) [11]. Motivations for this choice are given in a 
Frama-C experience report [6]. However this guide does not provide any 
introduction to this programming language: the World Wide Web
already contains plenty resources for OCaml developers (for instance, 
see http://caml.inria.fr/resources/doc/index.en.html for getting many 
pointers)."

Hope this helps,
Julien Signoles
-- 
Ing?nieur-Chercheur
CEA LIST, Laboratoire de S?ret? des Logiciels
point courrier 94, 91191 Gif-Sur-Yvette Cedex
tel:(+33)1.69.08.82.98  fax:(+33)1.69.08.83.95  Julien.Signoles at cea.fr