public DeadlockDetector(boolean optionPrintDebug, boolean optionRepairDeadlock, boolean optionAllowSelfEdges, List<CriticalSection> criticalSections) { this.optionPrintDebug = optionPrintDebug; this.optionRepairDeadlock = optionRepairDeadlock; this.optionAllowSelfEdges = optionAllowSelfEdges && !optionRepairDeadlock; // can only do this if not repairing this.criticalSections = criticalSections; this.tt = new TransitiveTargets(Scene.v().getCallGraph(), new Filter(new CriticalSectionVisibleEdgesPred(null))); }
protected void getReachableMethodsFromThreads(Set<ThreadProperties> startedRunnables) { if(this.callGraph == null) { this.callGraph = Scene.v().getCallGraph(); } // Get reachable methods for all threads for(ThreadProperties threadProperties : startedRunnables) { Type classType = threadProperties.getRunnableType(); SootClass runnableClass = Scene.v().loadClassAndSupport(classType.toString()); for(SootMethod sootMethod : runnableClass.getMethods()) { // Only consider run() methods if(! (sootMethod.getDeclaration().equals("public void run()") || sootMethod.getDeclaration().equals("public static void main(java.lang.String[])"))) { continue; } threadProperties.setRunMethod(sootMethod); // Get directly reachable and transitive targets from this function ReachableMethods directTargets = new ReachableMethods(this.callGraph, new Targets(callGraph.edgesOutOf(sootMethod))); TransitiveTargets transitiveTargets = new TransitiveTargets(this.callGraph); Iterator<MethodOrMethodContext> transitiveIterator = transitiveTargets.iterator(sootMethod); while (transitiveIterator.hasNext()) { SootMethod transitiveTarget = (SootMethod) transitiveIterator.next(); // Show all target methods not in JDK if(!SusHelper.isPackageInJdk(SusHelper.getClassFromSignature(transitiveTarget.getSignature()))) { // This method is directly reachable from this run() if(directTargets.contains(transitiveTarget)) { threadProperties.addDirectReachableMethod(transitiveTarget); System.out.println(sootMethod + " may call " + transitiveTarget); } // This method is transitively reachable from this run() else { threadProperties.addTransitiveReachableMethod(transitiveTarget); System.out.println(sootMethod + " may reach " + transitiveTarget); } } } } } }