0

I edit the question, because I have advanced with the program. It still does not do what I want. So the problem is due to ignorance of Ocaml, the variable "aux2" is of type: "Function_From.Deps.t -> Function_From.Deps.t". C How could I access each one and display the data ?,that is to say, enter the type on the right and the left.

This is my code:

open Cil_types
open Function_Froms  
(* usage: frama-c file.c -load-script print_vals.ml *)
    let aux depsReturn =
        match depsReturn with
        |Function_Froms.Memory.Top -> Locations.Zone.bottom
        |Function_Froms.Memory.Bottom -> Locations.Zone.bottom
        |Function_Froms.Memory.Map m ->  Function_Froms.Memory.fold (fun z v acc ->
            let open DepsOrUnassigned in
            match v with
    | DepsBottom | Unassigned -> acc
    | AssignedFrom _ | MaybeAssignedFrom _ -> Locations.Zone.join z acc)
      m Locations.Zone.bottom

let () =
  Db.Main.extend (fun () ->
      Format.printf "computing value...@.";
      !Db.Value.compute();
      let fun_name = "main" in
      let kf = Globals.Functions.find_by_name fun_name in
      if !Db.From.is_computed kf then
        Format.printf "Do to pass?...\n";
      let deps = !Db.From.get kf in
      let depsReturn = deps.deps_table in
      let aux1 =aux depsReturn
      in
      let aux2 =Function_Froms.Memory.substitute depsReturn in
      Format.printf " Passed \n";

    )

This is the result you get with -deps and below that I would like to put.

....
[from] ====== DEPENDENCIES COMPUTED ======
       These dependencies hold at termination for the executions that terminate:
[from] Function f:
  y FROM x
  \result FROM x
[from] Function main:
  y FROM \nothing
  z FROM \nothing (and SELF)
[from] ====== END OF DEPENDENCIES ======
computing value...
Do to pass?...
 To Pass..

new way:

Function main:

sub fuction: y 

val: nothing

sub function: z

val: nothing 

Thanks.

  • 1
    You should show what you have tried so far and what is not working as expected. – Anne May 29 '17 at 11:32
  • Do you know how to write code in OCaml ? Did you find the `From` module in file `db.mli`? – byako May 30 '17 at 12:38
  • Your code does not compile because `Function_Froms.Memory.substitute` expects two arguments: a memory state (probably `deps` here), and something of type `Deps.t`, hence probably `depsReturn`. But I do not understand what you are attempting to compute, so I cannot help you further. Can you clarify your _goal_? The example is not sufficient. – byako Jun 08 '17 at 08:49
  • I have solved the problem, thank for your time @byako – francisco manuel romero romero Jun 08 '17 at 12:10

0 Answers0