private HashSet<ClassInfo> nonRelevantClasses;// Class info objects of non-relevant classes
private HashSet<FieldInfo> nonRelevantFields; // Field info objects of non-relevant fields
private HashSet<FieldInfo> relevantFields; // Field info objects of relevant fields
- private HashMap<Integer, HashSet<Integer>> stateToEventMap;
+ private HashMap<Integer, HashSet<Integer>> stateToEventMap; // Map state ID to events
// Data structure to analyze field Read/Write accesses and conflicts
private HashMap<Integer, LinkedList<BacktrackExecution>> backtrackMap; // Track created backtracking points
private PriorityQueue<Integer> backtrackStateQ; // Heap that returns the latest state
// Statistics
private int numOfTransitions;
- private int numOfUniqueTransitions;
+ private HashMap<Integer, HashSet<Integer>> stateToUniqueEventMap;
public DPORStateReducerWithSummary(Config config, JPF jpf) {
verboseMode = config.getBoolean("printout_state_transition", false);
isNotCheckedForEventsYet = true;
mainSummary = new MainSummary();
numOfTransitions = 0;
- numOfUniqueTransitions = 0;
nonRelevantClasses = new HashSet<>();
nonRelevantFields = new HashSet<>();
relevantFields = new HashSet<>();
restorableStateMap = new HashMap<>();
stateToPredInfo = new HashMap<>();
+ stateToUniqueEventMap = new HashMap<>();
initializeStatesVariables();
}
out.println("\n==> DEBUG: ----------------------------------- search finished");
out.println("\n==> DEBUG: State reduction mode : " + stateReductionMode);
out.println("\n==> DEBUG: Number of transitions : " + numOfTransitions);
- out.println("\n==> DEBUG: Number of unique transitions (DPOR) : " + numOfUniqueTransitions);
+ out.println("\n==> DEBUG: Number of unique transitions (DPOR) : " + summarizeUniqueStateIds());
out.println("\n==> DEBUG: ----------------------------------- search finished" + "\n");
fileWriter.println("==> DEBUG: State reduction mode : " + stateReductionMode);
fileWriter.println("==> DEBUG: Number of transitions : " + numOfTransitions);
- fileWriter.println("==> DEBUG: Number of unique transitions : " + numOfUniqueTransitions);
+ fileWriter.println("==> DEBUG: Number of unique transitions : " + summarizeUniqueStateIds());
fileWriter.println();
fileWriter.close();
}
exploreNextBacktrackPoints(vm, icsCG);
} else {
numOfTransitions++;
- if (choiceCounter < choices.length) {
- numOfUniqueTransitions++;
- }
+ countUniqueStateId(vm.getStateId(), icsCG.getNextChoice());
}
// Map state to event
mapStateToEvent(icsCG.getNextChoice());
choiceCounter++;
}
} else {
- if (currentCG instanceof IntChoiceFromSet) {
- numOfTransitions++;
- }
+ numOfTransitions++;
+ }
+ }
+
+ // Count unique state IDs
+ private void countUniqueStateId(int stateId, int nextChoiceValue) {
+ HashSet<Integer> events;
+ // Get the set of events
+ if (!stateToUniqueEventMap.containsKey(stateId)) {
+ events = new HashSet<>();
+ stateToUniqueEventMap.put(stateId, events);
+ } else {
+ events = stateToUniqueEventMap.get(stateId);
}
+ // Insert the event
+ if (!events.contains(nextChoiceValue)) {
+ events.add(nextChoiceValue);
+ }
+ }
+
+ // Summarize unique state IDs
+ private int summarizeUniqueStateIds() {
+ // Just count the set size of each of entry map and sum them up
+ int numOfUniqueTransitions = 0;
+ for (Map.Entry<Integer,HashSet<Integer>> entry : stateToUniqueEventMap.entrySet()) {
+ numOfUniqueTransitions = numOfUniqueTransitions + entry.getValue().size();
+ }
+ // We also need to count root and boolean CG if this is in state reduction mode (DPOR)
+ if (stateReductionMode) {
+ numOfUniqueTransitions = numOfUniqueTransitions + 3;
+ }
+
+ return numOfUniqueTransitions;
}
@Override