use of soot.SceneTransformer in project soot by Sable.
the class CallGraphExample method main.
public static void main(String[] args) {
List<String> argsList = new ArrayList<String>(Arrays.asList(args));
argsList.addAll(Arrays.asList(new String[] { "-w", "-main-class", // main-class
"testers.CallGraphs", // argument classes
"testers.CallGraphs", //
"testers.A" }));
PackManager.v().getPack("wjtp").add(new Transform("wjtp.myTrans", new SceneTransformer() {
@Override
protected void internalTransform(String phaseName, Map options) {
CHATransformer.v().transform();
SootClass a = Scene.v().getSootClass("testers.A");
SootMethod src = Scene.v().getMainClass().getMethodByName("doStuff");
CallGraph cg = Scene.v().getCallGraph();
Iterator<MethodOrMethodContext> targets = new Targets(cg.edgesOutOf(src));
while (targets.hasNext()) {
SootMethod tgt = (SootMethod) targets.next();
System.out.println(src + " may call " + tgt);
}
}
}));
args = argsList.toArray(new String[0]);
soot.Main.main(args);
}
use of soot.SceneTransformer in project soot by Sable.
the class Main method main.
/**
* @param args
*/
public static void main(String[] args) {
PackManager.v().getPack("wjtp").add(new Transform("wjtp.ifds", new SceneTransformer() {
protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") Map options) {
IFDSTabulationProblem<Unit, ?, SootMethod, InterproceduralCFG<Unit, SootMethod>> problem = new IFDSPossibleTypes(new JimpleBasedInterproceduralCFG());
@SuppressWarnings({ "rawtypes", "unchecked" }) JimpleIFDSSolver<?, InterproceduralCFG<Unit, SootMethod>> solver = new JimpleIFDSSolver(problem);
solver.solve();
}
}));
soot.Main.main(args);
}
use of soot.SceneTransformer in project soot by Sable.
the class OnTheFlyJimpleBasedICFG method main.
public static void main(String[] args) {
PackManager.v().getPack("wjtp").add(new Transform("wjtp.onflyicfg", new SceneTransformer() {
@Override
protected void internalTransform(String phaseName, Map<String, String> options) {
if (Scene.v().hasCallGraph())
throw new RuntimeException("call graph present!");
loadAllClassesOnClassPathToSignatures();
SootMethod mainMethod = Scene.v().getMainMethod();
OnTheFlyJimpleBasedICFG icfg = new OnTheFlyJimpleBasedICFG(mainMethod);
Set<SootMethod> worklist = new LinkedHashSet<SootMethod>();
Set<SootMethod> visited = new HashSet<SootMethod>();
worklist.add(mainMethod);
int monomorphic = 0, polymorphic = 0;
while (!worklist.isEmpty()) {
Iterator<SootMethod> iter = worklist.iterator();
SootMethod currMethod = iter.next();
iter.remove();
visited.add(currMethod);
System.err.println(currMethod);
// MUST call this method to initialize ICFG for every method
Body body = currMethod.getActiveBody();
if (body == null)
continue;
for (Unit u : body.getUnits()) {
Stmt s = (Stmt) u;
if (s.containsInvokeExpr()) {
Set<SootMethod> calleesOfCallAt = icfg.getCalleesOfCallAt(s);
if (s.getInvokeExpr() instanceof VirtualInvokeExpr || s.getInvokeExpr() instanceof InterfaceInvokeExpr) {
if (calleesOfCallAt.size() <= 1)
monomorphic++;
else
polymorphic++;
System.err.println("mono: " + monomorphic + " poly: " + polymorphic);
}
for (SootMethod callee : calleesOfCallAt) {
if (!visited.contains(callee)) {
System.err.println(callee);
// worklist.add(callee);
}
}
}
}
}
}
}));
Options.v().set_on_the_fly(true);
soot.Main.main(args);
}
Aggregations