ocaml - 如何访问我的 CIL 模块中提供给 cilly 的文件

标签 ocaml static-analysis c-intermediate-language

我在 CIL(C 中间语言)中添加了一个新功能。我能够使用

执行我的新模块
$cilly --dotestmodule --save-temps -D HAPPY_MOOD -o test test.c

现在,在我的测试模块中,我想为 test.c 文件调用 Cfg.computeFileCFG。但是我不知道如何访问我的模块中的 test.c 文件。

我尝试使用 Cil.file。但它说“未绑定(bind)值 Cil.file”。

我的代码:

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;
  }

请告诉我如何计算 test.c 文件的 Cfg。

最佳答案

我不是 CIL 专家,但这里有几点说明:

  • CIL 在线文档 states Cil.file 是一个 Ocaml 类型。将 type 作为参数传递给 function 可能不是您想在此处执行的操作;
  • 您的功能描述符中的 fd_doit 函数似乎将您要处理的文件作为其参数 f
  • 根据Cilly manual,f的类型是Cil.file。方便的是,这 seems是函数 computeFileCFG 所需的参数类型。

希望你能从这里开始。祝你好运!

关于ocaml - 如何访问我的 CIL 模块中提供给 cilly 的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10515254/

相关文章:

operators - OCaml 中的扫描和负整数文字

在 OCaml 函数的 C 实现中创建求和类型

debugging - 无法在 ocamldebug : "Can' t find any event there. 中设置断点“

recursion - OCaml 中的匿名递归函数

java - PMD 报告超过 X 次违规

c - 在 C 代码中查找 "fallthroughs"

erlang - 在 Elixir 类型规范的类型定义中指定字符串值