Frama-C-Plugin: Set value of variable in plugin

左心房为你撑大大i 提交于 2020-01-07 06:58:29

问题


I am writing a Frama-C Plugin.

I want to develop a plugin, that sets the value of a local variable. By this idea I try to do the value-analysis afterwards, and then I can analyze the reachablility, path analysis and other things by my second plugin.

Is it possible to set the value of a local variable within a plugin (at the start of a function where I know the name)?

EDIT

I now found out how to make new local variables, how to get the Varinfo of variables and how to create new varinfos. The only missing thing is setting the variable's value.

I started with a code like this:

match kf_cil_fun with
| Cil_types.Definition(a,b) -> 
    let val_visitor = new value_set_visitor kf in
        Visitor.visitFramacFileSameGlobals (val_visitor :> Visitor.frama_c_visitor) (Ast.get());
    let old_varinfo = Cil.makeLocalVar a "x" Cil.intType in
    let new_varinfo = Cil.makeVarinfo false false "x" Cil.intType in
    val_visitor#doStuff old_varinfo new_varinfo;
    ()
| _ -> ()

where the visitor is a simple visitor with a method doStuff, and the builtin-methods vfile, vglob_aux and vstmt_aux that simply call Cil.DoChildren

method doStuff old_varinfo new_varinfo =
            Cil.set_varinfo self#behavior old_varinfo new_varinfo;

Does anyone have an idea of how to set the value of x to 1 (or a fixed other value)? Am I doing the things right?

来源:https://stackoverflow.com/questions/36326495/frama-c-plugin-set-value-of-variable-in-plugin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!