[Soot-list] Transformation capablilities of Soot

Bernhard Berger berber at tzi.de
Tue May 14 04:30:37 EDT 2013


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/20130514/fc2af5bb/attachment-0001.html 


More information about the Soot-list mailing list