1

In frama-C when I load my source file it does pre processing and does automatic error correction like "automatic typecast " as shown below (int is typecasted to float).

Now how can I see all the changes made after preprocessing.

Is there any method or log file or warning message which shows all the changes made by frama-c.! This is my Source code:

int main() {
int a, b;

printf("Input two integers to divide\n");
scanf("%d%d", &a, &b);
printf("%d/%d = %.2f\n", a, b, a/(float)b);

}

This is my frama-C preprocessed code:

extern int (/* missing proto */ printf)();
extern int (/* missing proto */ scanf)();
int main(void) {
int a;
int b;
int __retres;
printf("Input two integers to divide\n");
scanf("%d%d", &a, &b);
printf("%d/%d = %.2f\n", a, b, (float)a/(float)b);
__retres =0;
return (__retres);
}
anol
  • 8,264
  • 3
  • 34
  • 78

1 Answers1

5

Frama-C's API proposes a certain number of hooks that will be triggered for difference cases of normalization. Note that it does not perform "automatic error correction". The transformations that are done do not alter the semantics of the program.

These hooks are located in cil/src/frontc/cabs2cil.mli For instance, you find there:

val typeForInsertedCast:
  (Cil_types.exp -> Cil_types.typ -> Cil_types.typ -> Cil_types.typ) ref

typeForInsertedCast e t1 t2 is called when an expression e of type t1 must be implicitely converted to type t2 (in the conditions described by the section 6.3 of the C standard about implicit conversions). By providing your own function here via a plugin, you can track all implicit conversions that happen in your program.

A tutorial on writing Frama-C plugins is available in the user manual (requires OCaml knowledge).

Virgile
  • 9,724
  • 18
  • 42