[Soot-list] Multiple runs of Soot

Eric Bodden eric.bodden at mail.mcgill.ca
Fri Jul 10 11:04:50 EDT 2009


Hi Campbell.

...
> 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:
...
> 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?

Yes, one way would be to use both line numbers and column positions.
That should disambiguate things in every case. Actually people have
been working hard on attaching column positions as often as possible
when converting Java source to Jimple exactly for that purpose.
*Generally* what you want is attach some piece of information
(whatever that may be) to the Jimple statements in the form of a Tag,
i.e. an Object of a class that implements soot.tagkit.Tag
(http://www.sable.mcgill.ca/soot/doc/soot/tagkit/Tag.html). This
*could* be a tag that holds line numbers and column information (such
tags already exist:
http://www.sable.mcgill.ca/soot/doc/soot/tagkit/SourceLnPosTag.html)
or it could even be a tag that holds your eclipse/JDT AST node. Maybe
the latter is more suitable in your case. How do you translate the
eclipse AST to Jimple anyway? Do you do this yourself or do you have
Soot read in the Java source file? If you work directly on the AST
then surely attaching the AST node seems to make more sense.

> 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.

Yes: G.v().reset() should reset every static variable in Soot.

Eric
-- 
Eric Bodden
Sable Research Group, McGill University
Montréal, Québec, Canada


More information about the Soot-list mailing list