[Soot-list] Traversing the static Instructions of a class which has no methods

ASHISH MISHRA ashish123.mishragkp at gmail.com
Fri Apr 19 04:21:34 EDT 2013


Thanks Saswat for the reply,

I actually tried that , but the issue is that in such a case The <clinit>
of the inner classes don't have any ActiveBody.

I am not able to figure out , why these methods dont have a Body and in
such a case how to get the AssignmentStmt of static fields.


I am posting the code below - this is what I am doing-


*package callgraphandroid;*
*
*
*import statements;*
*
*
*public class GenerateJimple {*
* *
* public static void main(String[] args) {*
* // get the argument List in an ArrayList*
* List<String> argList= new ArrayList<String>(Arrays.asList(args));*
* String[] soot_options= new String[]{*
* "-w",*
* "-pp",*
* "-p", *
* "jb",*
* "use-original-names:true",*
* "-cp",*
* ".",*
* *
* "-main-class",*
* args[0],*
* //"testers.test_context",*
* "-app",*
* args[0],*
* "-allow-phantom-refs",*
* //"-include-all",*
* //"testers.test_context",*
* "-f",*
* "jimple"*
* *
* *
* *
* *
* *
* };*
* *
*Transform andTransform = new Transform("wjtp.andalyze", new
SceneTransformer() {*
* *
* @Override*
* protected void internalTransform(String phaseName, Map options) {*
* *
* System.out.println("Hi I am here in wjtp");*
* Chain<SootClass> sclist = Scene.v().getApplicationClasses();*
* List<SootMethod> methodlist = Scene.v().getEntryPoints();*
* System.out.println(sclist.toString());*
* for(SootClass sc : sclist){ *
* List<SootMethod> classmethods = sc.getMethods();*
* *
* System.out.println("classmethods "+ classmethods);*
* for(SootMethod sm : sc.getMethods()) {*
* *
* System.out.println("THE CURRENT METHOD " +sm);*
* Body bd = sm.getActiveBody();  ///Place of RunTimeException *
* System.out.println("The method body for " +sm.getName());*
* System.err.println(bd);*
* Iterator<Unit> it = bd.getUnits().iterator();*
* while (it.hasNext()) {*
* Unit unit = (Unit) it.next();*
*  soot.jimple.Stmt st = (soot.jimple.Stmt)unit;*
* //Value vl = (Value)st;*
* if(st.containsInvokeExpr()){*
* InvokeExpr inex = st.getInvokeExpr();*
* System.out.println("statement type" + inex);*
* *
* }*
* *
* }*
* *
* } *
* } *
* *
* }*
* *
* });*


      * PackManager.v().getPack("wjtp").add(andTransform);
*
* *
*
*
* Options.v().parse(soot_options);*
* Scene.v().forceResolve(args[0], SootClass.BODIES);*
* SootClass c =Scene.v().loadClassAndSupport(args[0]);*
* c.setApplicationClass();*
* Scene.v().getSootClass("java.util.Iterator");*
* Scene.v().loadNecessaryClasses(); *
* //get the entry method , if it is not main*
* List<SootMethod> entryPoints =c.getMethods();*
* System.out.println("entrypoints "+ entryPoints);*
* *
* Scene.v().setEntryPoints(entryPoints);*
* System.out.println("HERE");*
* PackManager.v().runPacks(); *
* *
* *
*
*
* }*
*
*
*}*

This is the Exception I am getting-

*Exception in thread "main" java.lang.RuntimeException: no active body
present for method <com.example.android.contactmanager.R$id: void
<clinit>()>*
* at soot.SootMethod.getActiveBody(SootMethod.java:297)*
* at
callgraphandroid.GenerateJimple$1.internalTransform(GenerateJimple.java:93)*
* at soot.SceneTransformer.transform(SceneTransformer.java:39)*
* at soot.Transform.apply(Transform.java:89)*
* at soot.ScenePack.internalApply(ScenePack.java:43)*
* at soot.Pack.apply(Pack.java:114)*
* at soot.PackManager.runWholeProgramPacks(PackManager.java:418)*
* at soot.PackManager.runPacks(PackManager.java:336)*
* at callgraphandroid.GenerateJimple.main(GenerateJimple.java:160)*
* *
Please provide me some reasons for the behavior and possible solutions to
get the static field assignment statements.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130419/418363d2/attachment.html 


More information about the Soot-list mailing list