[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Methods/Fields in scene



If you're only trying to detect which fields are not used in the whole
program (in order to make the program smaller for embedded applications,
for instance), then you'll probably find it easiest to write something
yourself following the suggestion of Stephen Neuendorffer.

On the other hand, if you really do want information about which fields
are not read/written by a *specific* method (and the methods called from
it), then there is a new side-effect analysis that sneaked in with
Spark. After you have your invoke graph, grab a SideEffectAnalysis
from the Scene with Scene.v().getActiveSideEffectAnalysis().
Then you can get the read and write sets of any statement, including
invoke statements, with 
sea.readSet( method, stmt )
sea.writeSet( method, stmt )
What you'll get from these is a RWSet, from which you can get a Set
of fields with getFields().

Two warnings:
1) it's slow (and memory-hungry), especially after you've
done a points-to analysis with Spark. This is because it attempts to
keep track of not only which fields are read/written, but also which
fields of which objects. You can discard a points-to analysis you've
done with Scene.v().releaseActivePointsToAnalysis(). We are working on
speeding it up eventually.
2) it's very new, and much less finalized or polished than even Spark.
There may be problems with it. It may be rewritten completely in the
next version of Soot. Use at your own risk. Let us know about your
experience and any comments or suggestions.

Ondrej

On Wed, Dec 11, 2002 at 08:06:16PM -0500, Ankush Varma wrote:
> I use invokeGraph.getTransitiveTargetsof(SootMethod) to get a list of all
> methods reachable from a given method. Is there a way to find all reachable
> fields too?
> 
> Ankush
> 
> -------------------------------------------------
> Ankush Varma
> Ph.D. Student / Graduate Research Assistant
> DSP-CAD Research Group 
> Department of Electrical and Computer Engineering
> University of Maryland, College Park.
> 
> email:
> ankush@eng.umd.edu
> not_ankush@yahoo.com
> 
> Home: 301-439-0438           Office: 301-405-3089
> --------------------------------------------------
>