[Soot-list] Soot transformations.

Roman Petriev vvpiroman at gmail.com
Sun Feb 1 07:28:43 EST 2015


Hello everybody!

I try to do test transformation, but I have some problems ...
Code:

        Chain units = b.getUnits();

        Iterator stmtIt = units.snapshotIterator();
        while(stmtIt.hasNext())
        {
            Stmt stmt = (Stmt)stmtIt.next();
            if(stmt instanceof EnterMonitorStmt)
            {
                Local intLocal = Jimple.v().newLocal("myInt", IntType.v());
                b.getLocals().add(intLocal);
                AssignStmt as1 = Jimple.v().newAssignStmt(intLocal,
IntConstant.v(500));
                units.insertBefore(as1, stmt);
                AssignStmt as2 = Jimple.v().newAssignStmt(intLocal,
Jimple.v().newAddExpr(intLocal, IntConstant.v(500)));
                units.insertAfter(as2, stmt);
                Local tmpRef = Jimple.v().newLocal("tmpRef",
RefType.v("java.io.PrintStream"));
                AssignStmt as3 = Jimple.v().newAssignStmt(tmpRef,

Jimple.v().newStaticFieldRef(Scene.v().getField("<java.lang.System:
java.io.PrintStream out>").makeRef()));
                units.insertAfter(as3, stmt);
                SootMethod toCall =
Scene.v().getMethod("<java.io.PrintStream: void println(int)>");


units.insertAfter(Jimple.v().newInvokeStmt(Jimple.v().newVirtualInvokeExpr(tmpRef,
toCall.makeRef(), intLocal)), as3);
            }
        }

What's wrong? Could someone explain, why this code isn't work?
Thanks for any help.

Best regards,
Roman.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20150201/c6036af9/attachment.html 


More information about the Soot-list mailing list