[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Extend Jimple keywords
Okay, so I found Bandera at
http://www.cse.msu.edu/sens/Software/Bandera/bandera/ and I see it has
JJJC which is a Java to Jimple compiler; it also has a Jimple to Java
decompiler. I assume this is what you are doing... and so have more
questions for you. :-)
VO Duc Duy <duy.voduc@epfl.ch> wrote:
> class A{
> ...
> public void main(){
> *select*{
> *case* *accept* my_method;
> blockStmt0;
> *case* caller.its_method(param);
> blockStmt1;
> }
> }}
Could you explain what the above code means?
> the idea to translate the above code to jimple is the following:
>
> ---------------------
> class A extend java.lang.Object{
> public static void main(java.lang.String[]){
> LinkedList list;
> ...
> *addCase* list my_method;
> *addCase* list caller calling_method;
> PC = *searchPair* list; // search the pair that is active from calling
> and called objects
> lookupswitch(PC){
> case 0: goto label0;
> case 1: goto label1;
> }
> label0:
> //do something
> blockStmt0;
> goto label2:
> label1:
> staticinvoke [caller.its_method():void](param);
> blockStmt1;
> label2:
> ...
> ---------------------
It would be nice if you could explain the above code as well... What
are you planning to do with the new keywords? Does it help your
analysis?
> The new keywords I wanted to add are: *addCase*, *searchPair*. As what I
> understood, I will:
> 1) implement the classes such as the ones of monitor (JEnterMonitorStmt,
> EnterMonitorStmt, SwitchStmt, etc). They are used to generate addCase,
> searchPair statements together with other keywords of jimple.
Implementing a new keyword should be fairly easy if that's all you
want to do. You'll have to fix your decompiler mind, and that might
not be trivial.
You might be interested in looking at Shimple, which is the same as
Jimple with only one new construct added (Phi expressions):
http://svn.sable.mcgill.ca/viewcvs/soot/trunk/src/soot/shimple/
To do this I added PhiExpr.java (an interface) and I implemented it in
internal/SPhiExpr.java . Then all I had to do was provide a
constructor for it in Shimple.java (newPhiExpr).
If you're using a StmtSwitch or something, you'll of course have to
update that for your new keywords. In my case since I didn't add a
keyword, only an Expr, I made new ExprSwitch and ValueSwitch.
> 2) implement a class that contains the method addCase (LinkedList,
> callerObject, String), searchPair(LinkedList).
> These methods are used when the jimple reader (a tool that scans jimple
> statements and analyzes them) arrives at addCase, searchPair statements.
Well you said addCase was a keyword... or is it a method? If it's
only a method then maybe you don't need to implement a new keyword.
Cheers,
Navin.