[Soot-list] VerifyError while instrumenting with Chain.insertBefore() method.

Neetha Maria Sebastian neetha.sebastian at gmail.com
Wed Jun 16 00:43:06 EDT 2010


I did not intend to limit my arguments to bytes / booleans, but yes it does
appear that this is what I end up doing. myIfBefore expects an integer and
an Object. The method signature is :

public static void myIfBefore(int iid, Object parameter);

I am trying to pass the condition of each ifStmt to myIfBefore by obtaining
the left and right operands of the if condition with the following code :

public void visitBinopExpr(SootMethod sm, Chain units, Stmt s, BinopExpr
expr, BinopExprContext context) {
     Value left =  expr.getOp1();
        Value right = expr.getOp2();

        if( s instanceof IfStmt) {
         System.out.println(" Found an if statement : " + s.toString());
                addCallWithObject(units, s, "myIfBefore", left, false);
        }
        nextVisitor.visitBinopExpr(sm, units, s, expr, context);
    }

My understanding was that "Value left = expr.getOp1()" would give an object
with the operand. I similar things done in other parts of the code (which is
working, and so assumed that it would work here too). The method
addCallWithObject takes the "Value" argument and does the instrumenting like
this :

protected void addCallWithObject(Chain units, Stmt s, String methodName,
Value v, boolean before) {
        SootMethodRef mr;

        mr = Scene.v().getMethod("<" + observerClass + ": void " +
methodName + "(int,java.lang.Object)>").makeRef();
        if (before) {

 units.insertBefore(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(mr,
IntConstant.v(getAndIncCounter()), v)), s);
        } else {

 units.insertAfter(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(mr,
IntConstant.v(getAndIncCounter()), v)), s);
        }
    }

Thanks!



On Tue, Jun 15, 2010 at 11:48 PM, Patrick Lam <plam at cs.mcgill.ca> wrote:

> On 06/15/10 13:48, Neetha Maria Sebastian wrote:
>
>> Hi,
>>
>> I have been trying to insert a method call before every "if" statement
>> inside some programs. I am building on top of an existing framework
>> called Calfuzzer, and for some reason, I am never able to pass the if
>> statements condition arguments to the instrumented method. I see other
>> parts of the framework do similar things, and tried to replicate what
>> they were doing, but end up with
>>
>>      [java] java.lang.VerifyError: (class:
>> benchmarks/dstest/MTTreeSetTest, method: main signature:
>> ([Ljava/lang/String;)V) Expecting to find object/array on stack
>>      [java] Could not find the main class:
>> benchmarks.dstest.MTTreeSetTest.  Program will exit.
>>      [java] Exception in thread "main"
>>
>
> The Jimple code looks correct, but what are the parameters to myIfBefore?
> It looks like you're assuming that they're (byte, boolean), but the JVM
> seems to think that they should at least contain one object or array.
>
> pat
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100616/2abf5685/attachment.html 


More information about the Soot-list mailing list