[Soot-list] Soot class instance

Bernhard Berger berber at tzi.de
Wed Dec 4 23:42:32 EST 2013


Hi,

creating Jimple by hand is not easy. Specialinvoke is the wrong invoke-type in your particular case. Do you create them manually? AFAIS your jimple-code should look like the following:

$lcl_1 = new record.Logger
specialinvoke $lcl_1.<record.Logger: void <init>()>();
$lcl_2 = new record.Structure;
specialinvoke $lcl_2.<record.Structure: void <init>()>();

virtualinvoke $lcl_2.<record.Structure: boolean setGenericParams()>();
virtualinvoke $lcl_1.<record.Logger: void log(record.Structure)>($lcl_2);


a) Add an InvokeStatement containing a specialinvoke to the constructor since the call is not part of new.
b) Use an InvokeStatement containing a virtualinvoke for calling the logging methods

I hope that this will help you.

Regards,

Bernhard

Am 03.12.2013 um 06:11 schrieb Satyaditya Munipalle <satyadit at buffalo.edu>:

> Hi Mr.Eric,
>                      I am trying to instrument my android app using soot .I am trying to assign a local variable to a class object so that i can call the methods of the class using it. I had noticed that my jimple output the <init>  is not being called  
> 	
> JAVA CODE:
>                                 Scene.v().loadClassAndSupport("record.Structure");
> 				SootClass structClass=Scene.v().getSootClass("record.Structure");
> 				SootMethod setGenericParams   = structClass.getMethod("boolean setGenericParams()");
>                                In the chain iterator I am trying to create an instance of the class. I had created the local as shown below
> 
>                               Local structLocal = Jimple.v().newLocal("$r" + locals.size(),structClass.getType());
> 							locals.add(structLocal);
> 
> 	                      //initializing struct class
> 				Value rValue=Jimple.v().newNewExpr(RefType.v(structClass));  
> 				Stmt newAssignStmt = Jimple.v().newAssignStmt(structLocal, rValue);
> 				logBlock.add(newAssignStmt);
> 				units.insertAfter(logBlock, stmt);
> 
> 
> 
> JIMPLE REPRESENTATION
>                      $r13 = new record.Logger;
>                     $r12 = new record.Structure;
>                    specialinvoke $r12.<record.Structure: boolean setGenericParams()>();  //NO INIT BEING CALLED
>                    specialinvoke $r13.<record.Logger: void log(record.Structure)>($r12);
> 
> 
> and  I am running into this particular error after writing this piece of code. 
> Exception
> 
> Exception in thread "main" java.lang.Error: unknown SpecialInvokeExpr (no call to constructor, super or private method): specialinvoke $r12.
> <record.Structure: boolean setGenericParams()>()
> 	at soot.toDex.ExprVisitor.caseSpecialInvokeExpr(ExprVisitor.java:129)
> 	at soot.jimple.internal.AbstractSpecialInvokeExpr.apply(AbstractSpecialInvokeExpr.java:117)
> 	at soot.toDex.StmtVisitor.caseInvokeStmt(StmtVisitor.java:566)
> 	at soot.jimple.internal.JInvokeStmt.apply(JInvokeStmt.java:101)
> 	at soot.toDex.DexPrinter.toInstructions(DexPrinter.java:348)
> 	at soot.toDex.DexPrinter.toCodeItem(DexPrinter.java:324)
> 	at soot.toDex.DexPrinter.toMethods(DexPrinter.java:248)
> 	at soot.toDex.DexPrinter.toClassDataItem(DexPrinter.java:211)
> 	at soot.toDex.DexPrinter.addAsClassDefItem(DexPrinter.java:202)
> 	at soot.toDex.DexPrinter.add(DexPrinter.java:510)
> 	at soot.PackManager.writeClass(PackManager.java:971)
> 	at soot.PackManager.writeOutput(PackManager.java:595)
> 
> Is this the right way of creating an object for a class?? Please help me
> 
> Regards,
> adit.
> _______________________________________________
> 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