Search code examples
frama-c

How can i use the modules written for Frama-C' s plugin?


Build is a module which has been developed in order to build the PDG. I wrote a script which uses this module Build but when i try to launch this script with:

frama-c -load-script test.ml

I get the mistake: Unbound module Build. Is there a way to get access to this module. I need it in my project. Build is an example but there are another modules like Sets which provides functions to read a PDG. However, others modules like PdgTypes don't make mistakes. If anybody could help me...

In my file test.ml, let compute = Build.compute_pdg ....

let () = Db.Main.extend main


Solution

  • You can't do that. -load-script can only work for script that do not have any dependency outside of Frama-C (or Frama-C's own dependencies such as OCamlgraph). As suggested by Anne, if your code is contained in more than one file, you should write it as a plugin.

    For a simple plugin, you basically only have to write a short Makefile in addition to your OCaml code. This Makefile will mainly contain the list of source files of your plugin and a few additional information (such as the plugin's name), as explained in the developer's manual, which contain a small tutorial.

    Alternatively, if you have only two files, it should be possible to assemble them manually into a single module that can then be loaded by Frama-C. Supposing you have build.ml and test.ml, you could do (with the Sodium version)

    ocamlopt -I $(frama-c-config -print-libpath) -c build.ml
    ocamlopt -I $(frama-c-config -print-libpath) -c test.ml
    ocamlopt -shared -o script.cmxs build.cmx test.cmx
    frama-c -load-module script.cmxs [other options] [files]