3

I have added a new feature to CIL(C Intermediate Language). I am able to execute my new module using

$cilly --dotestmodule --save-temps -D HAPPY_MOOD -o test test.c

Now, in my testmodule, I want to call Cfg.computeFileCFG for test.c file. But I don't know how to access test.c file in my module.

I tried using Cil.file. but it says "Unbound value Cil.file".

my code:

open Pretty
open Cfg
open Cil

module RD = Reachingdefs

let () = Cfg.computeFileCFG Cil.file

let rec fact n = if n < 2 then 1 else n * fact(n-1)
let doIt n = fact n

let feature : featureDescr =
  { fd_name = "testmodule";
    fd_enabled = ref false;
    fd_description = "simple test 1240";
    fd_extraopt = [];
    fd_doit = (function (f: file) -> ignore (doIt 10));
    fd_post_check = true;
  }

please tell me how to compute the Cfg for test.c file.

svick
  • 236,525
  • 50
  • 385
  • 514
Srikanth Vaindam
  • 455
  • 4
  • 13

1 Answers1

3

I am not a CIL expert, but here are a few remarks:

  • the CIL online documentation states that Cil.file is an Ocaml type. Passing a type as an argument to a function is probably not what you want to do here;
  • it seems like the fd_doit function in your feature descriptor takes the file you are looking to process as its argument f;
  • according to the Cilly manual, the type of f is Cil.file. Conveniently, this seems to be the type of the argument required by the function computeFileCFG.

Hopefully you can take it from here. Good luck!

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
ftk
  • 614
  • 6
  • 11