[Soot-list] ifStmt transformation

Bernhard Berger berber at tzi.de
Mon May 20 02:50:28 EDT 2013


Hi Zeinab,

generating Jimple is not easy. You have to remember that every "line" in a Jimple file corresponds to a statement [1]. There you can see all possible subtypes of Stmt (such as an IfStmt). Inside of statements you can place Values [2]. In your case the second line in your Jimple code is a IfStmt containing an EqExpr. The EqExpr contains a Local ($z0) and an IntConstant. Theoretical you can add a InvokeExpr instead of the Local but I'm always carful because there is lots of code that expects the Jimple code to be the way it's generated by the frontend.
Labels do not exist in the memory version of Jimple. They are resolved to references to statements. Take the following pseudo Jimple code:

Stmt_1;
Stmt_2;
if x == 0 goto label0;
Stmt_3;
Label0:
Stmt_4;

After loading this code into memory the target of the IfStmt will point to Stmt4.

That's all Folks,
Bernhard

[1] http://www.sable.mcgill.ca/soot/doc/index.html?soot/jimple/Stmt.html
[2] http://www.sable.mcgill.ca/soot/doc/index.html?soot/Value.html

Am 19.05.2013 um 21:45 schrieb Zeinab Lashkaripour <lashkaripour at yahoo.com>:

> Hi everyone,
> 
> I would be grateful if some one guided me.
> I need to add a function call in an ifStmt before a specific statement in the chain (As below).
> (params stands for the parameters of the "fn")
>     if ( fn(params) )     
>     {
>         statement in chain.
>     }
> I tried to work the other way round, I know that the equivalent Jimple is like below:
>     $z0 = staticinvoke <class: boolean fn(param types)>(params);        
>     if $z0 == 0 goto label2;
>         statement in chain
> 
> I tried some code but got no result, I only know how to generate the green part. 
> Do I need a ConditionExprBox?
> Can I not use the "fn" call directly in ifStmt?
> What about the label? How do I get the value of label?
> 
> If there is anything else that I need to take care of, I would be happy to know.
> Thanks in advance.
> 
> Regards,
> Zenab
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130520/5fd6884a/attachment.html 


More information about the Soot-list mailing list