[Soot-list] inter-procedural analysis on an android app

daniela antonova daniela.antonova at gmail.com
Thu Jan 6 20:18:11 EST 2011


Hi Bernhard,

I tried setting the entry points to onCreate(), etc. (by using
setEntryPoints()),
but I kept getting the "Main-class has no main method" error message.
I could not get rid of it, so I decided to use a dummy main class instead.
However this seems lame and I would really like to get the other
version running.
Do you have any ideas as to why this might be happening?

Thanks,
Daniela

>Hi Daniela,
>
>afais the problem is that the android apps have a completely different
>life-cycle. soot expects the main class to have a main method and
>android apps don't have one. You can try to write a dummy main that
>creates a new instance of your class and calls all the framework
>callbacks (onCreate and so on). Or you tell soot that these methods are
>entry points (there is a function to do so).
>Maybe you can tell me the results of your tests since I'm also
>interested in analysing android apps.
>
>Bernhard
>
>On Di, 2011-01-04 at 19:47 +0000, daniela antonova wrote:
> Hi,
>
> I would like to write an inter-procedural analysis to analyse Android apps.
> At the moment I am trying to create a call graph for an application.
> The problem is that the app doesn't have a main method and as a result
> I need to define
> entry points other than main method. I could not find an example that
> does that, so
> I would be very grateful for your help.
>
> This is the code I have so far:
> public static void main(String[] args) {
>
>               List<String> argsList = new ArrayList<String>(Arrays.asList(args));
>               argsList.addAll(Arrays.asList(new String[]{
>                               "-w",
>                               "-main-class",
>                               "testers.AddressBook2",//main-class
>                               "testers.AddressBook2"//argument classes
>               }));
>
>               PackManager.v().getPack("wjtp").add(new Transform("wjtp.myTrans",
> new SceneTransformer() {
>
>                       @Override
>                       protected void internalTransform(String phaseName, Map options) {
>                               CHATransformer.v().transform();
>                               SootClass a = Scene.v().getSootClass("testers.AddressBook2");
>
>                               SootMethod src = Scene.v().getMainClass().getMethodByName("onCreate");
>                               CallGraph cg = Scene.v().getCallGraph();
>
>                               Iterator<MethodOrMethodContext> targets = new Targets(cg.edgesOutOf(src));
>                               while (targets.hasNext()) {
>                                       SootMethod tgt = (SootMethod)targets.next();
>                                       System.out.println(src + " may call " + tgt);
>                               }
>                       }
>
>               }));
>
>               args = argsList.toArray(new String[0]);
>
>               soot.Main.main(args);
>
> I got this from the CallGraph example in the Soot source, but I have
> not been able to modify it so that I could get rid of the exception:
> 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.Scene.getEntryPoints(Scene.java:683)
>       at soot.Scene.getReachableMethods(Scene.java:730)
>       at soot.jimple.toolkits.callgraph.CallGraphBuilder.<init>(CallGraphBuilder.java:59)
>       at soot.jimple.toolkits.callgraph.CHATransformer.internalTransform(CHATransformer.java:42)
>       at soot.SceneTransformer.transform(SceneTransformer.java:39)
>       at soot.Transform.apply(Transform.java:89)
>       at soot.RadioScenePack.internalApply(RadioScenePack.java:57)
>       at soot.jimple.toolkits.callgraph.CallGraphPack.internalApply(CallGraphPack.java:47)
>       at soot.Pack.apply(Pack.java:114)
>       at soot.PackManager.runWholeProgramPacks(PackManager.java:408)
>       at soot.PackManager.runPacks(PackManager.java:329)
>       at soot.Main.run(Main.java:198)
>       at soot.Main.main(Main.java:141)
>       at RunInterProceduralAnalysis.main(RunInterProceduralAnalysis.java:64)
>
> Thank you very much for your help!
> Daniela
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list

--
Dipl. Inf. Bernhard Berger

TZI – Universität Bremen, AG Softwaretechnik
E-Mail  berber(at)tzi(dot)de

_______________________________________________
Soot-list mailing list
Soot-list at sable.mcgill.ca
http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list


More information about the Soot-list mailing list