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

Neetha Maria Sebastian neetha.sebastian at gmail.com
Tue Jun 15 13:48:37 EDT 2010


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"

Here is the code where I am trying to instrument :

    public void visitStmtIf(SootMethod sm, Chain units, IfStmt ifStmt) {
        nextVisitor.visitBinopExpr(sm, units, ifStmt, (BinopExpr)
ifStmt.getCondition(), IfContextImpl.getInstance());
        nextVisitor.visitLabel(sm, units, ifStmt, ifStmt.getTarget(),
IfContextImpl.getInstance());
    }

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, "myNewExprInAStaticMethodAfter",
left, false);
         //addCallWithObjectInt(units, s, "myReadBefore", leftOp,
IntConstant.v(4), true);
        }
        nextVisitor.visitBinopExpr(sm, units, s, expr, context);
    }

 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);
        }
    }

addCallWithObject here is a method that is provided by this framework to
instrument a method by simply passing the name of the method. Other calls to
addCallWithObject (from other visitStatements) function properly and dont
show this error. It is only my call to the function that brings up this
Verify Error. I am certain that it has something to do with the object I am
passing to the method, but I have been unsuccessful at figuring out what the
problem is. I saw a similar thread in the mailing list earlier, but I have
not been able to relate the problem that was described there to mine.

I am new to soot and am having considerable difficulty understanding how
things work and it will be helpful if you could point me to some good
documentation (in addition to whats on the sable site)

Thanks
Neetha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100615/00db3e3e/attachment.html 


More information about the Soot-list mailing list