[Soot-list] How to have whole-program analysis run from non-main() methods

Jiaqi Tan tanjiaqi at gmail.com
Tue Dec 13 11:22:40 EST 2011


Hi,

I'm working off of soot-2.4.0 and it seems that Scene does not have a
hasCustomEntryPoints() method, should I be working off the nightly
instead?

Thanks,
Jiaqi

On Tue, Dec 13, 2011 at 12:31 AM, Eric Bodden <eric.bodden at ec-spride.de> wrote:
> Yes, actually that did help, thanks. It appears that the method
> soot.jimple.toolkits.callgraph.CallGraphPack.internalApply() is
> missing a crucial check to avoid overriding the entry points you set.
>
> Can you try replacing...
>
>                if(!options.implicit_entry()) {
>                    Scene.v().setEntryPoints(EntryPoints.v().application());
>                }
>                if( options.all_reachable() ) {
>                    List<SootMethod> entryPoints = new ArrayList<SootMethod>();
>                    entryPoints.addAll( EntryPoints.v().all() );
>                    entryPoints.addAll(
> EntryPoints.v().methodsOfApplicationClasses() );
>                    Scene.v().setEntryPoints( entryPoints );
>                }
>
> ...by...
>
>        if(!Scene.v().hasCustomEntryPoints()) {
>            //original code
>        }
>
> ? Does this help? If yes, then I can commit this change to the repository.
>
> Eric
>
> On 12 December 2011 17:20, Jiaqi Tan <tanjiaqi at gmail.com> wrote:
>> Hi Eric,
>>
>> Here is the stack trace:
>> Exception in thread "main" java.lang.RuntimeException: There is no
>> main class set!
>>        at soot.Scene.getMainClass(Scene.java:160)
>>        at soot.EntryPoints.application(EntryPoints.java:65)
>>        at soot.EntryPoints.all(EntryPoints.java:95)
>>        at soot.jimple.toolkits.callgraph.CallGraphPack.internalApply(CallGraphPack.java:43)
>>        at soot.Pack.apply(Pack.java:114)
>>        at soot.PackManager.runWholeProgramPacks(PackManager.java:408)
>>        at soot.PackManager.runPacks(PackManager.java:329)
>>
>> Does this help?
>>
>> Thanks,
>> Jiaqi
>>
>> On Mon, Dec 12, 2011 at 11:16 PM, Eric Bodden <eric.bodden at ec-spride.de> wrote:
>>> Hi Jiaqi.
>>>
>>> It's surprising that you see "There is no main class set!". This
>>> should not actually happen when custom entry points are defined. Could
>>> you use a debugger to tell me in which context this message is raised,
>>> i.e., in which context the method soot.Scene.getMainClass() is called?
>>>
>>> Cheers,
>>> Eric
>>>
>>> On 12 December 2011 14:13, Jiaqi Tan <tanjiaqi at gmail.com> wrote:
>>>> Hi Eric,
>>>>
>>>> This is what I am currently doing:
>>>>
>>>> 1. Retrieve all methods from class to use as current entry-points
>>>> (begin exploring call-graph from one class of interest) using the
>>>> following:
>>>>
>>>> Options.v().set_allow_phantom_refs(true);
>>>> PhaseOptions.v().setPhaseOption("jb", "enabled:true");
>>>> Scene.v().addBasicClass(className, SootClass.BODIES);
>>>> PackManager.v().runPacks();
>>>> SootClass c = Scene.v().loadClassAndSupport(className);
>>>>
>>>> 2. Set entry points:
>>>> List<SootMethod> entry = c.getMethods();
>>>> G.reset();
>>>> Options.v().set_whole_program(true); // same as "-w"
>>>> Options.v().set_allow_phantom_refs(true);
>>>> Options.v().set_app(true); // set application mode
>>>> Options.v().set_debug(true);
>>>> PhaseOptions.v().setPhaseOption("cg.cha", "enabled:true"); // true or off
>>>> Scene.v().setEntryPoints(entry);
>>>> Scene.v().loadNecessaryClasses();
>>>> PackManager.v().runPacks();
>>>>
>>>> 3a. When I run with this, I get an error message that the main-class is not set:
>>>> Exception in thread "main" java.lang.RuntimeException: There is no
>>>> main class set!
>>>>
>>>> 3b. When I run it with "Scene.v().setMainClass(clazz);" added before
>>>> setting the entry-points, where clazz is the SootClass returned from
>>>> above, I get this error instead:
>>>> Exception in thread "main" java.lang.RuntimeException: Main-class has
>>>> no main method!
>>>>
>>>> I'm not sure if I've missed something.
>>>>
>>>> Thanks!
>>>> Jiaqi
>>>>
>>>>
>>>> On Fri, Dec 9, 2011 at 5:16 PM, Eric Bodden <eric.bodden at ec-spride.de> wrote:
>>>>> Hello.
>>>>>
>>>>> Does this thread answer your questions?
>>>>> http://www.sable.mcgill.ca/pipermail/soot-list/2011-July/003799.html
>>>>>
>>>>> Eric
>>>>>
>>>>> On 8 December 2011 15:27, Jiaqi Tan <tanjiaqi at gmail.com> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I am trying to explore the whole-program call-graph of a program
>>>>>> completely by flooding it, including from non-main() functions (even
>>>>>> if this will create disconnected components in the call-graph).
>>>>>>
>>>>>> However, it seems that the current Soot whole-program analysis only
>>>>>> treats functions named as "main", or with a single String[] argument,
>>>>>> as main functions.
>>>>>>
>>>>>> Is there any particular restriction that requires the whole-program
>>>>>> analysis to begin from a main(String[]) function (i.e. it is just
>>>>>> impossible to begin whole-program exploration from a non-main()
>>>>>> function)? Or is it just that an arbitrary exploration was never
>>>>>> developed?
>>>>>>
>>>>>> Help would be much appreciated :)
>>>>>>
>>>>>> Thanks!
>>>>>> Jiaqi Tan
>>>>>> _______________________________________________
>>>>>> Soot-list mailing list
>>>>>> Soot-list at sable.mcgill.ca
>>>>>> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Eric Bodden, Ph.D., http://bodden.de/
>>>>> Head of Secure Software Engineering Group at EC SPRIDE
>>>>> Principal Investigator in Secure Services at CASED
>>>>> Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
>>>>> Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
>>>
>>>
>>>
>>> --
>>> Eric Bodden, Ph.D., http://bodden.de/
>>> Head of Secure Software Engineering Group at EC SPRIDE
>>> Principal Investigator in Secure Services at CASED
>>> Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
>>> Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
>
>
>
> --
> Eric Bodden, Ph.D., http://bodden.de/
> Head of Secure Software Engineering Group at EC SPRIDE
> Principal Investigator in Secure Services at CASED
> Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
> Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt


More information about the Soot-list mailing list