From: bdemsky Date: Wed, 16 Mar 2011 19:14:06 +0000 (+0000) Subject: starting towards taints X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7c988f7d5469aacd280a38194643cfdc482558de;p=IRC.git starting towards taints --- diff --git a/Robust/src/Analysis/Disjoint/PointerMethod.java b/Robust/src/Analysis/Disjoint/PointerMethod.java index c3625e94..299a677f 100644 --- a/Robust/src/Analysis/Disjoint/PointerMethod.java +++ b/Robust/src/Analysis/Disjoint/PointerMethod.java @@ -98,6 +98,7 @@ public class PointerMethod { case FKind.FlatSESEEnterNode: case FKind.FlatSESEExitNode: case FKind.FlatGenReachNode: + case FKind.FlatExit: return true; case FKind.FlatCastNode: FlatCastNode fcn=(FlatCastNode)fn; diff --git a/Robust/src/Analysis/Disjoint/TaintSet.java b/Robust/src/Analysis/Disjoint/TaintSet.java index 4fda15a0..7e632b18 100644 --- a/Robust/src/Analysis/Disjoint/TaintSet.java +++ b/Robust/src/Analysis/Disjoint/TaintSet.java @@ -70,6 +70,20 @@ public class TaintSet extends Canonical { return out; } + public TaintSet add(Taint t) { + TaintSet newt=new TaintSet(); + newt.taints.addAll(taints); + newt.taints.add(t); + return (TaintSet) Canonical.makeCanonical(newt); + } + + public TaintSet merge(TaintSet ts) { + TaintSet newt=new TaintSet(); + newt.taints.addAll(taints); + newt.taints.addAll(ts.taints); + return (TaintSet) Canonical.makeCanonical(newt); + } + protected TaintSet() { taints = new HashSet(); } diff --git a/Robust/src/Analysis/Pointer/Edge.java b/Robust/src/Analysis/Pointer/Edge.java index 61fdbb42..94d50884 100644 --- a/Robust/src/Analysis/Pointer/Edge.java +++ b/Robust/src/Analysis/Pointer/Edge.java @@ -2,6 +2,8 @@ package Analysis.Pointer; import IR.Flat.*; import IR.*; import Analysis.Pointer.AllocFactory.AllocNode; +import Analysis.Disjoint.Taint; +import Analysis.Disjoint.TaintSet; public class Edge { FieldDescriptor fd; @@ -9,6 +11,8 @@ public class Edge { TempDescriptor srcvar; AllocNode dst; int statuspredicate; + TaintSet taints; + public static final int SNGSNG=1; public static final int SNGSUM=2; public static final int SUMSNG=4; @@ -67,6 +71,15 @@ public class Edge { return hashcode; } + public Edge addTaint(Taint t) { + Edge newe=copy(); + if (newe.taints==null) + newe.taints=TaintSet.factory(t); + else + newe.taints=newe.taints.add(t); + return newe; + } + public boolean equals(Object o) { if (o instanceof Edge) { Edge e=(Edge) o; @@ -86,6 +99,8 @@ public class Edge { e.srcvar=srcvar; e.dst=dst; e.statuspredicate=statuspredicate; + if (taints!=null) + e.taints=taints; return e; } @@ -94,6 +109,12 @@ public class Edge { return this; Edge newe=copy(); newe.statuspredicate=mergeStatus(statuspredicate, e.statuspredicate); + if (e.taints!=null) { + if (newe.taints==null) + newe.taints=e.taints; + else + newe.taints=newe.taints.merge(taints); + } return newe; } diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java index fcff4a50..60bed045 100644 --- a/Robust/src/Analysis/Pointer/Pointer.java +++ b/Robust/src/Analysis/Pointer/Pointer.java @@ -5,6 +5,7 @@ import IR.*; import Analysis.Liveness; import Analysis.Pointer.BasicBlock.BBlock; import Analysis.Pointer.AllocFactory.AllocNode; +import Analysis.Disjoint.Taint; import java.io.*; public class Pointer { @@ -130,7 +131,7 @@ public class Pointer { } //DEBUG - if (false) { + if (true) { int debugindex=0; for(Map.Entry e:bbgraphMap.entrySet()) { Graph g=e.getValue(); @@ -387,6 +388,28 @@ public class Pointer { } } + Delta processSESEEnter(FlatSESEEnterNode sese, Delta delta, Graph graph) { + for (TempDescriptor tmp:sese.getInVarSet()) { + Taint taint=Taint.factory(sese, null, tmp, null, sese, null); + if (delta.getInit()) { + MySet edges=GraphManip.getEdges(graph, delta, tmp); + for(Edge e:edges) { + Edge newe=e.addTaint(taint); + delta.addVarEdge(newe); + } + } else { + MySet edges=GraphManip.getDiffEdges(delta, tmp); + for(Edge e:edges) { + Edge newe=e.addTaint(taint); + delta.addVarEdge(newe); + } + } + } + applyDiffs(graph, delta); + return delta; + } + + /* This function compute the edges for the this variable for a * callee if it exists. */