Search in sources :

Example 6 with UnitGraph

use of soot.toolkits.graph.UnitGraph in project soot by Sable.

the class RunVeryBusyAnalysis method main.

public static void main(String[] args) {
    args = new String[] { "testers.VeryBusyClass" };
    if (args.length == 0) {
        System.out.println("Usage: java RunVeryBusyAnalysis class_to_analyse");
        System.exit(0);
    }
    String sep = File.separator;
    String pathSep = File.pathSeparator;
    String path = System.getProperty("java.home") + sep + "lib" + sep + "rt.jar";
    path += pathSep + "." + sep + "tutorial" + sep + "guide" + sep + "examples" + sep + "analysis_framework" + sep + "src";
    Options.v().set_soot_classpath(path);
    SootClass sClass = Scene.v().loadClassAndSupport(args[0]);
    sClass.setApplicationClass();
    Scene.v().loadNecessaryClasses();
    for (SootMethod m : sClass.getMethods()) {
        Body b = m.retrieveActiveBody();
        System.out.println("=======================================");
        System.out.println(m.toString());
        UnitGraph graph = new ExceptionalUnitGraph(b);
        VeryBusyExpressions vbe = new SimpleVeryBusyExpressions(graph);
        for (Unit u : graph) {
            List<AbstractBinopExpr> before = vbe.getBusyExpressionsBefore(u);
            List<AbstractBinopExpr> after = vbe.getBusyExpressionsAfter(u);
            UnitPrinter up = new NormalUnitPrinter(b);
            up.setIndent("");
            System.out.println("---------------------------------------");
            u.toString(up);
            System.out.println(up.output());
            System.out.print("Busy in: {");
            sep = "";
            for (AbstractBinopExpr e : before) {
                System.out.print(sep);
                System.out.print(e.toString());
                sep = ", ";
            }
            System.out.println("}");
            System.out.print("Busy out: {");
            sep = "";
            for (AbstractBinopExpr e : after) {
                System.out.print(sep);
                System.out.print(e.toString());
                sep = ", ";
            }
            System.out.println("}");
            System.out.println("---------------------------------------");
        }
        System.out.println("=======================================");
    }
}
Also used : NormalUnitPrinter(soot.NormalUnitPrinter) SimpleVeryBusyExpressions(dk.brics.soot.analyses.SimpleVeryBusyExpressions) SootClass(soot.SootClass) Unit(soot.Unit) SimpleVeryBusyExpressions(dk.brics.soot.analyses.SimpleVeryBusyExpressions) VeryBusyExpressions(dk.brics.soot.analyses.VeryBusyExpressions) ExceptionalUnitGraph(soot.toolkits.graph.ExceptionalUnitGraph) ExceptionalUnitGraph(soot.toolkits.graph.ExceptionalUnitGraph) UnitGraph(soot.toolkits.graph.UnitGraph) NormalUnitPrinter(soot.NormalUnitPrinter) UnitPrinter(soot.UnitPrinter) SootMethod(soot.SootMethod) Body(soot.Body)

Aggregations

UnitGraph (soot.toolkits.graph.UnitGraph)6 Unit (soot.Unit)5 Local (soot.Local)3 AssignStmt (soot.jimple.AssignStmt)3 IdentityStmt (soot.jimple.IdentityStmt)3 ExceptionalUnitGraph (soot.toolkits.graph.ExceptionalUnitGraph)3 HashMap (java.util.HashMap)2 List (java.util.List)2 SootMethod (soot.SootMethod)2 Value (soot.Value)2 ValueBox (soot.ValueBox)2 CastExpr (soot.jimple.CastExpr)2 Constant (soot.jimple.Constant)2 DefinitionStmt (soot.jimple.DefinitionStmt)2 EnterMonitorStmt (soot.jimple.EnterMonitorStmt)2 SimpleVeryBusyExpressions (dk.brics.soot.analyses.SimpleVeryBusyExpressions)1 VeryBusyExpressions (dk.brics.soot.analyses.VeryBusyExpressions)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1