improved debug graph capture
authorjjenista <jjenista>
Wed, 24 Mar 2010 22:18:13 +0000 (22:18 +0000)
committerjjenista <jjenista>
Wed, 24 Mar 2010 22:18:13 +0000 (22:18 +0000)
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Analysis/Disjoint/ReachGraph.java
Robust/src/IR/State.java
Robust/src/Main/Main.java

index 253cd78cf60e99aa208c32473e26025768c22359..d8faa20cbf7a1d344fa5320500f44809b370208b 100644 (file)
@@ -497,13 +497,24 @@ public class DisjointAnalysis {
     this.liveness                = liveness;
     this.arrayReferencees        = arrayReferencees;
     this.allocationDepth         = state.DISJOINTALLOCDEPTH;
+
     this.writeFinalDOTs          = state.DISJOINTWRITEDOTS && !state.DISJOINTWRITEALL;
     this.writeAllIncrementalDOTs = state.DISJOINTWRITEDOTS &&  state.DISJOINTWRITEALL;
+
+    this.takeDebugSnapshots      = state.DISJOINTSNAPSYMBOL != null;
+    this.descSymbolDebug         = state.DISJOINTSNAPSYMBOL;
+    this.visitStartCapture       = state.DISJOINTSNAPVISITTOSTART;
+    this.numVisitsToCapture      = state.DISJOINTSNAPNUMVISITS;
+    this.stopAfterCapture        = state.DISJOINTSNAPSTOPAFTER;
+    this.snapVisitCounter        = 1; // count visits from 1 (user will write 1, means 1st visit)
+    this.snapNodeCounter         = 0; // count nodes from 0
            
     // set some static configuration for ReachGraphs
     ReachGraph.allocationDepth = allocationDepth;
     ReachGraph.typeUtil        = typeUtil;
 
+    ReachGraph.debugCallSiteVisitsUntilExit = state.DISJOINTDEBUGCALLCOUNT;
+
     allocateStructures();
 
     double timeStartAnalysis = (double) System.nanoTime();
@@ -619,14 +630,6 @@ public class DisjointAnalysis {
       
       if( !rg.equals( rgPrev ) ) {
         setPartial( d, rg );
-
-        /*
-        if( d.getSymbol().equals( "getInterpolatePatch" ) ) {
-          ReachGraph.dbgEquals = true;
-          rg.equals( rgPrev );
-          ReachGraph.dbgEquals = false;
-        }
-        */
         
         // results for d changed, so enqueue dependents
         // of d for further analysis
@@ -666,8 +669,6 @@ public class DisjointAnalysis {
       FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next();
       flatNodesToVisit.remove( fn );
 
-      //System.out.println( "  "+fn );
-
       // effect transfer function defined by this node,
       // then compare it to the old graph at this node
       // to see if anything was updated.
@@ -691,7 +692,6 @@ public class DisjointAnalysis {
        FlatNode pn = fn.getPrev( i );
        if( mapFlatNodeToReachGraph.containsKey( pn ) ) {
          ReachGraph rgParent = mapFlatNodeToReachGraph.get( pn );
-//       System.out.println("parent="+pn+"->"+rgParent);
          rg.merge( rgParent );
        }
       }
@@ -702,7 +702,7 @@ public class DisjointAnalysis {
           ) {
        debugSnapshot( rg, fn, true );
       }
+
 
       // modify rg with appropriate transfer function
       rg = analyzeFlatNode( d, fm, fn, setReturns, rg );
@@ -712,6 +712,7 @@ public class DisjointAnalysis {
          d.getSymbol().equals( descSymbolDebug ) 
           ) {
        debugSnapshot( rg, fn, false );
+        ++snapNodeCounter;
       }
           
 
@@ -744,6 +745,26 @@ public class DisjointAnalysis {
 
       completeGraph.merge( rgRet );
     }
+
+
+    if( takeDebugSnapshots && 
+        d.getSymbol().equals( descSymbolDebug ) 
+        ) {
+      // increment that we've visited the debug snap
+      // method, and reset the node counter
+      System.out.println( "    @@@ debug snap at visit "+snapVisitCounter );
+      ++snapVisitCounter;
+      snapNodeCounter = 0;
+
+      if( snapVisitCounter == visitStartCapture + numVisitsToCapture && 
+          stopAfterCapture 
+          ) {
+        System.out.println( "!!! Stopping analysis after debug snap captures. !!!" );
+        System.exit( 0 );
+      }
+    }
+
+
     return completeGraph;
   }
 
@@ -1833,57 +1854,39 @@ getFlaggedAllocationSitesReachableFromTaskPRIVATE(TaskDescriptor td) {
 
   
   
-  // get successive captures of the analysis state
-  boolean takeDebugSnapshots = true;
-  String descSymbolDebug = "calcGoodFeature";
-  boolean stopAfterCapture = false;
-
-  // increments every visit to debugSnapshot, don't fiddle with it
-  int debugCounter = 0;
-
-  // the value of debugCounter to start reporting the debugCounter
-  // to the screen to let user know what debug iteration we're at
-  int numStartCountReport = 0;
-
-  // the frequency of debugCounter values to print out, 0 no report
-  int freqCountReport = 0;
-
-  // the debugCounter value at which to start taking snapshots
-  int iterStartCapture = 0;
-
-  // the number of snapshots to take
-  int numIterToCapture = 4000;
+  // get successive captures of the analysis state, use compiler
+  // flags to control
+  boolean takeDebugSnapshots = false;
+  String  descSymbolDebug    = null;
+  boolean stopAfterCapture   = false;
+  int     snapVisitCounter   = 0;
+  int     snapNodeCounter    = 0;
+  int     visitStartCapture  = 0;
+  int     numVisitsToCapture = 0;
 
 
   void debugSnapshot( ReachGraph rg, FlatNode fn, boolean in ) {
-    if( debugCounter > iterStartCapture + numIterToCapture ) {
+    if( snapVisitCounter > visitStartCapture + numVisitsToCapture ) {
       return;
     }
 
     if( in ) {
-      ++debugCounter;
-    }
 
-    if( debugCounter    > numStartCountReport &&
-       freqCountReport > 0                   &&
-        debugCounter % freqCountReport == 0   &&
-        in
-        ) {
-      System.out.println( "    @@@ debug counter = "+
-                          debugCounter );
     }
 
-    if( debugCounter > iterStartCapture ) {
-      System.out.println( "    @@@ capturing debug "+
-                          (debugCounter /*- iterStartCapture*/)+
+    if( snapVisitCounter >= visitStartCapture ) {
+      System.out.println( "    @@@ snapping visit="+snapVisitCounter+
+                          ", node="+snapNodeCounter+
                           " @@@" );
       String graphName;
       if( in ) {
-        graphName = String.format( "snap%04din",
-                                   debugCounter ); //- iterStartCapture );
+        graphName = String.format( "snap%02d_%04din",
+                                   snapVisitCounter,
+                                   snapNodeCounter );
       } else {
-        graphName = String.format( "snap%04dout",
-                                   debugCounter ); //- iterStartCapture );
+        graphName = String.format( "snap%02d_%04dout",
+                                   snapVisitCounter,
+                                   snapNodeCounter );
       }
       if( fn != null ) {
        graphName = graphName + fn;
@@ -1895,13 +1898,6 @@ getFlaggedAllocationSitesReachableFromTaskPRIVATE(TaskDescriptor td) {
                      false, // hide subset reachability states
                      true );// hide edge taints
     }
-
-    if( debugCounter == iterStartCapture + numIterToCapture && 
-        stopAfterCapture 
-        ) {
-      System.out.println( "Stopping analysis after debug captures." );
-      System.exit( 0 );
-    }
   }
 
 }
index e266145993179b5dd26741fcf1d64236ac36bd8f..9adbdad45f44a89554b5a4ba24adb7aacd4462ef 100644 (file)
@@ -1915,7 +1915,9 @@ public class ReachGraph {
   private static boolean resolveMethodDebugDOThideSubsetReach = false;
   private static boolean resolveMethodDebugDOThideEdgeTaints  = true;
 
-
+  static String debugGraphPrefix;
+  static int debugCallSiteVisitsUntilExit = 0;
+  
 
   public void 
     resolveMethodCall( FlatCall     fc,        
@@ -1926,14 +1928,16 @@ public class ReachGraph {
                        ) {
 
     if( writeDebugDOTs ) {
-      rgCallee.writeGraph( "callee", 
+      debugGraphPrefix = String.format( "call%02d", debugCallSiteVisitsUntilExit );
+      
+      rgCallee.writeGraph( debugGraphPrefix+"callee", 
                            resolveMethodDebugDOTwriteLabels,    
                            resolveMethodDebugDOTselectTemps,    
                            resolveMethodDebugDOTpruneGarbage,   
                            resolveMethodDebugDOThideSubsetReach,
                            resolveMethodDebugDOThideEdgeTaints );
       
-      writeGraph( "caller00In",  
+      writeGraph( debugGraphPrefix+"caller00In",  
                   resolveMethodDebugDOTwriteLabels,    
                   resolveMethodDebugDOTselectTemps,    
                   resolveMethodDebugDOTpruneGarbage,   
@@ -2169,7 +2173,7 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      writeGraph( "caller20BeforeWipe", 
+      writeGraph( debugGraphPrefix+"caller20BeforeWipe", 
                   resolveMethodDebugDOTwriteLabels,    
                   resolveMethodDebugDOTselectTemps,    
                   resolveMethodDebugDOTpruneGarbage,   
@@ -2193,7 +2197,7 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      writeGraph( "caller30BeforeAddingNodes", 
+      writeGraph( debugGraphPrefix+"caller30BeforeAddingNodes", 
                   resolveMethodDebugDOTwriteLabels,    
                   resolveMethodDebugDOTselectTemps,    
                   resolveMethodDebugDOTpruneGarbage,   
@@ -2260,7 +2264,7 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      writeGraph( "caller31BeforeAddingEdges", 
+      writeGraph( debugGraphPrefix+"caller31BeforeAddingEdges", 
                   resolveMethodDebugDOTwriteLabels,    
                   resolveMethodDebugDOTselectTemps,    
                   resolveMethodDebugDOTpruneGarbage,   
@@ -2460,7 +2464,7 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      writeGraph( "caller35BeforeAssignReturnValue", 
+      writeGraph( debugGraphPrefix+"caller35BeforeAssignReturnValue", 
                   resolveMethodDebugDOTwriteLabels,    
                   resolveMethodDebugDOTselectTemps,    
                   resolveMethodDebugDOTpruneGarbage,   
@@ -2544,7 +2548,7 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      writeGraph( "caller38propagateReach", 
+      writeGraph( debugGraphPrefix+"caller38propagateReach", 
                   resolveMethodDebugDOTwriteLabels,    
                   resolveMethodDebugDOTselectTemps,    
                   resolveMethodDebugDOTpruneGarbage,   
@@ -2572,7 +2576,7 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      writeGraph( "caller40BeforeShadowMerge", 
+      writeGraph( debugGraphPrefix+"caller40BeforeShadowMerge", 
                   resolveMethodDebugDOTwriteLabels,    
                   resolveMethodDebugDOTselectTemps,    
                   resolveMethodDebugDOTpruneGarbage,   
@@ -2671,7 +2675,7 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      writeGraph( "caller45BeforeUnshadow", 
+      writeGraph( debugGraphPrefix+"caller45BeforeUnshadow", 
                   resolveMethodDebugDOTwriteLabels,    
                   resolveMethodDebugDOTselectTemps,    
                   resolveMethodDebugDOTpruneGarbage,   
@@ -2697,7 +2701,7 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      writeGraph( "caller50BeforeGlobalSweep", 
+      writeGraph( debugGraphPrefix+"caller50BeforeGlobalSweep", 
                   resolveMethodDebugDOTwriteLabels,    
                   resolveMethodDebugDOTselectTemps,    
                   resolveMethodDebugDOTpruneGarbage,   
@@ -2714,12 +2718,18 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      writeGraph( "caller90AfterTransfer", 
+      writeGraph( debugGraphPrefix+"caller90AfterTransfer", 
                   resolveMethodDebugDOTwriteLabels,    
                   resolveMethodDebugDOTselectTemps,    
                   resolveMethodDebugDOTpruneGarbage,   
                   resolveMethodDebugDOThideSubsetReach,
                   resolveMethodDebugDOThideEdgeTaints );
+
+      --debugCallSiteVisitsUntilExit;
+      if( debugCallSiteVisitsUntilExit <= 0 ) {
+        System.out.println( "!!! Exiting after requested visits to call site. !!!" );
+        System.exit( 0 );
+      }
     }
   } 
 
index 004e56120f8725a9a7e5d497d970c8d90257e993..1183d77c60279758cb530e3723b314ec3c236060 100644 (file)
@@ -69,6 +69,7 @@ public class State {
   public int OWNERSHIPDEBUGCALLCOUNT=0;
   public String OWNERSHIPDEBUGCALLEE=null;
   public String OWNERSHIPDEBUGCALLER=null;
+  
   public boolean DISJOINT=false;
   public int DISJOINTALLOCDEPTH=3;
   public boolean DISJOINTWRITEDOTS=false;
@@ -79,6 +80,11 @@ public class State {
   public int DISJOINTDEBUGCALLCOUNT=0;
   public String DISJOINTDEBUGCALLEE=null;
   public String DISJOINTDEBUGCALLER=null;
+  public String DISJOINTSNAPSYMBOL=null;
+  public int DISJOINTSNAPVISITTOSTART=0;
+  public int DISJOINTSNAPNUMVISITS=0;
+  public boolean DISJOINTSNAPSTOPAFTER=false;
+
   public boolean OPTIONAL=false;
   public boolean ARRAYBOUNDARYCHECK=true;
   public boolean RAW=false;
index d51883f4703d2441d07efccdbeab78efc4ce50e6..03fff64b13144aaf19c92cda51da98251fb3fe88 100644 (file)
@@ -201,6 +201,19 @@ public class Main {
        state.DISJOINTDEBUGCALLEE=args[++i];
        state.DISJOINTDEBUGCALLER=args[++i];
        state.DISJOINTDEBUGCALLCOUNT=Integer.parseInt(args[++i]);
+      
+      } else if (option.equals("-disjoint-debug-snap-method")) {
+       state.DISJOINTSNAPSYMBOL=args[++i];
+        state.DISJOINTSNAPVISITTOSTART=Integer.parseInt(args[++i]);
+       state.DISJOINTSNAPNUMVISITS=Integer.parseInt(args[++i]);
+        String arg = args[++i];
+       if( arg.equals("true") ) {
+         state.DISJOINTSNAPSTOPAFTER = true;
+       } else if( arg.equals("false") ) {
+          state.DISJOINTSNAPSTOPAFTER = false;
+        } else {
+          throw new Error("disjoint-debug-snap-method requires arguments <method symbol> <# visit to start> <# visits to snap> <T/F stop after>");
+        }
       }
 
       else if (option.equals("-optional"))