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

Eric Bodden eric.bodden at ec-spride.de
Mon Dec 12 10:16:43 EST 2011


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


More information about the Soot-list mailing list