0

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

Community
  • 1
  • 1

2 Answers2

3

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]
Virgile
  • 9,724
  • 18
  • 42
  • Thank you for yours prompt answers! I thought a bit about the Makefile but i was wondering if there was not another way. Effectively, this is a script which has a dependency outside of Frama-C – Kune Rasamizanany Apr 22 '15 at 09:26
3

The modules you refer to, Build and Sets, are not considered as being part of the public user interface of Frama-C. Instead, they are internal to the plugin PDG. The modules of PDG you can access from user scripts are those in the directory src/pdgTypes: PdgIndex, PdgMarks and PdgTypes. Then, a second part of the API is available inside Db.Pdg (Db is in src/kernel/db.ml). In particular, most of the functions of the module Sets are re-exported there.

For the functions available inside Build, they have been deemed too low-level to be exported. If you really need to access it, you will have to copy the directory src/pdg and transform it into a plugin (with a new name, to avoid clashes).

byako
  • 3,372
  • 2
  • 21
  • 36
  • +1 @Boris: I read the question too fast, and I didn't realize that it was the PDG ``Build`` module, and thought it was from @Kune. – Anne Apr 22 '15 at 10:18