Fixing a bug in Conflict Tracker analysis
[jpf-core.git] / src / main / gov / nasa / jpf / listener / ConflictTracker.java
1 /*
2  * Copyright (C) 2014, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The Java Pathfinder core (jpf-core) platform is licensed under the
7  * Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  * 
10  *        http://www.apache.org/licenses/LICENSE-2.0. 
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and 
16  * limitations under the License.
17  */
18 package gov.nasa.jpf.listener;
19
20 import gov.nasa.jpf.Config;
21 import gov.nasa.jpf.JPF;
22 import gov.nasa.jpf.ListenerAdapter;
23 import gov.nasa.jpf.search.Search;
24 import gov.nasa.jpf.jvm.bytecode.*;
25 import gov.nasa.jpf.vm.*;
26 import gov.nasa.jpf.vm.bytecode.LocalVariableInstruction;
27 import gov.nasa.jpf.vm.bytecode.ReadInstruction;
28 import gov.nasa.jpf.vm.bytecode.StoreInstruction;
29 import gov.nasa.jpf.vm.bytecode.WriteInstruction;
30
31 import java.io.PrintWriter;
32
33 import java.util.*;
34
35 /**
36  * Listener using data flow analysis to find conflicts between smartApps.
37  **/
38
39 public class ConflictTracker extends ListenerAdapter {
40   private final PrintWriter out;
41   private final HashSet<String> conflictSet = new HashSet<String>(); // Variables we want to track
42   private final HashSet<String> appSet = new HashSet<String>(); // Apps we want to find their conflicts
43   private final HashSet<String> manualSet = new HashSet<String>(); // Writer classes with manual inputs to detect direct-direct(No Conflict) interactions
44   private final HashMap<Integer, Node> nodes = new HashMap<Integer, Node>(); // Nodes of a graph
45   private ArrayList<NameValuePair> tempSetSet = new ArrayList<NameValuePair>();
46   private long timeout;
47   private long startTime;
48   private Node parentNode = new Node(-2);
49   private String operation;
50   private String detail;
51   private String errorMessage;
52   private int depth;
53   private int id;
54   private boolean conflictFound = false;
55   private boolean manual = false;
56
57   private final String SET_LOCATION_METHOD = "setLocationMode";
58   private final String LOCATION_VAR = "locationMode";
59   
60   public ConflictTracker(Config config, JPF jpf) {
61     out = new PrintWriter(System.out, true);
62
63     String[] conflictVars = config.getStringArray("variables");
64     // We are not tracking anything if it is null
65     if (conflictVars != null) {
66       for (String var : conflictVars) {
67         conflictSet.add(var);
68       }
69     }
70     String[] apps = config.getStringArray("apps");
71     // We are not tracking anything if it is null
72     if (apps != null) {
73       for (String var : apps) {
74         appSet.add(var);
75       }
76     }
77     String[] manualClasses = config.getStringArray("manualClasses");
78     // We are not tracking anything if it is null
79     if (manualClasses != null) {
80       for (String var : manualClasses) {
81         manualSet.add(var);
82       }
83     }
84
85     // Timeout input from config is in minutes, so we need to convert into millis
86     timeout = config.getInt("timeout", 0) * 60 * 1000;
87     startTime = System.currentTimeMillis();
88   }
89
90   boolean propagateTheChange(Node currentNode) {
91         HashSet<Node> changed = new HashSet<Node>(currentNode.getSuccessors());
92         HashMap<Node, HashSet<Node>> parentQueueMap = new HashMap<Node, HashSet<Node>>();
93         HashSet<Node> parents = new HashSet<Node>();
94         parents.add(currentNode);
95
96         for (Node node : currentNode.getSuccessors()) {
97                 parentQueueMap.put(node, parents);
98         }
99
100         while(!changed.isEmpty()) {
101                 // Get the first element of the changed set and remove it
102                 Node nodeToProcess = changed.iterator().next();
103                 changed.remove(nodeToProcess);
104
105                 // Update the changed parents
106                 parents.clear();
107                 parents = parentQueueMap.get(nodeToProcess);
108                 boolean isChanged = false;
109
110                 for (Node node : parents) {
111                         // Update the edge
112                         isChanged |= updateTheOutSet(node, nodeToProcess);
113                 }
114
115                 // Check for a conflict if the outSet of nodeToProcess is changed
116                 if (isChanged) {
117                         for (Node node : nodeToProcess.getSuccessors()) {
118                                 HashMap<Transition, ArrayList<NameValuePair>> setSets = nodeToProcess.getOutgoingEdges().get(node).getSetSetMap();
119                                 for (Map.Entry mapElement : setSets.entrySet()) {
120                                         Transition transition = (Transition)mapElement.getKey();
121                                         if (checkForConflict(nodeToProcess, node, transition))
122                                                 return true;
123                                 }
124                         }
125                 }
126
127                 // Update the parents list for the successors of the current node
128                 parents.clear();
129                 parents.add(nodeToProcess);
130
131                 // Checking if the out set has changed or not(Add its successors to the change list!)
132                 if (isChanged) {
133                         for (Node i : nodeToProcess.getSuccessors()) {
134                                 if (!changed.contains(i))
135                                         changed.add(i);
136
137                                 // Update the list of updated parents for the current node
138                                 if (parentQueueMap.containsKey(i))
139                                         parentQueueMap.get(i).add(nodeToProcess);
140                                 else
141                                         parentQueueMap.put(i, parents);
142                         }
143                 }
144       }
145
146       return false;
147   }
148
149   String createErrorMessage(NameValuePair pair, HashMap<String, String> valueMap, HashMap<String, Integer> writerMap) {
150         String message = "Conflict found between the two apps. App"+pair.getAppNum()+
151                          " has written the value: "+pair.getValue()+
152                          " to the variable: "+pair.getVarName()+" while App"
153                          +writerMap.get(pair.getVarName())+" is overwriting the value: "
154                          +valueMap.get(pair.getVarName())+" to the same variable!";
155         System.out.println(message);    
156         return message;
157   }
158
159   boolean checkForConflict(Node parentNode, Node currentNode, Transition currentTransition) {
160         ArrayList<NameValuePair> setSet = parentNode.getOutgoingEdges().get(currentNode).getSetSetMap().get(currentTransition);
161         HashMap<String, String> valueMap = new HashMap<String, String>(); // HashMap from varName to value
162         HashMap<String, Integer> writerMap = new HashMap<String, Integer>(); //  HashMap from varName to appNum
163
164
165         // Update the valueMap and writerMap + check for conflict between the elements of setSet
166         for (int i = 0;i < setSet.size();i++) {
167             NameValuePair nameValuePair = setSet.get(i);
168             String varName = nameValuePair.getVarName();
169             String value = nameValuePair.getValue();
170             Integer appNum = nameValuePair.getAppNum();
171
172             if (valueMap.containsKey(varName)) {
173                 // Check if we have a same writer
174                 if (!writerMap.get(varName).equals(appNum)) {
175                         // Check if we have a conflict or not
176                         if (!valueMap.get(varName).equals(value)) {
177                                 errorMessage = createErrorMessage(nameValuePair, valueMap, writerMap);
178                                 return true;
179                         } else { // We have two writers writing the same value
180                                 writerMap.put(varName, 3); // 3 represents both apps
181                         }
182                 } else {
183                         // Check if we have more than one value with the same writer
184                         if (!valueMap.get(varName).equals(value)) {
185                                 // We have one writer writing more than one value in a same event
186                                 valueMap.put(varName, "twoValue");
187                         }
188                 }
189              } else {
190                 valueMap.put(varName, value);
191                 writerMap.put(varName, appNum);
192              }
193         }
194
195         // Check for conflict between outSet and this transition setSet
196         for (NameValuePair i : parentNode.getOutSet()) {
197              if (valueMap.containsKey(i.getVarName())) {
198                  String value = valueMap.get(i.getVarName());
199                  Integer writer = writerMap.get(i.getVarName());
200                      if ((value != null)&&(writer != null)) {
201                          if (!value.equals(i.getValue())&&!writer.equals(i.getAppNum())) { 
202                              // We have different values and different writers
203                              errorMessage = createErrorMessage(i, valueMap, writerMap);
204                              return true;
205                          }
206                      }
207              }
208        }
209
210        return false;
211   }
212
213   boolean updateTheOutSet(Node parentNode, Node currentNode) {
214         HashMap<Transition, ArrayList<NameValuePair>> setSets = parentNode.getOutgoingEdges().get(currentNode).getSetSetMap();
215         HashSet<String> updatedVarNames = new HashSet<String>();
216         Edge currentEdge = parentNode.getOutgoingEdges().get(currentNode);
217         HashMap<String, Integer> lastWriter = currentEdge.getLastWriter();
218         HashMap<String, String> lastValue = currentEdge.getLastValue();
219         HashMap<String, Integer> outSetVarMap = new HashMap<String, Integer>();
220         boolean isChanged = false;
221
222         for (Map.Entry mapElement : setSets.entrySet()) {
223             ArrayList<NameValuePair> setSet = (ArrayList<NameValuePair>)mapElement.getValue();
224   
225             for (int i = 0;i < setSet.size();i++) {
226                         updatedVarNames.add(setSet.get(i).getVarName());
227             }
228         }
229
230
231         for (NameValuePair i : parentNode.getOutSet()) {
232                 outSetVarMap.put(i.getVarName(), i.getAppNum());
233                 if (!updatedVarNames.contains(i.getVarName()))
234                         isChanged |= currentNode.getOutSet().add(i);
235         }
236
237
238         for (Map.Entry mapElement : setSets.entrySet()) {
239             ArrayList<NameValuePair> setSet = (ArrayList<NameValuePair>)mapElement.getValue();
240   
241             for (int i = 0;i < setSet.size();i++) {
242                         String varName = setSet.get(i).getVarName();
243                         Integer writer = lastWriter.get(varName);
244                         String value = lastValue.get(varName);
245
246                         if (setSet.get(i).getAppNum().equals(writer) 
247                             && setSet.get(i).getValue().equals(value)) {
248                                 if (outSetVarMap.containsKey(varName)) {
249                                         Integer hashCode = outSetVarMap.get(varName).hashCode() * 31 +
250                                                            varName.hashCode();
251                                         currentNode.getOutSet().remove(hashCode);
252                                 }
253                                 isChanged |= currentNode.getOutSet().add(setSet.get(i));
254                         }
255             }
256         }
257
258         return isChanged;
259   }
260
261   void updateTheEdge(Node currentNode, Transition transition) {
262         if (parentNode.getOutgoingEdges().containsKey(currentNode)) {
263                 Edge currentEdge = parentNode.getOutgoingEdges().get(currentNode);
264                 if (currentEdge.getSetSetMap().containsKey(transition)) { // Update the transition
265                         if (manual)
266                                 currentEdge.getSetSetMap().put(transition, tempSetSet);
267                         else
268                                 currentEdge.getSetSetMap().get(transition).addAll(tempSetSet);
269                 } else { // Add a new transition
270                         currentEdge.getSetSetMap().put(transition, tempSetSet);
271                 }
272         } else {
273                 parentNode.getOutgoingEdges().put(currentNode, new Edge(parentNode, currentNode));
274                 Edge currentEdge = parentNode.getOutgoingEdges().get(currentNode);
275                 currentEdge.getSetSetMap().put(transition, tempSetSet);
276         }
277
278         // Update the last writer and last value for this edge for each varName
279         Edge currentEdge = parentNode.getOutgoingEdges().get(currentNode);
280         ArrayList<NameValuePair> setSet = currentEdge.getSetSetMap().get(transition);
281         for (int i = 0;i < setSet.size();i++) {
282                 NameValuePair nameValuePair = setSet.get(i);
283                 currentEdge.getLastWriter().put(nameValuePair.getVarName(), nameValuePair.getAppNum());
284                 currentEdge.getLastValue().put(nameValuePair.getVarName(), nameValuePair.getValue());
285         }
286   }
287
288   
289
290   static class Node {
291         Integer id;
292         HashSet<Node> predecessors = new HashSet<Node>();
293         HashSet<Node> successors = new HashSet<Node>();
294         HashSet<NameValuePair> outSet = new HashSet<NameValuePair>();
295         HashMap<Node, Edge> outgoingEdges = new HashMap<Node, Edge>();
296
297         Node(Integer id) {
298           this.id = id;
299         }
300
301         Integer getId() {
302                 return id;
303         }
304
305         HashSet<Node> getPredecessors() {
306                 return predecessors;
307         }
308
309         HashSet<Node> getSuccessors() {
310                 return successors;
311         }
312
313         HashSet<NameValuePair> getOutSet() {
314                 return outSet;
315         }
316
317         HashMap<Node, Edge> getOutgoingEdges() {
318                 return outgoingEdges;
319         }
320   }
321
322   static class Edge {
323         Node source, destination;
324         HashMap<String, Integer> lastWriter = new HashMap<String, Integer>();
325         HashMap<String, String> lastValue = new HashMap<String, String>();
326         HashMap<Transition, ArrayList<NameValuePair>> setSetMap = new HashMap<Transition, ArrayList<NameValuePair>>();
327
328         Edge(Node source, Node destination) {
329                 this.source = source;
330                 this.destination = destination;
331         }
332
333         Node getSource() {
334                 return source;
335         }
336
337         Node getDestination() {
338                 return destination;
339         }
340
341         HashMap<Transition, ArrayList<NameValuePair>> getSetSetMap() {
342                 return setSetMap;
343         }
344
345         HashMap<String, Integer> getLastWriter() {
346                 return lastWriter;
347         }
348
349         HashMap<String, String> getLastValue() {
350                 return lastValue;
351         }
352   }
353
354   static class NameValuePair {
355         Integer appNum;
356         String value;
357         String varName;
358         boolean isManual;
359
360         NameValuePair(Integer appNum, String value, String varName, boolean isManual) {
361                 this.appNum = appNum;
362                 this.value = value;
363                 this.varName = varName;
364                 this.isManual = isManual;
365         }
366
367         void setAppNum(Integer appNum) {
368                 this.appNum = appNum;
369         }
370
371         void setValue(String value) {
372                 this.value = value;
373         }
374
375         void setVarName(String varName) {
376                 this.varName = varName;
377         }
378
379         void setIsManual(String varName) {
380                 this.isManual = isManual;
381         }
382
383         Integer getAppNum() {
384                 return appNum;
385         }
386
387         String getValue() {
388                 return value;
389         }
390
391         String getVarName() {
392                 return varName;
393         }
394
395         boolean getIsManual() {
396                 return isManual;
397         }
398
399         @Override
400         public boolean equals(Object o) {
401       if (o instanceof NameValuePair) {
402         NameValuePair other = (NameValuePair) o;
403         if (varName.equals(other.getVarName()))
404           return appNum.equals(other.getAppNum());
405       }
406       return false;
407         }
408
409         @Override
410         public int hashCode() {
411                 return appNum.hashCode() * 31 + varName.hashCode();
412         }
413   }
414
415   @Override
416   public void stateRestored(Search search) {
417     id = search.getStateId();
418     depth = search.getDepth();
419     operation = "restored";
420     detail = null;
421
422     out.println("The state is restored to state with id: "+id+", depth: "+depth);
423   
424     // Update the parent node
425     if (nodes.containsKey(id)) {
426           parentNode = nodes.get(id);
427     } else {
428           parentNode = new Node(id);
429     }
430   }
431
432   @Override
433   public void searchStarted(Search search) {
434     out.println("----------------------------------- search started");
435   }
436  
437
438   @Override
439   public void stateAdvanced(Search search) {
440     String theEnd = null;
441     Transition transition = search.getTransition();
442     id = search.getStateId();
443     depth = search.getDepth();
444     operation = "forward";
445
446     // Add the node to the list of nodes
447     if (nodes.get(id) == null)
448         nodes.put(id, new Node(id));
449
450     Node currentNode = nodes.get(id);
451
452     // Update the edge based on the current transition
453     updateTheEdge(currentNode, transition);
454
455     // Reset the temporary variables and flags
456     tempSetSet = new ArrayList<NameValuePair>();
457     manual = false;
458
459     // Check for the conflict in this transition
460     conflictFound = checkForConflict(parentNode, currentNode, transition);
461
462     if (search.isNewState()) {
463       detail = "new";
464     } else {
465       detail = "visited";
466     }
467
468     if (search.isEndState()) {
469       out.println("This is the last state!");
470       theEnd = "end";
471     }
472
473     out.println("The state is forwarded to state with id: "+id+", depth: "+depth+" which is "+detail+" state: "+"% "+theEnd);
474     
475     // Updating the predecessors for this node
476     // Check if parent node is already in successors of the current node or not
477     if (!(currentNode.getPredecessors().contains(parentNode)))
478         currentNode.getPredecessors().add(parentNode);
479
480     // Update the successors for this node
481     // Check if current node is already in successors of the parent node or not
482     if (!(parentNode.getSuccessors().contains(currentNode)))
483         parentNode.getSuccessors().add(currentNode);
484
485     // Update the outset of the current node and check if it is changed or not to propagate the change
486     boolean isChanged = updateTheOutSet(parentNode, currentNode);
487
488     // Check if the outSet of this state has changed, update all of its successors' sets if any
489     if (isChanged) {
490         for (Node node : currentNode.getSuccessors()) {
491                 HashMap<Transition, ArrayList<NameValuePair>> setSets = currentNode.getOutgoingEdges().get(node).getSetSetMap();
492                 for (Map.Entry mapElement : setSets.entrySet()) {
493                         Transition currentTransition = (Transition)mapElement.getKey();
494                         conflictFound = conflictFound || checkForConflict(currentNode, node, currentTransition);
495                 }
496         }
497         conflictFound = conflictFound || propagateTheChange(currentNode);
498     }
499     // Update the parent node
500     if (nodes.containsKey(id)) {
501           parentNode = nodes.get(id);
502     } else {
503           parentNode = new Node(id);
504     }
505   }
506
507   @Override
508   public void stateBacktracked(Search search) {
509     id = search.getStateId();
510     depth = search.getDepth();
511     operation = "backtrack";
512     detail = null;
513
514     out.println("The state is backtracked to state with id: "+id+", depth: "+depth);
515
516     // Update the parent node
517     if (nodes.containsKey(id)) {
518           parentNode = nodes.get(id);
519     } else {
520           parentNode = new Node(id);
521     }
522   }
523
524   @Override
525   public void searchFinished(Search search) {
526     out.println("----------------------------------- search finished");
527   }
528
529   private String getValue(ThreadInfo ti, Instruction inst, byte type) {
530     StackFrame frame;
531     int lo, hi;
532
533     frame = ti.getTopFrame();
534
535     if ((inst instanceof JVMLocalVariableInstruction) ||
536         (inst instanceof JVMFieldInstruction))
537     {
538       if (frame.getTopPos() < 0)
539         return(null);
540
541       lo = frame.peek();
542       hi = frame.getTopPos() >= 1 ? frame.peek(1) : 0;
543
544       return(decodeValue(type, lo, hi));
545     }
546
547     if (inst instanceof JVMArrayElementInstruction)
548       return(getArrayValue(ti, type));
549
550     return(null);
551   }
552
553   private final static String decodeValue(byte type, int lo, int hi) {
554     switch (type) {
555       case Types.T_ARRAY:   return(null);
556       case Types.T_VOID:    return(null);
557
558       case Types.T_BOOLEAN: return(String.valueOf(Types.intToBoolean(lo)));
559       case Types.T_BYTE:    return(String.valueOf(lo));
560       case Types.T_CHAR:    return(String.valueOf((char) lo));
561       case Types.T_DOUBLE:  return(String.valueOf(Types.intsToDouble(lo, hi)));
562       case Types.T_FLOAT:   return(String.valueOf(Types.intToFloat(lo)));
563       case Types.T_INT:     return(String.valueOf(lo));
564       case Types.T_LONG:    return(String.valueOf(Types.intsToLong(lo, hi)));
565       case Types.T_SHORT:   return(String.valueOf(lo));
566
567       case Types.T_REFERENCE:
568         ElementInfo ei = VM.getVM().getHeap().get(lo);
569         if (ei == null)
570           return(null);
571
572         ClassInfo ci = ei.getClassInfo();
573         if (ci == null)
574           return(null);
575
576         if (ci.getName().equals("java.lang.String"))
577           return('"' + ei.asString() + '"');
578
579         return(ei.toString());
580
581       default:
582         System.err.println("Unknown type: " + type);
583         return(null);
584      }
585   }
586
587   private String getArrayValue(ThreadInfo ti, byte type) {
588     StackFrame frame;
589     int lo, hi;
590
591     frame = ti.getTopFrame();
592     lo    = frame.peek();
593     hi    = frame.getTopPos() >= 1 ? frame.peek(1) : 0;
594
595     return(decodeValue(type, lo, hi));
596   }
597
598   private byte getType(ThreadInfo ti, Instruction inst) {
599     StackFrame frame;
600     FieldInfo fi;
601     String type;
602
603     frame = ti.getTopFrame();
604     if ((frame.getTopPos() >= 0) && (frame.isOperandRef())) {
605       return (Types.T_REFERENCE);
606     }
607
608     type = null;
609
610     if (inst instanceof JVMLocalVariableInstruction) {
611       type = ((JVMLocalVariableInstruction) inst).getLocalVariableType();
612     } else if (inst instanceof JVMFieldInstruction){
613       fi = ((JVMFieldInstruction) inst).getFieldInfo();
614       type = fi.getType();
615     }
616
617     if (inst instanceof JVMArrayElementInstruction) {
618       return (getTypeFromInstruction(inst));
619     }
620
621     if (type == null) {
622       return (Types.T_VOID);
623     }
624
625     return (decodeType(type));
626   }
627
628   private final static byte getTypeFromInstruction(Instruction inst) {
629     if (inst instanceof JVMArrayElementInstruction)
630       return(getTypeFromInstruction((JVMArrayElementInstruction) inst));
631
632     return(Types.T_VOID);
633   }
634
635   private final static byte decodeType(String type) {
636     if (type.charAt(0) == '?'){
637       return(Types.T_REFERENCE);
638     } else {
639       return Types.getBuiltinType(type);
640     }
641   }
642
643   // Find the variable writer
644   // It should be one of the apps listed in the .jpf file
645   private String getWriter(List<StackFrame> sfList, HashSet<String> writerSet) {
646     // Start looking from the top of the stack backward
647     for(int i=sfList.size()-1; i>=0; i--) {
648       MethodInfo mi = sfList.get(i).getMethodInfo();
649       if(!mi.isJPFInternal()) {
650         String method = mi.getStackTraceName();
651         // Check against the writers in the writerSet
652         for(String writer : writerSet) {
653           if (method.contains(writer)) {
654             return writer;
655           }
656         }
657       }
658     }
659
660     return null;
661   }
662
663   private void writeWriterAndValue(String writer, String value, String var) {
664     // Update the temporary Set set.
665     NameValuePair temp = new NameValuePair(1, value, var, manual);
666     if (writer.equals("App2"))
667         temp = new NameValuePair(2, value, var, manual);
668     
669     tempSetSet.add(temp);
670   }
671
672   @Override
673   public void instructionExecuted(VM vm, ThreadInfo ti, Instruction nextInsn, Instruction executedInsn) {
674     if (timeout > 0) {
675       if (System.currentTimeMillis() - startTime > timeout) {
676         StringBuilder sbTimeOut = new StringBuilder();
677         sbTimeOut.append("Execution timeout: " + (timeout / (60 * 1000)) + " minutes have passed!");
678         Instruction nextIns = ti.createAndThrowException("java.lang.RuntimeException", sbTimeOut.toString());
679         ti.setNextPC(nextIns);
680       }
681     }
682
683     if (conflictFound) {
684       StringBuilder sb = new StringBuilder();
685       sb.append(errorMessage);
686       Instruction nextIns = ti.createAndThrowException("java.lang.RuntimeException", sb.toString());
687       ti.setNextPC(nextIns);
688     } else {
689       if (conflictSet.contains(LOCATION_VAR)) {
690         MethodInfo mi = executedInsn.getMethodInfo();
691         // Find the last load before return and get the value here
692         if (mi.getName().equals(SET_LOCATION_METHOD) &&
693                 executedInsn instanceof ALOAD && nextInsn instanceof ARETURN) {
694           byte type  = getType(ti, executedInsn);
695           String value = getValue(ti, executedInsn, type);
696
697           // Extract the writer app name
698           ClassInfo ci = mi.getClassInfo();
699           String writer = ci.getName();
700
701           // Update the temporary Set set.
702           writeWriterAndValue(writer, value, LOCATION_VAR);
703         }
704       } else {
705         if (executedInsn instanceof WriteInstruction) {
706           String varId = ((WriteInstruction) executedInsn).getFieldInfo().getFullName();
707
708           for (String var : conflictSet) {
709             if (varId.contains(var)) {
710               // Get variable info
711               byte type = getType(ti, executedInsn);
712               String value = getValue(ti, executedInsn, type);
713               String writer = getWriter(ti.getStack(), appSet);
714               // Just return if the writer is not one of the listed apps in the .jpf file
715               if (writer == null)
716                 return;
717
718               if (getWriter(ti.getStack(), manualSet) != null)
719                 manual = true;
720
721               // Update the temporary Set set.
722               writeWriterAndValue(writer, value, var);
723             }
724           }
725         }
726       }
727     }
728   }
729 }