[Soot-list] ThreadLocalObjectsAnalysis problem

smhuang at cse.ust.hk smhuang at cse.ust.hk
Wed Jul 1 08:13:00 EDT 2009


Thanks a lot for your reply, Richard.
The problem disappears when I apply my instrument in the "wjtp" phase
instead of "jtp".

But now I am facing another problem:
Support I am instrumenting the method body of a method "B", what I want to
do is to insert some static method invocation "A" on entry to "B". "A" has
some arguments such as the method name and the argument types of "B". The
program throws exception when I do the operation:

mr = Scene.v().getMethod("<" + myClass + ": int " + myMethod +
"(java.lang.String,java.lang.Object[],java.lang.String[],boolean[])>").makeRef();

units.insertBefore(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(mr,
args)), s);


Following is the stack trace:

Exception in thread "main" java.lang.ClassCastException: java.lang.String
cannot be cast to soot.Value
	at
soot.jimple.internal.JStaticInvokeExpr.<init>(JStaticInvokeExpr.java:45)
at soot.jimple.Jimple.newStaticInvokeExpr(Jimple.java:433)
	at test.Visitor.addCallWithMethodEntry(Visitor.java:56)
	at test.Visitor.methodEntryInsert(Visitor.java:42)
	at test.Visitor.visitStmt(Visitor.java:31)
	at test.SJTP$1.internalTransform(SJTP.java:80)
	at soot.SceneTransformer.transform(SceneTransformer.java:39)
	at soot.Transform.apply(Transform.java:89)
	at soot.ScenePack.internalApply(ScenePack.java:43)
	at soot.Pack.apply(Pack.java:114)
	at soot.PackManager.runWholeProgramPacks(PackManager.java:407)
	at soot.PackManager.runPacks(PackManager.java:327)
	at soot.Main.run(Main.java:202)
	at soot.Main.main(Main.java:145)

Any clue?

Thanks,
Jeff


> Jeff,
> ThreadLocalObjectsAnalysis only works on the Jimple IR.  This exception
is telling us that the code you're analyzing is in the Baf IR. 
Normally, unless you force it to use a different IR, Soot will transform
your code like this: Java/.class->Jimple->Baf->.class.  You have either
skipped Jimple, or you ran the ThreadLocalObjectsAnalysis too late in
the Soot transformation.  If you need to run something during the Jimple
phase of Soot, the best way is to create your own SceneTransformer and
run it as a phase in the "Whole Jimple Transformation Pack" (wjtp).
>
> If that doesn't sufficiently answer your question, then you should probably
> show us the parts of your code that set up and run Soot and the
> ThreadLocalObjectsAnalysis.
>
> Good Luck,
> Richard
>
> On Mon, Jun 29, 2009 at 10:54 PM, <smhuang at cse.ust.hk> wrote:
>
>> Hi,
>>
>> When I am running ThreadLocalObjectsAnalysis.isObjectThreadLocal in soot,
>> it prompts the following exception:
>>
>>
>> Exception in thread "main" java.lang.ClassCastException:
>> soot.baf.internal.BPushInst cannot be cast to soot.jimple.Stmt
>>        at
>>
>> soot.jimple.toolkits.infoflow.ClassInfoFlowAnalysis.simpleConservativeInfoFlowAnalysis(ClassInfoFlowAnalysis.java:180)
>>        at
>>
>> soot.jimple.toolkits.infoflow.ClassInfoFlowAnalysis.getMethodInfoFlowSummary(ClassInfoFlowAnalysis.java:81)
>>        at
>>
>> soot.jimple.toolkits.infoflow.InfoFlowAnalysis.getMethodInfoFlowSummary(InfoFlowAnalysis.java:110)
>>        at
>>
>> soot.jimple.toolkits.infoflow.InfoFlowAnalysis.getMethodInfoFlowSummary(InfoFlowAnalysis.java:106)
>>        at
>>
>> soot.jimple.toolkits.infoflow.ClassLocalObjectsAnalysis.getContextFor(ClassLocalObjectsAnalysis.java:581)
>>        at
>>
>> soot.jimple.toolkits.infoflow.ClassLocalObjectsAnalysis.propagate(ClassLocalObjectsAnalysis.java:533)
>>        at
>>
>> soot.jimple.toolkits.infoflow.ClassLocalObjectsAnalysis.<init>(ClassLocalObjectsAnalysis.java:94)
>>        at
>>
>> soot.jimple.toolkits.thread.ThreadLocalObjectsAnalysis.newClassLocalObjectsAnalysis(ThreadLocalObjectsAnalysis.java:70)
>>        at
>>
>> soot.jimple.toolkits.infoflow.LocalObjectsAnalysis.getClassLocalObjectsAnalysis(LocalObjectsAnalysis.java:48)
>>        at
>>
>> soot.jimple.toolkits.infoflow.LocalObjectsAnalysis.isObjectLocalToContext(LocalObjectsAnalysis.java:129)
>>        at
>>
>> soot.jimple.toolkits.thread.ThreadLocalObjectsAnalysis.isObjectThreadLocal(ThreadLocalObjectsAnalysis.java:92)
>>        at
>> javato.instrumentor.RecursiveVisitor.visitStmt(RecursiveVisitor.java:90)
at javato.instrumentor.Visitor.visitStmt(Visitor.java:129)
>>        at
>>
>> javato.instrumentor.TransformerForInstrumentation.internalTransform(TransformerForInstrumentation.java:86)
>>        at soot.BodyTransformer.transform(BodyTransformer.java:51) at
soot.Transform.apply(Transform.java:104)
>>        at soot.BodyPack.internalApply(BodyPack.java:49)
>>        at soot.Pack.apply(Pack.java:124)
>>        at soot.PackManager.runBodyPacks(PackManager.java:772)
>>        at soot.PackManager.runBodyPacks(PackManager.java:452)
>>        at soot.PackManager.runBodyPacks(PackManager.java:371)
>>        at soot.PackManager.runPacks(PackManager.java:348)
>>        at soot.Main.run(Main.java:202)
>>        at soot.Main.main(Main.java:145)
>>        at
>>
>> javato.instrumentor.TransformClass.processAllAtOnce(TransformClass.java:213)
>>        at
>>
>> javato.activetesting.instrumentor.InstrumentorForActiveTesting.main(InstrumentorForActiveTesting.java:51)
>>
>>
>> Any hints?
>>
>> Thanks,
>> Jeff
>>
>>
>>
>> _______________________________________________
>> Soot-list mailing list
>> Soot-list at sable.mcgill.ca
>> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>>
>






More information about the Soot-list mailing list