use of soot.UnitPrinter 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("=======================================");
}
}
use of soot.UnitPrinter in project soot by Sable.
the class DavaPrinter method printStatementsInBody.
private void printStatementsInBody(Body body, java.io.PrintWriter out) {
if (Options.v().verbose())
System.out.println("Printing " + body.getMethod().getName());
Chain<Unit> units = ((DavaBody) body).getUnits();
if (units.size() != 1) {
throw new RuntimeException("DavaBody AST doesn't have single root.");
}
UnitPrinter up = new DavaUnitPrinter((DavaBody) body);
((ASTNode) units.getFirst()).toString(up);
out.print(up.toString());
}
Aggregations