From: jjenista Date: Sat, 14 May 2011 00:33:14 +0000 (+0000) Subject: print allocation site when a points-to check fails to try and see what it should be X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=073c54e79f6e530f6286f018df41a19980b04ae1;p=IRC.git print allocation site when a points-to check fails to try and see what it should be --- diff --git a/Robust/src/IR/Flat/BCXPointsToCheckVRuntime.java b/Robust/src/IR/Flat/BCXPointsToCheckVRuntime.java index 3f658db5..2ab300ac 100644 --- a/Robust/src/IR/Flat/BCXPointsToCheckVRuntime.java +++ b/Robust/src/IR/Flat/BCXPointsToCheckVRuntime.java @@ -17,12 +17,17 @@ import java.util.*; public class BCXPointsToCheckVRuntime implements BuildCodeExtension { protected BuildCode buildCode; + protected TypeUtil typeUtil; protected HeapAnalysis heapAnalysis; + protected ClassDescriptor cdObject; + public BCXPointsToCheckVRuntime( BuildCode buildCode, + TypeUtil typeUtil, HeapAnalysis heapAnalysis ) { this.buildCode = buildCode; + this.typeUtil = typeUtil; this.heapAnalysis = heapAnalysis; } @@ -197,9 +202,20 @@ public class BCXPointsToCheckVRuntime implements BuildCodeExtension { protected void printConditionFailed( PrintWriter output, - String condition ) { + String condition, + String pointer ) { + + // don't do this in the constructor of this extension object because + // build code hasn't created any types or classes yet! + if( cdObject == null ) { + cdObject = typeUtil.getClass( typeUtil.ObjectClass ); + assert cdObject != null; + } + output.println( "printf(\"[[[ CHECK VS HEAP RESULTS FAILED ]]] Condition for failure( "+ - condition+" ) at %s:%d\\n\", __FILE__, __LINE__ );" ); + condition+" ) allocsite=%d at %s:%d\\n\", ((struct "+ + cdObject.getSafeSymbol()+"*)"+ + pointer+")->allocsite, __FILE__, __LINE__ );" ); } @@ -213,7 +229,6 @@ public class BCXPointsToCheckVRuntime implements BuildCodeExtension { assert targetsByAnalysis != null; - output.println( "" ); output.println( "// checks vs. heap results (DEBUG) for "+x ); @@ -223,26 +238,20 @@ public class BCXPointsToCheckVRuntime implements BuildCodeExtension { return; } + String ptr = buildCode.generateTemp( context, x ); String condition; if( targetsByAnalysis.isEmpty() ) { - condition = - buildCode.generateTemp( context, x )+ - " != NULL"; + condition = ptr+" != NULL"; } else { - condition = - buildCode.generateTemp( context, x )+ - " != NULL &&"; + condition = ptr+" != NULL &&"; Iterator aItr = targetsByAnalysis.iterator(); while( aItr.hasNext() ) { Alloc a = aItr.next(); - condition += - buildCode.generateTemp( context, x )+ - "->allocsite != "+ - a.getUniqueAllocSiteID(); + condition += ptr+"->allocsite != "+a.getUniqueAllocSiteID(); if( aItr.hasNext() ) { condition += " &&"; @@ -251,7 +260,7 @@ public class BCXPointsToCheckVRuntime implements BuildCodeExtension { } output.println( "if( "+condition+" ) {" ); - printConditionFailed( output, condition ); + printConditionFailed( output, condition, ptr ); output.println( "}\n" ); } @@ -351,7 +360,7 @@ public class BCXPointsToCheckVRuntime implements BuildCodeExtension { } output.println( "if( "+condition+" ) {" ); - printConditionFailed( output, condition ); + printConditionFailed( output, condition, "objOneHop" ); output.println( "}" ); } diff --git a/Robust/src/IR/Flat/BCXallocsiteObjectField.java b/Robust/src/IR/Flat/BCXallocsiteObjectField.java index ee8dc81c..3d33ad25 100644 --- a/Robust/src/IR/Flat/BCXallocsiteObjectField.java +++ b/Robust/src/IR/Flat/BCXallocsiteObjectField.java @@ -20,6 +20,9 @@ public class BCXallocsiteObjectField implements BuildCodeExtension { protected TypeUtil typeUtil; protected HeapAnalysis heapAnalysis; + protected ClassDescriptor cdString; + protected FieldDescriptor argBytes; + public BCXallocsiteObjectField( BuildCode buildCode, TypeUtil typeUtil, @@ -37,10 +40,10 @@ public class BCXallocsiteObjectField implements BuildCodeExtension { public void additionalCodeForCommandLineArgs(PrintWriter outmethod, String argsVar) { - ClassDescriptor cdString = typeUtil.getClass( typeUtil.StringClass ); + cdString = typeUtil.getClass( typeUtil.StringClass ); assert cdString != null; - FieldDescriptor argBytes = null; + argBytes = null; Iterator sFieldsItr = cdString.getFields(); while( sFieldsItr.hasNext() ) { FieldDescriptor fd = (FieldDescriptor) sFieldsItr.next(); @@ -51,6 +54,7 @@ public class BCXallocsiteObjectField implements BuildCodeExtension { } assert argBytes != null; + String argsAccess = "((struct "+cdString.getSafeSymbol()+ " **)(((char *)& "+argsVar+"->___length___)+sizeof(int)))"; diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index 63e5888b..0bb5c21a 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -678,7 +678,7 @@ public class Main { if( state.POINTSTO_CHECK_V_RUNTIME && heapAnalysis != null ) { - BCXPointsToCheckVRuntime bcx = new BCXPointsToCheckVRuntime( bc, heapAnalysis ); + BCXPointsToCheckVRuntime bcx = new BCXPointsToCheckVRuntime( bc, tu, heapAnalysis ); bc.registerExtension( bcx ); }