[Soot-list] ifStmt transformation
Bernhard Berger
berber at tzi.de
Mon May 20 03:53:38 EDT 2013
Hi,
a Chain is "simple" list of statements and the insertBefore operation inserts a object X before a object Y. I'm not expecting the chain to take care of gotos and so forth (if you have label0: stmt_1 in your Jimple code it will not insert a statement between the label and the statement).
Regarding your transformation I see no problem.
Regards,
Bernahrd
Am 20.05.2013 um 09:22 schrieb Zeinab Lashkaripour <lashkaripour at yahoo.com>:
> Hi Bernhard,
>
> Again I should thank you for the nice explanation.
> If I want to add my ifStmt before the specific Stmt and I use insertBefore is the result as I want?
> if (condition)
> statement
>
> I mean that is the Stmt not repeated again in the chain due to using insertBefore or does Soot take care of it?
>
> Another question that I have and I would be grateful if you guided me is also related to transformation:
> I process UD chains, then iterate through the CFGs of the methods I have and look for specific statements.
> After finding them, I perform some processing on the UDs and depending on the results I need to transform my code.
> The question I have is that depending on the result I might need to transform a statement that I have iterated through before my specific statement.
> Am I able to perform my transformations?
>
> Regards,
> Zeinab
> From: Bernhard Berger <berber at tzi.de>
> To: Zeinab Lashkaripour <lashkaripour at yahoo.com>
> Cc: "soot-list at sable.mcgill.ca" <soot-list at sable.mcgill.ca>
> Sent: Monday, May 20, 2013 11:20 AM
> Subject: Re: [Soot-list] ifStmt transformation
>
> 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/0440f17a/attachment.html
More information about the Soot-list
mailing list