On Wed, Apr 11, 2012 at 11:12:52AM +0800, 林楠 wrote: > First of all, I don't think changing CIL source files directly is a good idea. > It would be better to implement a dedicated visitor for this job. I think the > visitor should visit the globals (GVarDecl and GFun) of the single C file and > change the vstorage to static.
I fully agree. You can find example of visitors in src/ext. Yours should be something like (not tested, might contain a few typos): class changeStorage = object(self) inherit cilVisitor method vglob = function (* you can find the list of possible globals here: http://kerneis.github.com/cil/doc/html/cil/api/Cil.html#TYPEglobal *) | GVarDecl (vi, _) | GVar (vi, _) | GFun ({ svar = vi }, _) -> vi.storage <- Static; SkipChildren | _ -> SkipChildren end let feature = { fd_name = "change_storage"; fd_enabled = ref true; fd_description = "change storage to static"; fd_extraopt = []; fd_doit = fun f -> visitCilFileSameGlobals (new changeStorage) f; fd_post_check = true; } Note that the "feature" part is only needed if you implement it as a CIL extension (in src/ext). If you want to use Cil as an OCaml library instead, you can follow this tutorial for instance: http://people.redhat.com/~rjones/cil-analysis-of-libvirt/ Best, -- Gabriel ------------------------------------------------------------------------------ Better than sec? Nothing is better than sec when it comes to monitoring Big Data applications. Try Boundary one-second resolution app monitoring today. Free. http://p.sf.net/sfu/Boundary-dev2dev _______________________________________________ CIL-users mailing list CIL-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cil-users