[Soot-list] Add Expression works strange.

Roman Petriev vvpiroman at gmail.com
Wed Feb 4 04:33:16 EST 2015


I do transformations for JBCO. My class extends BodyTransformer and
implements IJbcoTransform. I transform simplest app with only one class
with main method.

Minimal TC1:

@Override
    protected void internalTransform(Body body, String phaseName,
Map<String, String> options) {

        int weight = soot.jbco.Main.getWeight(phaseName,
body.getMethod().getSignature());
        if (weight == 0){
            return;
        }

        PatchingChain<Unit> units = body.getUnits();

        Local intLocal = Jimple.v().newLocal("myInt", IntType.v());
        body.getLocals().add(intLocal);

        AssignStmt as3 = Jimple.v().newAssignStmt(intLocal,
Jimple.v().newAddExpr(intLocal, IntConstant.v(500)));
        units.add(as3);
    }

Minimal TC2:

@Override
    protected void internalTransform(Body body, String phaseName,
Map<String, String> options) {

        int weight = soot.jbco.Main.getWeight(phaseName,
body.getMethod().getSignature());
        if (weight == 0){
            return;
        }

        PatchingChain<Unit> units = body.getUnits();

        Local intLocal = Jimple.v().newLocal("myInt", IntType.v());
        body.getLocals().add(intLocal);

        AssignStmt as1 = Jimple.v().newAssignStmt(intLocal,
IntConstant.v(0));
        units.add(as1);

        AssignStmt as3 = Jimple.v().newAssignStmt(intLocal,
Jimple.v().newAddExpr(intLocal, IntConstant.v(500)));
        units.add(as3);
    }

Erroneous code will be added after return statement of main method.
I hope that is (exactly) what you want to see.


2015-02-04 11:43 GMT+03:00 Bodden, Eric <eric.bodden at sit.fraunhofer.de>:

> Hmmm, this looks wrong. Can you please post a minimal test case to
> reproduce this?
>
> Cheers,
> Eric
>
> > On 04.02.2015, at 08:51, Roman Petriev <vvpiroman at gmail.com> wrote:
> >
> > I try to initialize, and after this I have:
> >
> > iconst_0
> > istore_1
> > iinc_w        #1,  1
> >
> > So, it isn't help.
> >
> >
> > 2015-02-04 2:08 GMT+03:00 Elena Sherman <elenasherman at boisestate.edu>:
> > Roman,
> >
> > Shouldn't you first initialize intLocal before using it in the addition
> expression?
> > For example to 0 :
> >
> > AssignStmt as1 = Jimple.v().newAssignStmt(intLocal, IntConstant.v(0));
> > units.add(as1);
> > AssignStmt as2 = Jimple.v().newAssignStmt(intLocal,
> Jimple.v().newAddExpr(intLocal, IntConstant.v(500)));
> > units.add(as2);
> >
> > On Tue, Feb 3, 2015 at 2:38 PM, Roman Petriev <vvpiroman at gmail.com>
> wrote:
> > Hello everybody!
> > I have code:
> >
> > Local intLocal = Jimple.v().newLocal("myInt", IntType.v());
> > body.getLocals().add(intLocal);
> > AssignStmt as2 = Jimple.v().newAssignStmt(intLocal,
> Jimple.v().newAddExpr(intLocal, IntConstant.v(500)));
> > units.add(as2);
> >
> > So I want to increase local variable on 500.
> > In byte code after transformation I see:
> >
> > iinc_w        #5,  1
> >
> > Why 1 instead of 500? Where I mistake?
> >
> > 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
> >
> >
> >
> > _______________________________________________
> > 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/20150204/efa8bf46/attachment.html 


More information about the Soot-list mailing list