使用烟灰,我正在尝试构建呼叫图。据我所知,问题是,在处理API时,没有主要方法可以用作入口点。我更彻底地检查了烟灰的加载。所使用的类是"正确加载的"(我从Scene.v().getClasses()
打印了他们的列表,它显示了项目中的适当类(源和测试源)。
现在,在要求Scene.v().getCallGraph()
的呼叫图:
java.lang.RuntimeException: No call graph present in Scene. Maybe you want Whole Program mode (-w).
我因此尝试手动添加入口点,寻找用于该目的的测试套件中的方法。我发现,如果加载了这些类,则它们的方法不是。这是我使用的片段,在烟灰的教程上可以加载类方法:
SootClass c = Scene.v().loadClassAndSupport(name);
c.setApplicationClass();
Iterator<SootMethod> mi = c.getMethods().iterator();
while (mi.hasNext()) {
SootMethod sm = (SootMethod)mi.next();
if (sm.isConcrete()) {
sm.retrieveActiveBody();
}
}
但是c.getMethods()
返回没有方法...更多,呼叫sm.retrieveActiveBody();
提高了一个例外:
java.lang.RuntimeException: Failed to apply jb to <com.[...classified...].resource.VoidResource: void <init>()>
at soot.asm.AsmMethodSource.getBody(AsmMethodSource.java:1911)
at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:126)
at soot.SootMethod.retrieveActiveBody(SootMethod.java:385)
at ca.umontreal.iro.soot.CallGraphExample.loadClass(CallGraphExample.java:204)
at ca.umontreal.iro.soot.CallGraphExample.loadClasses(CallGraphExample.java:139)
at ca.umontreal.iro.soot.CallGraphExample.loadClasses(CallGraphExample.java:157)
at ca.umontreal.iro.soot.CallGraphExample.loadClasses(CallGraphExample.java:157)
at ca.umontreal.iro.soot.CallGraphExample.loadClasses(CallGraphExample.java:157)
at ca.umontreal.iro.soot.CallGraphExample.loadClasses(CallGraphExample.java:157)
at ca.umontreal.iro.soot.CallGraphExample.loadClasses(CallGraphExample.java:157)
at ca.umontreal.iro.soot.CallGraphExample.loadClasses(CallGraphExample.java:157)
at ca.umontreal.iro.soot.CallGraphExample.main(CallGraphExample.java:95)
Caused by: java.lang.IllegalStateException: RefType java.lang.InstantiationError not loaded. If you tried to get the RefType of a library class, did you call loadNecessaryClasses()? Otherwise please check Soot's classpath.
at soot.Scene.getRefType(Scene.java:916)
at soot.toolkits.exceptions.ThrowableSet$Manager.<init>(ThrowableSet.java:213)
at soot.Singletons.soot_toolkits_exceptions_ThrowableSet_Manager(Singletons.java:1829)
at soot.toolkits.exceptions.ThrowableSet$Manager.v(ThrowableSet.java:277)
at soot.toolkits.exceptions.UnitThrowAnalysis.<init>(UnitThrowAnalysis.java:215)
at soot.toolkits.exceptions.UnitThrowAnalysis.<init>(UnitThrowAnalysis.java:231)
at soot.Singletons.soot_toolkits_exceptions_UnitThrowAnalysis(Singletons.java:1843)
at soot.toolkits.exceptions.UnitThrowAnalysis.v(UnitThrowAnalysis.java:246)
at soot.Scene.getDefaultThrowAnalysis(Scene.java:1324)
at soot.jimple.toolkits.scalar.UnreachableCodeEliminator.internalTransform(UnreachableCodeEliminator.java:78)
at soot.BodyTransformer.transform(BodyTransformer.java:54)
at soot.Transform.apply(Transform.java:105)
at soot.JimpleBodyPack.applyPhaseOptions(JimpleBodyPack.java:62)
at soot.JimpleBodyPack.internalApply(JimpleBodyPack.java:105)
at soot.Pack.apply(Pack.java:125)
at soot.asm.AsmMethodSource.getBody(AsmMethodSource.java:1909)
... 11 more
这几乎适用于几乎所有类(测试类别除外)。我究竟做错了什么 ?为什么拒绝方法?
您是否使用命令行参数-w作为错误消息建议?
花花公子。您可以尝试写这篇文章:
Options.v().set_whole_program(true);
Scene.v().loadNecessaryClasses();
PackManager.v().runPacks();
大声笑也许对您有帮助。