[Soot-list] Issue Loading Method Bodies
Eric Bodden
eric.bodden at uni-paderborn.de
Wed Sep 12 02:31:32 EDT 2018
Hi Chris, hi all.
The recommended way to run _any_ whole-program analysis in Soot, including Heros, is to execute it within the “wjtp” pack. You need to create a new SceneTransformer callback which inside its tranasform-method contains exactly the code you have to execute Heros. This SceneTransformer you then add to the wjtp pack. Then _afterwards_ you call Soot’s main method. That should also take care of the body-release issue, as then Heros will execute before bodies are released.
Best wishes
Eric
> On 11. Sep 2018, at 18:37, Chris Shiflet <cshiflet at pjrcorp.com> wrote:
>
> Hi Manuel,
>
> The "-no-writeout-body-releasing" option you suggested corrected my issue. There is an active method body present after setting it to true using the follow line:
>
> Options.v().set_no_writeout_body_releasing(true);
>
> Thanks also for the tip about "Scene.v().loadNecessaryClasses()". Out of curiosity, should I be running Heros elsewhere rather than after executing "soot.Main.main()"?
>
> Thank you for your help!
> ---Chris
>
> -----Original Message-----
> From: Manuel Benz <manuel.benz at uni-paderborn.de>
> Sent: Tuesday, September 11, 2018 9:51 AM
> To: Eric Bodden <eric.bodden at uni-paderborn.de>; Chris Shiflet <cshiflet at pjrcorp.com>
> Cc: Soot list <soot-list at sable.mcgill.ca>
> Subject: Re: [Soot-list] Issue Loading Method Bodies
>
> Hi Chris.
>
> Can you try the "-no-writeout-body-releasing" option?
> Soot releases method bodies on write out by default. Since you are using IFDS after running "soot.Main.main()", write out should already have taken place.
>
> BTW. You do not need to call "Scene.v().loadNecessaryClasses();" manually if you're running Soot by calling "soot.Main.main()" .
>
> Best,
> Manuel
>
> Am 11.09.18, 13:37 schrieb "Soot-list im Auftrag von Eric Bodden" <soot-list-bounces at CS.McGill.CA im Auftrag von eric.bodden at uni-paderborn.de>:
>
> Hmm, does the code for this method exist on the classpath you provide to Soot?
>
> com.example.UISample.JSONProject: void main(java.lang.String[])
>
> Cheers
> Eric
>
>> On 10. Sep 2018, at 16:55, Chris Shiflet <cshiflet at pjrcorp.com> wrote:
>>
>> Hi Eric,
>>
>> Yes, I do enabled whole-program mode. I neglected to include them in my code snippet. These lines appears just before the snippet in my previous message.
>>
>> Options.v().set_whole_program(true);
>> Options.v().set_app(true);
>>
>> Thanks,
>> ---Chris
>>
>> -----Original Message-----
>> From: Eric Bodden <eric.bodden at uni-paderborn.de>
>> Sent: Monday, September 10, 2018 3:29 AM
>> To: Chris Shiflet <cshiflet at pjrcorp.com>
>> Subject: Re: [Soot-list] Issue Loading Method Bodies
>>
>> Hi Chris.
>>
>> Do you have whole-program-mode enabled? (-w flag) I cannot see this in your code.
>>
>> Cheers
>> Eric
>>
>>> On 7. Sep 2018, at 22:02, Chris Shiflet <cshiflet at pjrcorp.com> wrote:
>>>
>>> Hi all,
>>>
>>> I'm having an issue with loading method bodies when I attempt run the HEROS IFDS solver. Let me start with my stack trace:
>>>
>>> Running Heros IFDS Solver...
>>> Exception in thread "main" java.lang.RuntimeException: no active body present for method <com.example.UISample.JSONProject: void main(java.lang.String[])>
>>> at soot.SootMethod.getActiveBody(SootMethod.java:359)
>>> at soot.jimple.toolkits.ide.exampleproblems.IFDSReachingDefinitions.initialSeeds(IFDSReachingDefinitions.java:170)
>>> at heros.solver.IFDSSolver$1.initialSeeds(IFDSSolver.java:68)
>>> at heros.solver.IDESolver.<init>(IDESolver.java:200)
>>> at heros.solver.IDESolver.<init>(IDESolver.java:165)
>>> at heros.solver.IFDSSolver.<init>(IFDSSolver.java:52)
>>> at <redacted calling method in my code>
>>>
>>> This is the line where I instantiate IFDSSolver (reacted in the stack trace). You can see it in context later, but I've provided it here for reference:
>>>
>>> IFDSSolver<Unit, Pair<Value, Set<DefinitionStmt>>,
>>> SootMethod, InterproceduralCFG<Unit, SootMethod>> solver =
>>> new IFDSSolver<Unit, Pair<Value, Set<DefinitionStmt>>, SootMethod, InterproceduralCFG<Unit, SootMethod>>(problem);
>>>
>>> I am able to successfully perform the following earlier in the code:
>>> * Build a call-graph using SPARK (shown below), and
>>> * Process active method bodies with BodyTransformer and SceneTransformer in the jtp and wjtp packs, respectively (not shown).
>>>
>>> The code leading up to the above error is as follows:
>>>
>>> Options.v().setPhaseOption("cg", "safe-newinstance:true");
>>> Options.v().setPhaseOption("cg.cha","enabled:false");
>>>
>>> // Enable SPARK
>>> Options.v().setPhaseOption("cg.spark","enabled:true");
>>> Options.v().setPhaseOption("cg.spark","verbose:true");
>>> Options.v().setPhaseOption("cg.spark","on-fly-cg:true");
>>>
>>> Options.v().set_allow_phantom_refs(true);
>>> Options.v().set_output_format(Options.output_format_class);
>>>
>>> Options.v().set_main_class(mainClass);
>>>
>>> SootClass c = Scene.v().loadClass(mainClass, SootClass.BODIES);
>>> c.setApplicationClass();
>>>
>>> SootMethod entryPoint = c.getMethodByName("main");
>>> List<SootMethod> entryPoints = new ArrayList<SootMethod>();
>>> entryPoints.add(entryPoint);
>>> Scene.v().setEntryPoints(entryPoints);
>>>
>>> Scene.v().loadNecessaryClasses();
>>>
>>> // Set output dir
>>> Options.v().set_output_dir(outputDir);
>>>
>>> // Execute Soot
>>> soot.Main.main();
>>>
>>> // Run Heros IFDS Solver...
>>> JimpleBasedInterproceduralCFG icfg= new JimpleBasedInterproceduralCFG();
>>> System.out.println("1");
>>> IFDSTabulationProblem<Unit, Pair<Value,
>>> Set<DefinitionStmt>>, SootMethod,
>>> InterproceduralCFG<Unit, SootMethod>> problem = new IFDSReachingDefinitions(icfg);
>>>
>>> System.out.println("2");
>>> IFDSSolver<Unit, Pair<Value, Set<DefinitionStmt>>,
>>> SootMethod, InterproceduralCFG<Unit, SootMethod>> solver =
>>> new IFDSSolver<Unit, Pair<Value, Set<DefinitionStmt>>, SootMethod, InterproceduralCFG<Unit, SootMethod>>(problem);
>>>
>>> System.out.println("Starting solver");
>>> solver.solve();
>>> System.out.println("Done");
>>>
>>> Any help is much appreciated!
>>>
>>> Best,
>>> ---Chris
>>> _______________________________________________
>>> Soot-list mailing list
>>> Soot-list at CS.McGill.CA
>>> https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
>>
>>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at CS.McGill.CA
> https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
>
>
More information about the Soot-list
mailing list