= new ReachableMethods(cg, Collections.<MethodOrMethodContext>singletonList(container)); reachableMethods.update(); for (Iterator<MethodOrMethodContext> iterator = reachableMethods.listener(); iterator.hasNext();) { SootMethod m = (SootMethod) iterator.next(); if (m.hasActiveBody() &&
/** * Causes the QueueReader objects to be filled up with any methods that have become reachable since the last call. */ public void update() { while (edgeSource.hasNext()) { Edge e = edgeSource.next(); if (set.contains(e.getSrc())) { addMethod(e.getTgt()); } } while (unprocessedMethods.hasNext()) { MethodOrMethodContext m = unprocessedMethods.next(); Iterator<Edge> targets = cg.edgesOutOf(m); if (filter != null) { targets = filter.wrap(targets); } addMethods(new Targets(targets)); } }
public CallChain getNextCallChainBetween(SootMethod start, SootMethod goal, List previouslyFound) { // callChains.add(new LinkedList()); // Represents the one way to get from goal to goal (which is to already be there) // Is this worthwhile? Fast? Slow? Broken? Applicable inside the recursive method? // If method is unreachable, don't bother trying to make chains // CACHEABLE? ReachableMethods rm = null; if (rmCache.containsKey(start)) { rm = rmCache.get(start); } else { List<MethodOrMethodContext> entryPoints = new ArrayList<MethodOrMethodContext>(); entryPoints.add(start); rm = new ReachableMethods(cg, entryPoints); rm.update(); rmCache.put(start, rm); } if (rm.contains(goal)) { // Set methodsInAnyChain = new HashSet(); // methodsInAnyChain.add(goal); return getNextCallChainBetween(rm, start, goal, null, null, previouslyFound); } return null; // new ArrayList(); }
public ReachableMethods getReachableMethods() { if (reachableMethods == null) { reachableMethods = new ReachableMethods(getCallGraph(), new ArrayList<MethodOrMethodContext>(getEntryPoints())); } reachableMethods.update(); return reachableMethods; }
protected void internalTransform(String phaseName, Map options) { int numAppMethods = 0; for (Iterator mIt = Scene.v().getReachableMethods().listener(); mIt.hasNext();) { final SootMethod m = (SootMethod) mIt.next(); if (isAppMethod(m)) { // System.out.println(m); // assert OnFlyCallGraphBuilder.processedMethods.contains(m) : m // + " not processed!!"; numAppMethods++; } } logger.debug("Number of reachable methods in application: " + numAppMethods); }
public boolean mayHappenInParallel(CriticalSection tn1, CriticalSection tn2) { if (mhp == null) { if (optionLeaveOriginalLocks) { return true; } ReachableMethods rm = Scene.v().getReachableMethods(); if (!rm.contains(tn1.method) || !rm.contains(tn2.method)) { return false; } return true; } return mhp.mayHappenInParallel(tn1.method, tn2.method); } }
private void processReachables() { reachableMethods.update(); while (reachablesReader.hasNext()) { MethodOrMethodContext m = reachablesReader.next(); MethodPAG mpag = MethodPAG.v(pag, m.method()); mpag.build(); mpag.addToPAG(m.context()); } }
/** * This constructor builds the incomplete hack call graph for the Dava ThrowFinder. It uses all application class methods * as entry points, and it ignores any calls by non-application class methods. Don't use this constructor if you need a * real call graph. */ public CallGraphBuilder() { logger.warn("using incomplete callgraph containing " + "only application classes."); pa = soot.jimple.toolkits.pointer.DumbPointerAnalysis.v(); cg = Scene.v().internalMakeCallGraph(); Scene.v().setCallGraph(cg); List<MethodOrMethodContext> entryPoints = new ArrayList<MethodOrMethodContext>(); entryPoints.addAll(EntryPoints.v().methodsOfApplicationClasses()); entryPoints.addAll(EntryPoints.v().implicit()); reachables = new ReachableMethods(cg, entryPoints); ContextManager cm = new ContextInsensitiveContextManager(cg); ofcgb = new OnFlyCallGraphBuilder(cm, reachables, true); }
protected void internalTransform(String phaseName, Map<String, String> opts) { CHAOptions options = new CHAOptions(opts); CallGraphBuilder cg = options.apponly() ? new CallGraphBuilder() : new CallGraphBuilder(DumbPointerAnalysis.v()); cg.build(); if (options.verbose()) { logger.debug("" + "Number of reachable methods: " + Scene.v().getReachableMethods().size()); } } }
protected void addMethods(Iterator<? extends MethodOrMethodContext> methods) { while (methods.hasNext()) { addMethod(methods.next()); } }
public ReachableMethods(CallGraph graph, Iterator<? extends MethodOrMethodContext> entryPoints, Filter filter) { this.filter = filter; this.cg = graph; addMethods(entryPoints); unprocessedMethods = reachables.reader(); this.edgeSource = graph.listener(); if (filter != null) { this.edgeSource = filter.wrap(this.edgeSource); } }
protected void initializeUnitToOwner() { for (Iterator<MethodOrMethodContext> iter = Scene.v().getReachableMethods().listener(); iter.hasNext();) { SootMethod m = iter.next().method(); initializeUnitToOwner(m); } }
protected Collection<SootMethod> getMethodsForSeeds(IInfoflowCFG icfg) { List<SootMethod> seeds = new LinkedList<SootMethod>(); // If we have a callgraph, we retrieve the reachable methods. Otherwise, // we have no choice but take all application methods as an // approximation if (Scene.v().hasCallGraph()) { ReachableMethods reachableMethods = Scene.v().getReachableMethods(); reachableMethods.update(); for (Iterator<MethodOrMethodContext> iter = reachableMethods.listener(); iter.hasNext();) { SootMethod sm = iter.next().method(); if (isValidSeedMethod(sm)) seeds.add(sm); } } else { long beforeSeedMethods = System.nanoTime(); Set<SootMethod> doneSet = new HashSet<SootMethod>(); for (SootMethod sm : Scene.v().getEntryPoints()) getMethodsForSeedsIncremental(sm, doneSet, seeds, icfg); logger.info("Collecting seed methods took {} seconds", (System.nanoTime() - beforeSeedMethods) / 1E9); } return seeds; }
public static List<SootMethod> getAllReachableMethods(SootClass sc) { ReachableMethods rm = Scene.v().getReachableMethods(); // Get list of reachable methods declared in this class List<SootMethod> allMethods = new ArrayList<SootMethod>(); Iterator methodsIt = sc.methodIterator(); while (methodsIt.hasNext()) { SootMethod method = (SootMethod) methodsIt.next(); if (rm.contains(method)) { allMethods.add(method); } } // Add reachable methods declared in superclasses SootClass superclass = sc; if (superclass.hasSuperclass()) { superclass = superclass.getSuperclass(); } while (superclass.hasSuperclass()) // we don't want to process Object { Iterator scMethodsIt = superclass.methodIterator(); while (scMethodsIt.hasNext()) { SootMethod scMethod = (SootMethod) scMethodsIt.next(); if (rm.contains(scMethod)) { allMethods.add(scMethod); } } superclass = superclass.getSuperclass(); } return allMethods; }
public ReachableMethods getReachableMethods() { if( reachableMethods == null ) { reachableMethods = new ReachableMethods( getCallGraph(), new ArrayList<MethodOrMethodContext>(getEntryPoints()) ); } reachableMethods.update(); return reachableMethods; } public void setReachableMethods( ReachableMethods rm ) {
public void processReachables() { while (true) { if (!worklist.hasNext()) { rm.update(); if (!worklist.hasNext()) { break; } } MethodOrMethodContext momc = worklist.next(); SootMethod m = momc.method(); if (appOnly && !m.getDeclaringClass().isApplicationClass()) { continue; } if (analyzedMethods.add(m)) { processNewMethod(m); } processNewMethodContext(momc); } }
/** This constructor builds the incomplete hack call graph for the * Dava ThrowFinder. * It uses all application class methods as entry points, and it ignores * any calls by non-application class methods. * Don't use this constructor if you need a real call graph. */ public CallGraphBuilder() { G.v().out.println( "Warning: using incomplete callgraph containing "+ "only application classes." ); pa = soot.jimple.toolkits.pointer.DumbPointerAnalysis.v(); cg = new CallGraph(); Scene.v().setCallGraph(cg); List<MethodOrMethodContext> entryPoints = new ArrayList<MethodOrMethodContext>(); entryPoints.addAll( EntryPoints.v().methodsOfApplicationClasses() ); entryPoints.addAll( EntryPoints.v().implicit() ); reachables = new ReachableMethods( cg, entryPoints ); ContextManager cm = new ContextInsensitiveContextManager( cg ); ofcgb = new OnFlyCallGraphBuilder( cm, reachables, true ); } public void build() {
logger.debug("[Spark] Number of reachable methods: " + Scene.v().getReachableMethods().size());