print allocation site when a points-to check fails to try and see what it should be
authorjjenista <jjenista>
Sat, 14 May 2011 00:33:14 +0000 (00:33 +0000)
committerjjenista <jjenista>
Sat, 14 May 2011 00:33:14 +0000 (00:33 +0000)
Robust/src/IR/Flat/BCXPointsToCheckVRuntime.java
Robust/src/IR/Flat/BCXallocsiteObjectField.java
Robust/src/Main/Main.java

index 3f658db523d51c01f4fd0b551595db025185f1f2..2ab300ac36d27a0d3a2656fd12a1f5cc8263d8fb 100644 (file)
@@ -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<Alloc> 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( "}" );
         }
         
index ee8dc81cba627c8c1545aa55ae4534936758661d..3d33ad25afb2dd2d9ae71ee86e7720a6800612aa 100644 (file)
@@ -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)))";
     
index 63e5888bc7356588d41fe44c0d5f72b88fefee51..0bb5c21a4dd297534f14d9eec21af89b6b60f5bf 100644 (file)
@@ -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 );
       }