On Fri, Jul 26, 2013 at 03:46:51PM +0800, tsuletgo wrote:
> Ok. i changed the code.
> See the attached.
Thanks. I have no idea why and I don't have the time to check CIL code right
now, but using ChangeDoChildrenPost instead of DoChildren makes your code behave
correctly:
open Cil
let function_id = ref 0
class myVisitor = object(self)
inherit nopCilVisitor
method vglob = function
| GFun (fd, _) ->
function_id := fd.svar.vid;
DoChildren
| _ -> SkipChildren
method vstmt st =
let df_fun = Cil.emptyFunction "df_stmt_monitor" in
let df_monitor_call = Call(None,Lval(Var df_fun.svar,NoOffset),
[Cil.integer !function_id; Cil.integer st.sid], !currentLoc) in
ChangeDoChildrenPost(st, fun s -> self#queueInstr [df_monitor_call]; s)
end;;
let do_df_instrumentation (file: Cil.file) =
visitCilFileSameGlobals (new myVisitor) file
let feature : featureDescr =
{ fd_name = "df";
fd_enabled = ref false;
fd_description = "testing instrumentor";
fd_extraopt = [ ];
fd_doit =
(function (f: file) ->
do_df_instrumentation f);
fd_post_check = true
}
Note that st.sid will always be -1 unless you build the Cfg first.
Best,
--
Gabriel
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
CIL-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cil-users