烟灰:场景中没有调用图!无法应用jb

时间:2017-11-21 16:00:27

标签: java soot

使用Soot,我正在尝试构建调用图。据我所知,问题在于,处理API时,没有主要方法可用作入口点。 我更彻底地检查了Soot的装载情况。使用的类是“正确加载的”(我从Scene.v().getClasses()打印它们的列表,它显示项目中的正确类(源和测试源)。

现在,当要求使用Scene.v().getCallGraph()

的呼叫图时,Soot继续上升相同的异常
java.lang.RuntimeException: No call graph present in Scene. Maybe you want Whole Program mode (-w).

因此我试图手动添加入口点,寻找测试套件中用于此目的的方法。我发现,如果加载了类,则它们的方法不是。这是我使用的代码片段,可以在Soot的加载类方法的教程中找到:

    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

这几乎适用于所有类(测试类除外)。 我究竟做错了什么 ?为什么这些方法被拒绝了?

2 个答案:

答案 0 :(得分:0)

您是否使用命令行参数-w作为错误消息建议?

答案 1 :(得分:0)

伙计。 你可以试试写这个:

Options.v().set_whole_program(true);
Scene.v().loadNecessaryClasses();
PackManager.v().runPacks();

lol 也许对你有帮助。