Fixing bug due to refactoring/moving of code in the previous commit to handle apps...
authorrtrimana <rtrimana@uci.edu>
Tue, 19 Jan 2021 18:22:39 +0000 (10:22 -0800)
committerrtrimana <rtrimana@uci.edu>
Tue, 19 Jan 2021 18:22:39 +0000 (10:22 -0800)
src/main/gov/nasa/jpf/listener/DPORStateReducerWithSummary.java

index cfc70678086df38f980d793e691aeb9b06831926..2bc18a9f83a5e0210a577be66959cec9bd9294f8 100755 (executable)
@@ -190,44 +190,43 @@ public class DPORStateReducerWithSummary extends ListenerAdapter {
 
   @Override
   public void choiceGeneratorRegistered(VM vm, ChoiceGenerator<?> nextCG, ThreadInfo currentThread, Instruction executedInstruction) {
+    if (isNotCheckedForEventsYet) {
+      // Check if this benchmark has no events
+      if (nextCG instanceof IntChoiceFromSet) {
+        IntChoiceFromSet icsCG = (IntChoiceFromSet) nextCG;
+        Integer[] cgChoices = icsCG.getAllChoices();
+        if (cgChoices.length == 2 && cgChoices[0] == 0 && cgChoices[1] == -1) {
+          // This means the benchmark only has 2 choices, i.e., 0 and -1 which means that it has no events
+          stateReductionMode = false;
+        }
+        isNotCheckedForEventsYet = false;
+      }
+    }
     if (stateReductionMode) {
-      if (isNotCheckedForEventsYet) {
-        // Check if this benchmark has no events
-        if (nextCG instanceof IntChoiceFromSet) {
-          IntChoiceFromSet icsCG = (IntChoiceFromSet) nextCG;
+      // Initialize with necessary information from the CG
+      if (nextCG instanceof IntChoiceFromSet) {
+        IntChoiceFromSet icsCG = (IntChoiceFromSet) nextCG;
+        // Tell JPF that we are performing DPOR
+        icsCG.setDpor();
+        if (!isEndOfExecution) {
+          // Check if CG has been initialized, otherwise initialize it
           Integer[] cgChoices = icsCG.getAllChoices();
-          if (cgChoices.length == 2 && cgChoices[0] == 0 && cgChoices[1] == -1) {
-            // This means the benchmark only has 2 choices, i.e., 0 and -1 which means that it has no events
-            stateReductionMode = false;
-          }
-          isNotCheckedForEventsYet = false;
-        }
-      } else {
-        // Initialize with necessary information from the CG
-        if (nextCG instanceof IntChoiceFromSet) {
-          IntChoiceFromSet icsCG = (IntChoiceFromSet) nextCG;
-          // Tell JPF that we are performing DPOR
-          icsCG.setDpor();
-          if (!isEndOfExecution) {
-            // Check if CG has been initialized, otherwise initialize it
-            Integer[] cgChoices = icsCG.getAllChoices();
-            // Record the events (from choices)
-            if (choices == null) {
-              choices = cgChoices;
-              // Make a copy of choices as reference
-              refChoices = copyChoices(choices);
-              // Record the max event choice (the last element of the choice array)
-              maxEventChoice = choices[choices.length - 1];
-            }
-            icsCG.setNewValues(choices);
-            icsCG.reset();
-            // Use a modulo since choiceCounter is going to keep increasing
-            int choiceIndex = choiceCounter % choices.length;
-            icsCG.advance(choices[choiceIndex]);
-          } else {
-            // Set done all CGs while transitioning to a new execution
-            icsCG.setDone();
+          // Record the events (from choices)
+          if (choices == null) {
+            choices = cgChoices;
+            // Make a copy of choices as reference
+            refChoices = copyChoices(choices);
+            // Record the max event choice (the last element of the choice array)
+            maxEventChoice = choices[choices.length - 1];
           }
+          icsCG.setNewValues(choices);
+          icsCG.reset();
+          // Use a modulo since choiceCounter is going to keep increasing
+          int choiceIndex = choiceCounter % choices.length;
+          icsCG.advance(choices[choiceIndex]);
+        } else {
+          // Set done all CGs while transitioning to a new execution
+          icsCG.setDone();
         }
       }
     }