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();
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
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.
FlatNode pn = fn.getPrev( i );
if( mapFlatNodeToReachGraph.containsKey( pn ) ) {
ReachGraph rgParent = mapFlatNodeToReachGraph.get( pn );
-// System.out.println("parent="+pn+"->"+rgParent);
rg.merge( rgParent );
}
}
) {
debugSnapshot( rg, fn, true );
}
-
+
// modify rg with appropriate transfer function
rg = analyzeFlatNode( d, fm, fn, setReturns, rg );
d.getSymbol().equals( descSymbolDebug )
) {
debugSnapshot( rg, fn, false );
+ ++snapNodeCounter;
}
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;
}
- // 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;
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 );
- }
}
}
private static boolean resolveMethodDebugDOThideSubsetReach = false;
private static boolean resolveMethodDebugDOThideEdgeTaints = true;
-
+ static String debugGraphPrefix;
+ static int debugCallSiteVisitsUntilExit = 0;
+
public void
resolveMethodCall( FlatCall fc,
) {
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,
if( writeDebugDOTs ) {
- writeGraph( "caller20BeforeWipe",
+ writeGraph( debugGraphPrefix+"caller20BeforeWipe",
resolveMethodDebugDOTwriteLabels,
resolveMethodDebugDOTselectTemps,
resolveMethodDebugDOTpruneGarbage,
if( writeDebugDOTs ) {
- writeGraph( "caller30BeforeAddingNodes",
+ writeGraph( debugGraphPrefix+"caller30BeforeAddingNodes",
resolveMethodDebugDOTwriteLabels,
resolveMethodDebugDOTselectTemps,
resolveMethodDebugDOTpruneGarbage,
if( writeDebugDOTs ) {
- writeGraph( "caller31BeforeAddingEdges",
+ writeGraph( debugGraphPrefix+"caller31BeforeAddingEdges",
resolveMethodDebugDOTwriteLabels,
resolveMethodDebugDOTselectTemps,
resolveMethodDebugDOTpruneGarbage,
if( writeDebugDOTs ) {
- writeGraph( "caller35BeforeAssignReturnValue",
+ writeGraph( debugGraphPrefix+"caller35BeforeAssignReturnValue",
resolveMethodDebugDOTwriteLabels,
resolveMethodDebugDOTselectTemps,
resolveMethodDebugDOTpruneGarbage,
if( writeDebugDOTs ) {
- writeGraph( "caller38propagateReach",
+ writeGraph( debugGraphPrefix+"caller38propagateReach",
resolveMethodDebugDOTwriteLabels,
resolveMethodDebugDOTselectTemps,
resolveMethodDebugDOTpruneGarbage,
if( writeDebugDOTs ) {
- writeGraph( "caller40BeforeShadowMerge",
+ writeGraph( debugGraphPrefix+"caller40BeforeShadowMerge",
resolveMethodDebugDOTwriteLabels,
resolveMethodDebugDOTselectTemps,
resolveMethodDebugDOTpruneGarbage,
if( writeDebugDOTs ) {
- writeGraph( "caller45BeforeUnshadow",
+ writeGraph( debugGraphPrefix+"caller45BeforeUnshadow",
resolveMethodDebugDOTwriteLabels,
resolveMethodDebugDOTselectTemps,
resolveMethodDebugDOTpruneGarbage,
if( writeDebugDOTs ) {
- writeGraph( "caller50BeforeGlobalSweep",
+ writeGraph( debugGraphPrefix+"caller50BeforeGlobalSweep",
resolveMethodDebugDOTwriteLabels,
resolveMethodDebugDOTselectTemps,
resolveMethodDebugDOTpruneGarbage,
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 );
+ }
}
}
public int OWNERSHIPDEBUGCALLCOUNT=0;
public String OWNERSHIPDEBUGCALLEE=null;
public String OWNERSHIPDEBUGCALLER=null;
+
public boolean DISJOINT=false;
public int DISJOINTALLOCDEPTH=3;
public boolean DISJOINTWRITEDOTS=false;
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;
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"))