From c51dcd99a356d9d83ca32d24284354d315eaafe2 Mon Sep 17 00:00:00 2001 From: jjenista Date: Thu, 24 Jun 2010 21:19:46 +0000 Subject: [PATCH] bug fix, now interprocedural seems cool, unitl the next bug HA --- Robust/src/Analysis/Disjoint/Canonical.java | 64 +++++++++++++++++++ Robust/src/Analysis/Disjoint/CanonicalOp.java | 2 + Robust/src/Analysis/Disjoint/ReachGraph.java | 3 +- .../src/Tests/disjoint/taintTest1/test.java | 19 +++--- 4 files changed, 79 insertions(+), 9 deletions(-) diff --git a/Robust/src/Analysis/Disjoint/Canonical.java b/Robust/src/Analysis/Disjoint/Canonical.java index 40bd77a1..4407e147 100644 --- a/Robust/src/Analysis/Disjoint/Canonical.java +++ b/Robust/src/Analysis/Disjoint/Canonical.java @@ -1443,4 +1443,68 @@ abstract public class Canonical { //op2result.put( op, out ); CRY CRY return out; } + + + public static Taint makePredsTrue( Taint t ) { + assert t != null; + assert t.isCanonical(); + + // ops require two canonicals, in this case always supply + // the empty reach state as the second, it's never used, + // but makes the hashing happy + CanonicalOp op = + new CanonicalOp( CanonicalOp.TAINT_MAKEPREDSTRUE, + t, + t ); + + Canonical result = op2result.get( op ); + if( result != null ) { + return (Taint) result; + } + + // otherwise, no cached result... + Taint out = new Taint( t.sese, + t.stallSite, + t.var, + t.allocSite, + ExistPredSet.factory( ExistPred.factory() ) + ); + + out = (Taint) makeCanonical( out ); + op2result.put( op, out ); + return out; + } + + + public static TaintSet makePredsTrue( TaintSet ts ) { + assert ts != null; + assert ts.isCanonical(); + + // ops require two canonicals, in this case always supply + // the empty reach set as the second, it's never used, + // but makes the hashing happy + CanonicalOp op = + new CanonicalOp( CanonicalOp.TAINTSET_MAKEPREDSTRUE, + ts, + TaintSet.factory() ); + + Canonical result = op2result.get( op ); + if( result != null ) { + return (TaintSet) result; + } + + // otherwise, no cached result... + TaintSet out = TaintSet.factory(); + Iterator itr = ts.iterator(); + while( itr.hasNext() ) { + Taint t = itr.next(); + out = Canonical.add( out, + Canonical.makePredsTrue( t ) + ); + } + + out = (TaintSet) makeCanonical( out ); + op2result.put( op, out ); + return out; + } } diff --git a/Robust/src/Analysis/Disjoint/CanonicalOp.java b/Robust/src/Analysis/Disjoint/CanonicalOp.java index 35afa5a9..81ad56d7 100644 --- a/Robust/src/Analysis/Disjoint/CanonicalOp.java +++ b/Robust/src/Analysis/Disjoint/CanonicalOp.java @@ -38,6 +38,8 @@ public class CanonicalOp { public static final int TAINTSET_ADD_TAINT = 0xcd17; public static final int TAINTSET_UNION_TAINTSET = 0xa835; public static final int TAINTSET_UNIONORPREDS_TAINTSET = 0x204f; + public static final int TAINT_MAKEPREDSTRUE = 0x3ab4; + public static final int TAINTSET_MAKEPREDSTRUE = 0x2ff1; protected int opCode; protected Canonical operand1; diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java index 7bcf7391..c2cab689 100644 --- a/Robust/src/Analysis/Disjoint/ReachGraph.java +++ b/Robust/src/Analysis/Disjoint/ReachGraph.java @@ -642,7 +642,7 @@ public class ReachGraph { ) ), predsTrue, - edgeY.getTaints() + Canonical.makePredsTrue( edgeY.getTaints() ) ); addEdgeOrMergeWithExisting( edgeNew ); @@ -686,6 +686,7 @@ public class ReachGraph { HeapRegionNode referencee = edgeX.getDst(); RefEdge edgeNew = edgeX.copy(); edgeNew.setSrc( lnR ); + edgeNew.setTaints( Canonical.makePredsTrue( edgeNew.getTaints() ) ); addRefEdge( lnR, referencee, edgeNew ); } diff --git a/Robust/src/Tests/disjoint/taintTest1/test.java b/Robust/src/Tests/disjoint/taintTest1/test.java index c079e86d..4ec6d2ab 100644 --- a/Robust/src/Tests/disjoint/taintTest1/test.java +++ b/Robust/src/Tests/disjoint/taintTest1/test.java @@ -9,34 +9,37 @@ public class Test { static public void main( String[] args ) { Foo a = new Foo(); + Foo b = new Foo(); + /* if( false ) { a = new Foo(); } + */ rblock r1 { a.f = new Foo(); - doSomething( a ); + + b.f = new Foo(); + + doSomething( a, b ); } } - static void doSomething( Foo a ) { + static void doSomething( Foo a, Foo b ) { a.g = new Foo(); a.f.f = a.g; - //Foo x = a.g; - - // Foo y = new Foo(); - // y.f = x; - - //Foo f = doStuff( a, c ); + Foo f = doStuff( a, b ); } static Foo doStuff( Foo m, Foo n ) { + m.f.g = n.f; + return new Foo(); } } -- 2.34.1