[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reaching Definitions Analysis
Soot includes a reaching defs analysis in SimpleLocalDefs. Here is an
example of some code that uses it which is taken from the
ReachingDefsTagger which will appear in upcoming versions of Soot.
Ondrej
protected void internalTransform(Body b, String phaseName, Map options){
SimpleLocalDefs sld = new SimpleLocalDefs(new ExceptionalUnitGraph(b));
Iterator it = b.getUnits().iterator();
while (it.hasNext()){
Stmt s = (Stmt)it.next();
//System.out.println("stmt: "+s);
Iterator usesIt = s.getUseBoxes().iterator();
while (usesIt.hasNext()){
ValueBox vbox = (ValueBox)usesIt.next();
if (vbox.getValue() instanceof Local) {
Local l = (Local)vbox.getValue();
//System.out.println("local: "+l);
Iterator rDefsIt = sld.getDefsOfAt(l, s).iterator();
while (rDefsIt.hasNext()){
Stmt next = (Stmt)rDefsIt.next();
String info = l+" has reaching def: "+next.toString();
s.addTag(new LinkTag(info, next, b.getMethod().getDeclaringClass().getName(), "Reaching Defs"));
}
}
}
}
}
On Wed, Mar 24, 2004 at 03:01:31PM -0500, Leon Krupkin wrote:
> Can anyone give me some pointers on performing reaching definitions
> analysis using soot? I've looked at the tutorials and the classes in
> soot.toolkits.scalar, but I'm still unclear. Is there a way to do the
> analysis using the existing soot classes, or do the necessary classes
> need to be written from scratch (excluding classes like FlowSet, etc
> ofcourse)?
>
> Thanks,
> Leon
>
> --
> Leon Krupkin
> Polytechnic University
> lkrupk01@utopia.poly.edu
>