[Soot-list] Soot transformations.
Roman Petriev
vvpiroman at gmail.com
Sun Feb 1 09:02:22 EST 2015
Dear Eric, sorry, i forgot to write this.
Test java app before transformation:
public static void main(String[] args) {
int i = 0;
StringBuilder str = new StringBuilder();
synchronized(str){
str.append("fff");
}
i++;
System.out.println(i);
}
Expected result after transformation:
public static void main(String[] args) {
//I want to create Local variable, e.g. myInt
int i = 0;
StringBuilder str = new StringBuilder();
//I want to insert here
//myInt = 500;
synchronized(str){
//myInt = myInt + 500;
//System.out.println(myInt);
str.append("fff");
}
i++;
System.out.println(i);
}
Actually Result:
java.lang.NullPointerException at line in my transformation:
units.insertAfter(Jimple.v().newInvokeStmt(Jimple.v().newVirtualInvokeExpr(tmpRef,
toCall.makeRef(), intLocal)), as3);
2015-02-01 16:08 GMT+03:00 Bodden, Eric <eric.bodden at sit.fraunhofer.de>:
> Dear Roman,
>
> it's hard to say why it does not work when we don't know what the code is
> intended to do and what it actually does do.
>
> Cheers,
> Eric
>
> > On 01.02.2015, at 07:28, Roman Petriev <vvpiroman at gmail.com> wrote:
> >
> > 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.
> > _______________________________________________
> > Soot-list mailing list
> > Soot-list at CS.McGill.CA
> > https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
>
> --
> Prof. Eric Bodden, Ph.D., http://sse.ec-spride.de/ http://bodden.de/
> Head of Secure Software Engineering at Fraunhofer SIT, TU Darmstadt and EC
> SPRIDE
> Tel: +49 6151 16-75422 Fax: +49 6151 869-127
> Room B5.11, Fraunhofer SIT, Rheinstraße 75, 64295 Darmstadt
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20150201/c9e2d5f3/attachment.html
More information about the Soot-list
mailing list