JPF ready to run with old infrastructure
authorSeyed Amir Hossein Aqajari <saqajari@circinus-5.ics.uci.edu>
Thu, 13 Feb 2020 21:39:36 +0000 (13:39 -0800)
committerSeyed Amir Hossein Aqajari <saqajari@circinus-5.ics.uci.edu>
Thu, 13 Feb 2020 21:39:36 +0000 (13:39 -0800)
src/main/gov/nasa/jpf/listener/ConflictTracker.java

index 3ec1eea1b9b9d466a0d9db55e5d001e97dbb3de4..fd7311715a21d1636c5d67972a8b47f2a4fef422 100644 (file)
@@ -49,9 +49,11 @@ public class ConflictTracker extends ListenerAdapter {
   private Node parentNode = new Node(-2);
   private String operation;
   private String detail;
+  private String errorMessage;
   private int depth;
   private int id;
   private boolean manual = false;
+  private boolean conflictFound = false;
 
   private final String SET_LOCATION_METHOD = "setLocationMode";
   private final String LOCATION_VAR = "locationMode";
@@ -132,7 +134,9 @@ public class ConflictTracker extends ListenerAdapter {
       if (confupdates != null && !u.isManual()) {
         for(Update u2: confupdates) {
           if (conflicts(u, u2)) {
-            throw new RuntimeException(createErrorMessage(u, u2));
+            //throw new RuntimeException(createErrorMessage(u, u2));
+            conflictFound = true;
+           errorMessage = createErrorMessage(u, u2);
           }
         }
       }
@@ -168,9 +172,9 @@ public class ConflictTracker extends ListenerAdapter {
   }
   
   String createErrorMessage(Update u, Update u2) {
-    String message = "Conflict found between the two apps. App"+u.getApp()+
+    String message = "Conflict found between the two apps. "+u.getApp()+
                     " has written the value: "+u.getValue()+
-      " to the attribute: "+u.getAttribute()+" while App"
+      " to the attribute: "+u.getAttribute()+" while "
       +u2.getApp()+" is writing the value: "
       +u2.getValue()+" to the same variable!";
     System.out.println(message);       
@@ -553,8 +557,13 @@ public class ConflictTracker extends ListenerAdapter {
         ti.setNextPC(nextIns);
       }
     }
-
-    if (conflictSet.contains(LOCATION_VAR)) {
+    
+    if (conflictFound) {
+      StringBuilder sb = new StringBuilder();
+      sb.append(errorMessage);
+      Instruction nextIns = ti.createAndThrowException("java.lang.RuntimeException", sb.toString());
+      ti.setNextPC(nextIns);
+    } else if (conflictSet.contains(LOCATION_VAR)) {
       MethodInfo mi = executedInsn.getMethodInfo();
       // Find the last load before return and get the value here
       if (mi.getName().equals(SET_LOCATION_METHOD) &&
@@ -572,19 +581,20 @@ public class ConflictTracker extends ListenerAdapter {
     } else {
       if (executedInsn instanceof WriteInstruction) {
         String varId = ((WriteInstruction) executedInsn).getFieldInfo().getFullName();
-        
+         
         for (String var : conflictSet) {
           if (varId.contains(var)) {
             // Get variable info
             byte type = getType(ti, executedInsn);
             String value = getValue(ti, executedInsn, type);
             String writer = getWriter(ti.getStack(), appSet);
+
             // Just return if the writer is not one of the listed apps in the .jpf file
             if (writer == null)
               return;
             
-            if (getWriter(ti.getStack(), manualSet) != null)
-              manual = true;
+            //if (getWriter(ti.getStack(), manualSet) != null)
+            //  manual = true;
             
             // Update the current updates
             writeWriterAndValue(writer, var, value);