[Soot-list] Multiple runs of Soot

Campbell Morrison cammorr at gmail.com
Fri Jul 10 06:00:51 EDT 2009


I have two problems that I can't seem to solve or find useful info on on any
of the Soot websites.  I'm using Soot in an Eclipse plugin I wrote myself.
It uses a custom transformer to do symbolic execution on Java files on a
Jimple level and do coverage calculation.

The first problem I have is with linking Jimple to the source code.  I need
to be able to link the Jimple Unit statements to the actual Java source code
instruction they were generated from.  A simple example of this is a
multi-conditional if:
Java
    public static byte mytest( byte b ) {
       byte i = -1;
       if( b == 2 && i == 2 ) {
          i = 4;
       }
       i++;
       return i;
    }

Jimple:
    public static byte mytest(byte)
    {
        byte b0, b1, b3;
        int $i2;

        b0 := @parameter0: byte;
        b1 = -1;
        if b0 != 2 goto label0;

        if b1 != 2 goto label0;

        b1 = 4;

     label0:
        $i2 = b1 + 1;
        b3 = (byte) $i2;
        return b3;
    }

In this, I need to be able to link *if b0 != 2 goto label0;* and *if b1 != 2
goto label0;* together to indicate that they come from the same if
statement.  My question is, is there a way to link the Jimple statements to
the Java source code statements?  It is very important to note that I *cannot
use line numbers*.  The reason I cannot use line numbers is because it is
syntactically correct, albeit not good coding practice, to have more than
one statement on a single line:
    public static byte mytest( byte b ) {
       b++; b++;  return b;
    }
It is also common practice, and makes code more legible, to split
multi-conditional if conditions over multiple lines:
    public static byte mytest( byte b ) {
       byte i = -1;
       if( b == 2
            && i == 2 ) {
          i = 4;
       }
       i++;
       return i;
    }
This is why I can't use line numbers.  Is there a way to link the Jimple
statements to Java source code statements without using line numbers?

The second problem I have is with the Soot execution environment.  Because
I'm writing a plugin, its operation will generally be used numerous times
during an execution of Eclipse.  The problem is that as soon as I run Soot
once, all its classes are instantiated and options set.  If I try to run
Soot again, it complains about variables already being set , timers already
initialized, etc.  At the moment I have to close Eclipse and run it again in
order to run Soot again.  My question therefore is is there a way "reset"
the Soot environment to allow me to run Soot more than once?  I tried
clearing all the variables in the soot.options.Options class, but it didn't
work.  My knowledge of the inner workings of Soot is somewhat limited, so I
don't know if it can't be done, or if I'm just missing something.

Thank you for an excellent program.  I'm using Soot for my Masters degree
and it's been great.  Just have these two issues I haven't been able to
figure out.

Thank you
  Campbell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20090710/12248607/attachment.html 


More information about the Soot-list mailing list