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

2019-09-09 20:53发布

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?

标签: frama-c
0条回答
登录 后发表回答