0

Using Soot, I am trying to build the call graph. To my knowledge, the problem was that, dealing with APIs, there are no main methods to be used as entrypoints. I check more thoroughly what Soot was loading. The classes used are "correctly loaded" (I print their list from Scene.v().getClasses() and it shows the proper classes from the project (source and test-source).

Now, Soot keep rising the same exception when asking for a call graph with Scene.v().getCallGraph() :

java.lang.RuntimeException: No call graph present in Scene. Maybe you want Whole Program mode (-w).

I thus tried to add entry points manually, looking for methods in the test-suite to be used on that purpose. I discovered that, if the classes are loaded, their methods are not. This is the snippet I use though, found on Soot's tutorial to load classes methods :

    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();
        }
    }

But c.getMethods() return no methods... More, the call sm.retrieveActiveBody(); rise an exception :

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

This applies to almost all classes (test-classes excepted). What am I doing wrong ? Why are the methods rejected ?

2 Answers2

0

Did you use the command-line parameter -w as the error message suggest?

Eric
  • 1,343
  • 1
  • 11
  • 19
  • lol, oui. Programmatically, it is called `set_whole_program(boolean)` – Edouard Batot Nov 24 '17 at 21:09
  • I should also mention that the same commandline executed via `Options.v().Main()` or in the windows command produces a good set of jimple files (I am not sure their methods are ALL (exhaustively) full, but they look fine. – Edouard Batot Nov 24 '17 at 21:10
0

dude. You can have a try to write this:

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

lol maybe it helps you.