我编辑了这个问题,因为我已经使用该程序了。它仍然没有做我想要的。所以问题是由于忽略了Ocaml,变量"aux2"
的类型为:"Function_From.Deps.t -> Function_From.Deps.t"
。 C我怎样才能访问每一个并显示数据?也就是说,输入右侧和左侧的类型。
这是我的代码:
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";
)
这是你得到的-deps以及我想要的结果。
....
[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..
新方式:
Function main:
sub fuction: y
val: nothing
sub function: z
val: nothing
感谢。