Add some minor changes to the listener to make the error message more clean! aj_branch
authoramiraj <amiraj.95@uci.edu>
Thu, 17 Oct 2019 18:40:45 +0000 (11:40 -0700)
committeramiraj <amiraj.95@uci.edu>
Thu, 17 Oct 2019 18:40:45 +0000 (11:40 -0700)
src/main/gov/nasa/jpf/listener/ConflictTracker.java

index adbab197d443a24af07bb9c58004a3b0795e241a..9fb12cf3dac2aa6a4769468a7966edf7a7d5e710 100644 (file)
@@ -49,6 +49,7 @@ 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 conflictFound = false;
@@ -145,7 +146,7 @@ public class ConflictTracker extends ListenerAdapter {
 
        for (NameValuePair i : currentNode.getSetSet()) {
                if (i.getIsManual()) // Manual input: we have no conflict
-                       return false;
+                       continue;
 
                valueMap.put(i.getVarName(), i.getValue());
                if (writerMap.containsKey(i.getVarName()))
@@ -157,9 +158,13 @@ public class ConflictTracker extends ListenerAdapter {
        // Comparing the inSet and setSet to find the conflict
        for (NameValuePair i : currentNode.getInSet()) {
                if (valueMap.containsKey(i.getVarName())) {
-                       if (!(valueMap.get(i.getVarName()).equals(i.getValue())))
-                               if (!(writerMap.get(i.getVarName()).equals(i.getAppNum())))
+                       if (!(valueMap.get(i.getVarName()).equals(i.getValue()))) // We have different values
+                               if (!(writerMap.get(i.getVarName()).equals(i.getAppNum()))) {// We have different writers
+                                       errorMessage = "Conflict found between the two apps. App"+i.getAppNum()+" has written the value: "+i.getValue()+
+                                                       " to the variable: "+i.getVarName()+" while App"+writerMap.get(i.getVarName())+" is overwriting the value: "
+                                                       +valueMap.get(i.getVarName())+" to the same variable!";
                                        return true;
+                               }
                }
        }
 
@@ -541,7 +546,7 @@ public class ConflictTracker extends ListenerAdapter {
 
     if (conflictFound) {
       StringBuilder sb = new StringBuilder();
-      sb.append("Conflict found between two apps!");
+      sb.append(errorMessage);
       Instruction nextIns = ti.createAndThrowException("java.lang.RuntimeException", sb.toString());
       ti.setNextPC(nextIns);
     } else if (executedInsn instanceof WriteInstruction) {