From: rtrimana Date: Mon, 23 Mar 2020 21:56:29 +0000 (-0700) Subject: Cleaning up: Removing the full-blown graph traversal. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=jpf-core.git;a=commitdiff_plain;h=81daeefff026caeb076584f572dd095b7cc0a652;ds=sidebyside Cleaning up: Removing the full-blown graph traversal. --- diff --git a/src/main/gov/nasa/jpf/listener/ConflictTracker.java b/src/main/gov/nasa/jpf/listener/ConflictTracker.java index 791a7da..b426d26 100644 --- a/src/main/gov/nasa/jpf/listener/ConflictTracker.java +++ b/src/main/gov/nasa/jpf/listener/ConflictTracker.java @@ -38,10 +38,9 @@ import java.util.*; **/ public class ConflictTracker extends ListenerAdapter { - // Public graph: to allow the StateReducer class to access it - public static final HashMap nodes = new HashMap(); // Nodes of a graph - // Private + private final PrintWriter out; + private final HashMap nodes = new HashMap(); // Nodes of a graph private final HashSet conflictSet = new HashSet(); // Variables we want to track private final HashSet appSet = new HashSet(); // Apps we want to find their conflicts private final HashSet manualSet = new HashSet(); // Writer classes with manual inputs to detect direct-direct(No Conflict) interactions diff --git a/src/main/gov/nasa/jpf/listener/StateReducer.java b/src/main/gov/nasa/jpf/listener/StateReducer.java index 96d49a3..0a27b5c 100644 --- a/src/main/gov/nasa/jpf/listener/StateReducer.java +++ b/src/main/gov/nasa/jpf/listener/StateReducer.java @@ -89,8 +89,6 @@ public class StateReducer extends ListenerAdapter { // HashSet that stores references to unused CGs private HashSet unusedCG; - // Reference to the state graph in the ConflictTracker class - // TODO: The following is a full-blown graph traversal that we can do if we need to in the future //private HashMap stateGraph; private HashMap> stateToEventMap; // Map state to event @@ -120,8 +118,6 @@ public class StateReducer extends ListenerAdapter { backtrackSet = new HashSet<>(); conflictPairMap = new HashMap<>(); unusedCG = new HashSet<>(); - // TODO: The following is a full-blown graph traversal that we can do if we need to in the future - //stateGraph = ConflictTracker.nodes; stateToEventMap = new HashMap<>(); prevVisitedStates = new HashSet<>(); currVisitedStates = new HashSet<>(); @@ -278,42 +274,6 @@ public class StateReducer extends ListenerAdapter { return containsCyclesWithAllEvts; } - // TODO: The following is a full-blown graph traversal that we can do if we need to in the future - // Detect cycles in the current execution/trace - // We terminate the execution iff: - // (1) the state has been visited in the current execution - // (2) the state has one or more cycles that involve all the events -// private boolean containsCyclesWithAllEvents(int stId) { -// -// HashSet visitingStates = new HashSet<>(); -// HashSet visitedEvents = new HashSet<>(); -// boolean containsCyclesWithAllEvts = false; -// ConflictTracker.Node currNode = stateGraph.get(stId); -// dfsFindCycles(currNode, visitingStates, visitedEvents, new HashSet<>()); -// if (checkIfAllEventsInvolved(visitedEvents)) { -// containsCyclesWithAllEvts = true; -// } -// -// return containsCyclesWithAllEvts; -// } -// -// private void dfsFindCycles(ConflictTracker.Node currNode, HashSet visitingStates, -// HashSet visitedEvents, HashSet visitingEvents) { -// -// // Stop when there is a cycle and record all the events -// if (visitingStates.contains(currNode)) { -// visitedEvents.addAll(visitingEvents); -// } else { -// visitingStates.add(currNode); -// for(ConflictTracker.Edge edge : currNode.getOutEdges()) { -// visitingEvents.add(edge.getEventNumber()); -// dfsFindCycles(edge.getDst(), visitingStates, visitedEvents, visitingEvents); -// visitingEvents.remove(edge.getEventNumber()); -// } -// visitingStates.remove(currNode); -// } -// } - private boolean checkIfAllEventsInvolved(HashSet visitedEvents) { // Check if this set contains all the event choices