Package soot.jimple.toolkits.callgraph

Examples of soot.jimple.toolkits.callgraph.ReachableMethods


        if(!Scene.v().hasCallGraph()) {
          throw new IllegalStateException("No call graph found!");
        }
             
      CallGraph cg = Scene.v().getCallGraph();
      ReachableMethods reachableMethods = 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() &&
        //exclude static initializer of same class (assume that it has already been executed)
         !(m.getName().equals(SootMethod.staticInitializerName) && m.getDeclaringClass().equals(container.getDeclaringClass()))) {       
          for (Unit u : m.getActiveBody().getUnits()) {
View Full Code Here


        activeCallGraph = null;
        reachableMethods = null;
    }
    public ReachableMethods getReachableMethods() {
        if( reachableMethods == null ) {
            reachableMethods = new ReachableMethods(
                    getCallGraph(), new ArrayList<MethodOrMethodContext>(getEntryPoints()) );
        }
        reachableMethods.update();
        return reachableMethods;
    }
View Full Code Here

        CallGraphBuilder cg = new CallGraphBuilder(DumbPointerAnalysis.v(),
                true);
        cg.build();
        CallGraph callGraph = Scene.v().getCallGraph();
        ReachableMethods reachableMethods = new ReachableMethods(callGraph,
                EntryPoints.v().application());

        reachableMethods.update();

        Hierarchy hierarchy = Scene.v().getActiveHierarchy();

        final Set createableClasses = new HashSet();

        for (Iterator reachables = reachableMethods.listener(); reachables
                .hasNext();) {
            SootMethod method = (SootMethod) reachables.next();
            //String methodName = method.getSignature();

            if (method.getName().equals("<init>")
                    && !method.getDeclaringClass().getName().startsWith("java")) {
                createableClasses
                        .addAll(hierarchy.getSuperclassesOfIncluding(method
                                .getDeclaringClass()));
                _addAllInterfaces(createableClasses, method.getDeclaringClass());
            }
        }

        System.out.println("createableClasses = " + createableClasses);

        // Now create a new set of reachable methods that only
        // includes methods that are static or are declared in classes
        // that can are created.
        Filter filter = new Filter(new EdgePredicate() {
            public boolean want(Edge e) {
                SootMethod target = e.tgt();
                return e.isExplicit()
                        && (target.isStatic() || createableClasses
                                .contains(target.getDeclaringClass()));
            }
        });
        Set necessaryClasses = new HashSet();
        ReachableMethods RTAReachableMethods = new ReachableMethods(callGraph,
                EntryPoints.v().application().iterator(), filter);
        RTAReachableMethods.update();

        List list = new LinkedList();

        for (Iterator reachables = RTAReachableMethods.listener(); reachables
                .hasNext();) {
            SootMethod method = (SootMethod) reachables.next();
            String methodName = method.getSignature();
            list.add(methodName);
View Full Code Here

        _unprocessedMethods = new ChunkedQueue();

        Iterator methods = _unprocessedMethods.reader();

        CallGraph callGraph = Scene.v().getCallGraph();
        _reachables = new ReachableMethods(callGraph, EntryPoints.v()
                .application());
        _reachables.update();

        // Process all the reachableMethods.
        for (Iterator reachableMethods = _reachables.listener(); reachableMethods
View Full Code Here

        // targeted by that invocation.
        CallGraphBuilder cg = new CallGraphBuilder(DumbPointerAnalysis.v(),
                true);
        cg.build();
        CallGraph callGraph = Scene.v().getCallGraph();
        ReachableMethods reachables = new ReachableMethods(callGraph,
                forcedReachableMethodSet);
        reachables.update();

        Scene.v().setCallGraph(callGraph);

        // Loop over all the classes...
        for (Iterator i = Scene.v().getApplicationClasses().iterator(); i
                .hasNext();) {
            SootClass theClass = (SootClass) i.next();

            // Loop through all the methods...
            List methodList = new ArrayList(theClass.getMethods());

            for (Iterator methods = methodList.iterator(); methods.hasNext();) {
                SootMethod method = (SootMethod) methods.next();

                // And remove any methods that aren't reachable.
                if (!reachables.contains(method)) {
                    if (debug) {
                        System.out.println("removing method " + method);
                    }

                    theClass.removeMethod(method);
View Full Code Here

TOP

Related Classes of soot.jimple.toolkits.callgraph.ReachableMethods

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.