[Soot-list] My Forward Analysis crashes when there is a loop in function

Eric Bodden eric.bodden at mail.mcgill.ca
Wed Jul 30 22:17:32 EDT 2008


Hi Ahmad,

What do you mean by "crash"? A stack trace usually helps to identify
the problem.

Also you may prefer the default implementation in Soot that is known
to work quite well:
http://www.sable.mcgill.ca/soot/doc/soot/toolkits/scalar/SmartLocalDefs.html

Eric

2008/7/30 Ahmad Golzar <golzara at cs.man.ac.uk>:
> Hi,
>
> I have implemented "Reaching Definitions" analysis using the data-flow
> analysis framework in Soot. It works fine with functions that do not have
> any loops in them, but crashes with any function that contains a loop. Here
> is the code of the class. Have I done anything wrong?
>
>
>
> public class ReachingDefinitionsAnalysis extends ForwardFlowAnalysis
>
> {
>
>                 private FlowSet emptySet;
>
>
>
>                 public ReachingDefinitionsAnalysis(DirectedGraph<Unit> g) {
>
>                                 super(g);
>
>                                 emptySet = new ArraySparseSet();
>
>                                 doAnalysis();
>
>                 }
>
>
>
>                 @Override
>
>                 protected void merge(Object in1, Object in2, Object out) {
>
>                                 FlowSet inSet1 = (FlowSet)in1,
>
>                                                                 inSet2 =
> (FlowSet)in2,
>
>                                                                 outSet =
> (FlowSet)out;
>
>                                 inSet1.union(inSet2, outSet);
>
>                 }
>
>
>
>                 @Override
>
>                 protected void copy(Object source, Object dest) {
>
>                                 FlowSet srcSet = (FlowSet)source,
>
>                                                                 destSet =
> (FlowSet)dest;
>
>                                 srcSet.copy(destSet);
>
>                 }
>
>
>
>                 @Override
>
>                 protected Object newInitialFlow() {
>
>                                 return emptySet.clone();
>
>                 }
>
>
>
>                 @Override
>
>                 protected Object entryInitialFlow() {
>
>                                 return emptySet.clone();
>
>                 }
>
>
>
>                 @Override
>
>                 protected void flowThrough(Object in, Object node, Object
> out) {
>
>                                 FlowSet inSet = (FlowSet)in,
>
>                                                                 outSet =
> (FlowSet)out;
>
>                                 Unit u = (Unit)node;
>
>                                 kill(inSet, u, outSet);
>
>                                 gen(outSet, u);
>
>                 }
>
>
>
>                 private void kill(FlowSet inSet, Unit u, FlowSet outSet) {
>
>                                 FlowSet kills = (FlowSet)emptySet.clone();
>
>                                 Iterator<ValueBox> defIt =
> u.getDefBoxes().iterator();
>
>                                 while (defIt.hasNext()) {
>
>                                                 ValueBox defBox =
> defIt.next();
>
>
>
>                                                 if (defBox.getValue()
> instanceof Local) {
>
>
> Iterator<DependencyItem> inSetIt = inSet.iterator();
>
>                                                                 while
> (inSetIt.hasNext()) {
>
>
> DependencyItem e = inSetIt.next();
>
>
> Local local = e.getLocal();
>
>
> if (local.equivTo(defBox.getValue()))
>
>
> kills.add(e);
>
>                                                                 }
>
>                                                 }
>
>                                 }
>
>                                 inSet.difference(kills, outSet);
>
>                 }
>
>
>
>                 private void gen(FlowSet outSet, Unit u) {
>
>                                 Iterator<ValueBox> useIt =
> u.getDefBoxes().iterator();
>
>
>
>                                 while (useIt.hasNext()) {
>
>                                                 ValueBox useBox =
> useIt.next();
>
>                                                 if(useBox.getValue()
> instanceof Local)
>
>
> outSet.add(new DependencyItem(u, (Local)useBox.getValue()));
>
>                                 }
>
>                 }
>
> }
>
>
>
> public class DependencyItem
>
> {
>
>                 private Local local;
>
>                 private Unit unit;
>
>                 DependencyItem(Unit u, Local l)
>
>                 {
>
>                                 this.unit = u;
>
>                                 this.local = l;
>
>                 }
>
>
>
>                 public Local getLocal(){
>
>                                 return this.local;
>
>                 }
>
>
>
>                 public Unit getUnit()
>
>                 {
>
>                                 return this.unit;
>
>                 }
>
> }
>
>
>
> Thanks,
>
> Ahmad
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
>



-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada


More information about the Soot-list mailing list