[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: read/write sets for a Unit
I don't think there's anything wrong with getting the side-effect
analysis through the PASideEffectTester, other than that it's a
convoluted way to get to it, and the approach Manoj mentioned is much
simpler.
Assuming the exception is happening in the same line 44 that is line 44
in the latest version in Subverion, it sounds like the problem is that
you're building the side-effect analysis in the jtp pack, which doesn't
run on all method bodies together. Instead, the jtp pack runs on all the
methods of a class, then all the other packs run on the same class, then
the class is written out, and then we go on to running jtp on another
class. The exception happens when the side-effect analysis needs to look
at a method that has already been processed and written out to a class
file, so its code is no longer available.
The reason that this doesn't happen normally is that most code using
the PASideEffectTester needs the side-effects of all the statements in
each method, meaning that all the side-effects are computed for every
method before it gets written out. If they are needed again later, the
side-effect analysis just pulls the side-effects it has already
computed, which works even if the method is no longer available.
Probably the easiest way to fix this is to put your analysis into a
SceneTransformer explicitly iterating over the methods you want to
analyze, and put the SceneTransformer into a whole-program pack such as
wjtp.
Ondrej
On Tue, Nov 25, 2003 at 09:21:00AM -0600, Will Benton wrote:
> Hello,
>
> I'm curious as to what the correct way to access read/write sets for a
> given Unit is from within a BodyTransformer. I'm assuming that what
> I'm doing is violating some precondition on the SideEffectTester code,
> because it's not working. (Therefore, the rest of this message, which
> explains what I am doing now, can probably be skimmed or skipped if
> it's clearly wrong.)
>
> Right now, what I'm doing is pretty convoluted (and I'm pretty sure
> that it's wrong -- both a priori and because I get occasional
> ClassCastExceptions from deep within soot code). My basic approach is
> to override PASideEffectTester with a class that will let me access the
> fields in readSet() and writeSet(), instantiate that class in my
> BodyTransformer and invoke its newMethod method with the Method
> corresponding to the current Body, and then invoking the methods on my
> SideEffectTester-derived class that return the getFields() set from the
> RWSets returned by readSet and writeSet. I then run soot in
> whole-program mode, enabling spark (my transformation is in the jtp
> pack).
>
> Occasionally, I'll get exceptions like the following. These occur when
> analyzing method invocations. It's not clear to me that a particular
> class of method invocations (i.e. special, static, or virtual) is the
> culprit; if I catch these exceptions, I can see that some will fail and
> some will not. Overall, it appears that between 5-45% of attempts to
> analyze method invocations fail, depending on what program I'm
> analyzing.
>
> Exception in thread "main" java.lang.ClassCastException
> at
> soot.jimple.toolkits.pointer.SideEffectAnalysis.findNTRWSets(SideEffectA
> nalysis.java:44)
> at
> soot.jimple.toolkits.pointer.SideEffectAnalysis.nonTransitiveReadSet(Sid
> eEffectAnalysis.java:57)
> at
> soot.jimple.toolkits.pointer.SideEffectAnalysis.readSet(SideEffectAnalys
> is.java:90)
> at
> soot.jimple.toolkits.pointer.PASideEffectTester.readSet(PASideEffectTest
> er.java:65)
> at
> com.willbenton.sootPasses.wbSideEffectMarker$csssemSideEffectTester.read
> Fields(wbSideEffectMarker.java:13)
> at
> com.willbenton.sootPasses.wbSideEffectMarker.actualTransform(wbSideEffec
> tMarker.java:90)
> at
> com.willbenton.sootPasses.cwsBaseBodyTransformer.internalTransform(cwsBa
> seBodyTransformer.java:32)
> at soot.BodyTransformer.transform(BodyTransformer.java:51)
> at soot.Transform.apply(Transform.java:88)
> at soot.BodyPack.internalApply(BodyPack.java:44)
> at soot.Pack.apply(Pack.java:110)
> at soot.PackManager.runBodyPacks(PackManager.java:423)
> at soot.PackManager.runBodyPacks(PackManager.java:282)
> at soot.PackManager.runPacks(PackManager.java:241)
> at soot.Main.run(Main.java:172)
> at soot.Main.main(Main.java:152)
> at
> com.willbenton.sootPasses.wbSideEffectMarker.main(wbSideEffectMarker.jav
> a:125)
>
> Thanks for any help!
>
>
>
>
> wb
>
> ---
> Will Benton <willb@cs.wisc.edu>
> "Wir sind Bettler, das ist wahr"
> recently updated (11/1/03) contact info at:
> http://www.cs.wisc.edu/~willb/willb.vcf
>