[Soot-list] Transformation capablilities of Soot

Bernhard Berger berber at tzi.de
Wed May 15 03:51:07 EDT 2013


Hi Zeinab,

comments below:

Am 14.05.2013 um 16:48 schrieb Zeinab Lashkaripour <lashkaripour at yahoo.com>:

> > As far as I understood, you try to calculate the results of a StringBuffer. It's not easy to solve this problem since you have to take care of the complete StringBuffer-API and some parts of the String may not be visible (read from input or passed to a method). Have I understood you correctly?
> Yes you are right but in my case I don't have none visible parts although their value would not be clear till runtime.
> I need to concatenate the different parts of the LHS variable which I have processed and add it to my code. 
Aren't you trying to evaluate the operations on the StringBuffer instance? IIRC this isn't solvable with Heroes. I discussed the problem with Eric, once.

> > But take care of gotos and exceptions. 
> I can not see why this is an issue. Is that for the time that I want to add this statement at the end of the statements of a specific label or am I making a mistake?
> For example I have "var = value;" in my code that depending on its value I need to add a value to my local list. I don't understand why your point will matter in my case?
I do not know your particular use case. Assume you have the following code: StringBuffer sb = new StringBuffer(); if(condition) { sb.append("foo"); } sb.toString();  Depending on condition sb.toString() will evaluate to "" or "foo". It's getting even more complicated if "foo" is not a string constant but a method parameter. Or you are append the result of a method-call.  To sum up, for a general solution you have use an interprocedural analysis. I've no idea if you can exclude some of those cases.

Regards,

Bernhard

> 
> From: Bernhard Berger <berber at tzi.de>
> To: Zeinab Lashkaripour <lashkaripour at yahoo.com> 
> Cc: soot-list at sable.mcgill.ca 
> Sent: Tuesday, May 14, 2013 1:00 PM
> Subject: Re: [Soot-list] Transformation capablilities of Soot
> 
> Hi Zeinab,
> 
> Am 13.05.2013 um 21:18 schrieb Zeinab Lashkaripour <lashkaripour at yahoo.com>:
> 
>> > That is the reason why Bernhard and I have used templates to generate Jimple.
>> Could you please open up what you have done a little bit. Can we use these templates or not? 
> Modifying Jimple code by "hand" is a tedious task. Especially if you have to consider jumps and so forth and you try to generate large parts. I started to write a transformation engine for jimple where you can specify a pattern and a replacement in textual Jimple and the engine searches in the memory representation of jimple for the matches and replaces them -in memory- with the occurrences of the pattern. It is based on the ideas of TXL (http://www.txl.ca).  A simple example is inlining of special function calls (but it's a bad example since it's easy to do it programmatically):
> «transformation»
>   «replace»
>     virtualinvoke «obj1».<org.apache.jasper.runtime.HttpJspBase: void service(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)>(«obj2», «obj3»);
>   «end»
>   «by»
>     virtualinvoke «obj1».<org.apache.jasper.runtime.HttpJspBase: void _jspService(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)>(«obj2», «obj3»);
>   «end»
> «end»
> 
> Currently, the transformation is done in wjpp to have some benefits in the cg construction. Whether you can use this preliminary framework is hard to say since I did not understand your goal. Can you give us a specific example? As far as I understood, you try to calculate the results of a StringBuffer. It's not easy to solve this problem since you have to take care of the complete StringBuffer-API and some parts of the String may not be visible (read from input or passed to a method). Have I understood you correctly?
> 
> 
>> > 1. That looks like you want to do syntax-directed translation in order to determine the constant parts of that string concatenation. Am I right?
>> I don't know what you mean. 
>> The result of my analysis can be in the form of  (v1 = "...." + v + "..") which means that the value of the LHS variable (v1) can contain variables and constants. I wanted to know in order to insert this statement in my code do I have to perform the actions that are done in a Jimple code (using a StringBuilder and virtualinvoke) or is there a way to give such a value to a variable at once?
>> 
>> > 2. I have no idea what you want to ask...
>> In this question I want to add a value to the list that I have added to my locals and insert "list.add(value)" in my code. How can I do that?
> This sounds like you are trying to instrument your code. I'm confused. You have to create an InvokeStmt and add a VirtualInvokeExpr. The base is the list-local and the parameter is the value-local. But take care of gotos and exceptions. Otherwise your results may be invalid.
> 
> Regards,
> Bernhard
> 
> 
> 

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


More information about the Soot-list mailing list