[Soot-list] How can I avoid the java.lang.VerifyError?
Sunny
sunfire001 at gmail.com
Mon May 8 13:52:12 EDT 2006
Hi,
I am trying to record the values of a local variable before and after an
assignment to it. Below
I listed my code snippet to achieve this and described two problems.
The source code to be instrumented (part of TestInvoke.java):
public void test()
{
String x;
x = "from test";
}
The method to report the value as well as the containing context:
public static void reportLocal(Object enclosingObj, Object value)
{
System.out.println("enclosing = " + enclosingObj + ", value = " + value);
}
And finally, the code in internalTransform to insert statements:
Vector args = new Vector();
args.add(body.getThisLocal());
args.add(loc);
InvokeExpr reportExpr = Jimple.v().newStaticInvokeExpr(reportLocal.makeRef(),
args);
Stmt reportStmtBefore = Jimple.v().newInvokeStmt(reportExpr);
// Stmt reportStmtAfter = Jimple.v().newInvokeStmt(reportExpr);
units.insertBefore(reportStmtBefore, stmt);
// units.insertAfter(reportStmtAfter, stmt);
The above code only injects an invoke statement before the assignment.
Problem1:
After the TestInvoke.java is instrumented and executed, I always got the
exception:
java.lang.VerifyError: (class: src/TestInvoke, method: test signature: ()V)
Accessing value from uninitialized register 1
Exception in thread "main"
How should I avoid this error and obtain the variable's value before
assignment? It worked if I only injected
invoke statements AFTER the assignment, as the commented lines show.
Problem2:
There are two kinds of local variables in a jimple method, those implicitly
defined by
jimple representing stack positions, and those that are explicitly defined
by a user's program. Can I distinguish
these two simply by using Local#getName().startsWith("$"))?
Thank you very much for any help!
Sunny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20060508/197097be/attachment.htm
More information about the Soot-list
mailing list