[Soot-list] How to add transformation without modifying the Soot
source code
Chris Pickett
chris.pickett at mail.mcgill.ca
Thu Apr 12 02:27:22 EDT 2007
Hi Mario,
Check out the Soot tutorials:
http://www.sable.mcgill.ca/soot/tutorial/
I think you want to look at the source code for:
http://www.sable.mcgill.ca/soot/tutorial/profiler/index.html
in particular. Let us know if the documentation needs fixing, of course...
Chris
Mario Mendez wrote:
> Hi again, guys
>
> First of all, thank you for your quick response in the last question.
> you were so diligent that I have another one ;-)
>
> I have my BodyTransformer; for making it work it was necessary to
> a)Add the transformation phase in soot.PackManager
>
> addPack(p = new JimpleBodyPack());
> {
> // ...
> p.add(new Transform("jb.pl",CiaoGenerator.v()));
> }
> b)Force it to actually transform bodies when iterating through them in
> soot.JimpleBodyPack
>
> private void applyPhaseOptions(JimpleBody b, Map opts)
> {
> // ...
> PackManager.v().getTransform( "jb.pl" ).apply( b );
> }
>
> c) add the singleton retrieval in Singletons
>
> private soot.jimple.toolkits.ciao.CiaoGenerator
> instance_soot_jimple_toolkits_scalar_CiaoGenerator;
>
> public soot.jimple.toolkits.ciao.CiaoGenerator
> soot_jimple_toolkits_scalar_CiaoGenerator() {
> if( instance_soot_jimple_toolkits_scalar_CiaoGenerator == null )
> instance_soot_jimple_toolkits_scalar_CiaoGenerator = new
> soot.jimple.toolkits.ciao.CiaoGenerator( g );
> return instance_soot_jimple_toolkits_scalar_CiaoGenerator;
> }
>
> d) ...and all the corresponding options in Options
>
>
> So the question is: for doing so, I'm modifying you code. This is
> problematic for many reason, including that I share my source with other
> people in my group. So rather than telling them: "download Soot and then
> overwrite this 4 files and add this one here and..." I would like to
> create a Main of my own, which does all the above using the API instead
> of overwriting your code. Something like
>
> class MyMain extends soot.Main{
> /...
>
> public int run(String[] args) {
>
> PackManager.v().add(myTransformer)
> tell PackManager to actually use myTransformer, instead of
> modify JimpleBodyPack.java
> add the singleton to Singletons through some interface, instead
> of modifying Singletons.java
> super.run(args)
> }
>
>
> Probably there is a way of doing this. If that is the case, my code will
> be completely separated from yours, so if for example you release a new
> version my transformation will work right away. Can you guys help me a
> little? Thanks!
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
More information about the Soot-list
mailing list