[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Soot API: VerifyError when using Chain.insertBefore() methods
Hello,
Are you saying that when I assign input parameter references to local
variables I use the newAssignStmt instead of
the newIdentityStmt?
for (;j < prameterNames.length; j++) {
Type sootType = getSootType(parameterTypes[j]);
argv[j] = Jimple.v().newLocal(prameterNames[j],
sootType);
locals.add(argv[j]);
//Unit currentUnit =
Jimple.v().newIdentityStmt(argv[j], Jimple.v().newParameterRef(sootType,
j));
Unit currentUnit =
Jimple.v().newAssignStmt(argv[j], Jimple.v().newParameterRef(sootType,
j));
units.insertAfter(currentUnit, prevUnits[j]);
prevUnits[j+1] = currentUnit;
params.add((Value)argv[j]);
}
I tried doing that (see line # 6) but I get a RunTime Exception:
java.lang.RuntimeException: Box
soot.jimple.internal.JAssignStmt$LinkedRValueBox
@304310 cannot contain value: @parameter0: java.lang.String(class
soot.jimple.Pa
rameterRef).
Nathan
On Fri, 7 Sep 2001 13:31:17 -0400 (EDT) Patrick LAM
<plam@sable.mcgill.ca> writes:
> On Fri, 7 Sep 2001, nathan gulley wrote:
>
> > What I'm trying to do (using the Soot API) is to insert a static
> method
> > call right before
> > every return statement in a method:
> >
> > // create post condition static invokation
> > Unit postCondMthdUnit = Jimple.v().newInvokeStmt
> > (Jimple.v().newStaticInvokeExpr(postCondMthd, params));
> >
> > // get a Unit iterator
> > Iterator unitIterator = units.snapshotIterator();
> >
> > while (unitIterator.hasNext()) {
> > Unit retStmtUnit = (Unit)unitIterator.next();
> > if (nextUnit instanceof JReturnVoidStmt || nextUnit
> instanceof
> > JReturnStmt) {
> > units.insertBefore(postCondMthdUnit,
> retStmtUnit );
> > }
> > }
>
> Well, one problem is that you're inserting the same Invoke Statement
> before all of the return statements. This *will* be rejected by
> Chain if
> you ever try to insert the same InvokeStmt twice. But that's not
> the
> immediate problem.
>
> How do you construct the params list?
>
> > When you examine the byte code of the instrumented method, you'll
> notice
> > that the value of a
> > String constant is being stored into a DebugMsg object reference
> on the
> > stack at byte # 8:
>
> That's clearly the result of the cast expression. I'm not sure how
> that
> cast expression gets there.
>
> pat
>
>