我正在编写一个程序来获取和打印程序的调用图。我使用 soot 来尝试获取调用图,并将我想要打印的 java 类作为参数传递,但是当我运行程序时,我收到一条消息,提示 soot 找不到该类。如何配置 eclipse 类路径以找到我要打印的 cals?
我的代码:
public class CFG extends SceneTransformer
{
public static void main(String[] args)
{
if(args.length == 0)
{
System.out.println("Syntax: java CFG [soot options]");
System.exit(0);
}
PackManager.v().getPack("wjtp").add(new Transform("wjtp.cfg", CFG.v()));
// Just in case, resolve the PrintStream and System SootClasses.
Scene.v().addBasicClass("java.io.PrintStream",SootClass.SIGNATURES);
Scene.v().addBasicClass("java.lang.System",SootClass.SIGNATURES);
soot.Main.main(args);
}
private static CFG instance = new CFG();
public static CFG v() { return instance; }
protected void internalTransform(String phaseName, Map options)
{
System.out.println("Entering CFG transformer");
System.out.println("phaseName = " + phaseName);
System.out.println("options = " + options);
CallGraph cg = Scene.v().getCallGraph();
SootMethod m = Scene.v().getMainMethod();
Iterator targets = new Targets(cg.edgesOutOf(m));
while (targets.hasNext()) {
SootMethod trgt = (SootMethod)targets.next();
System.out.println(m.getName() + " -> " + trgt.getName() + ";");
}
System.out.println("Exiting CFG transformer");
}
}