[Soot-list] Can soot have multiple runs to collect some info beforehand?

Eric Bodden eric.bodden at mail.mcgill.ca
Thu Jul 23 05:04:29 EDT 2009


Hi Kelvin.

Yes, the best way to go about this would be to add two transforms.
Transforms are executed one after the other. So when you add two
transforms (a) and (b) then Soot will first execute (a) on all bodies
(here you can collect your information and store it in a global data
structure) and then it will execute (b) on all bodies (here you can
use the information).

About printing information when the instrumented program exits:
The most reliable way, but also a bit more tricky than the "before
return in main method" way is to add to the beginning of the "main"
method a call to Runtime.getRuntime().addShutdownHook(..). Then have
the shutdown hook print whatever information you want it to print.
Note, though that the hook runs in a separate thread. Hence you may
have to use synchronization too.

http://java.sun.com/j2se/1.4.2/docs/guide/lang/hook-design.html

Eric

2009/7/22 Kelvin Tian <kevinn.tian at gmail.com>:
> Dear Eric,
>
>     Great thanks for your help!  I've successfully output the line number of
> the statements I want.
>     But I found one problem with Soot, Soot seems to instrument functions up
> to down in a class file.  Currently I output all the instrumentation just
> before the return statement in main() function by adding some output
> statements.  But that's on condition of that all other functions are above
> main() function. If I put some functions below main() function, the
> instrumentation info of those functions would not output, as Soot instrument
> those functions after instrumenting main() function.   So does Soot have
> some support for several runs to collect some information beforehand, which
> means previous runs of soot can collect some information useful for later
> runs of Soot?
>
>    BTW, what's the good location to output all the profiling information,
> other than before the return statement in main() function?
>
>
> --
> Best regards,
> Kelvin
>
>
>
> On Thu, Jul 16, 2009 at 2:56 PM, Eric Bodden <eric.bodden at mail.mcgill.ca>
> wrote:
>>
>> Hi.
>>
>> If by location you mean source-code line numbers then the answer is
>> yes. Just use the -keep-line-number command-line flag and then look
>> for a SourceLnPosTag using stmt.getTags(..). There's more on this in
>> the archive of this list.
>>
>> Eric
>>
>> 2009/7/16 Kelvin Tian <kevinn.tian at gmail.com>:
>> > Hi,
>> >
>> >      I wonder if Soot has some way to record the location of a certain
>> > statement,  to build some kind of mapping between a certain statement
>> > (ie:
>> > loop) and the location  (ie. line number in a xx class file) ?  So that
>> > I
>> > can revisit a certain statement I want?  Thanks a lot for any
>> > suggestions!
>> >
>> >
>> > --
>> > Best regards,
>> > Kelvin
>> >
>> > _______________________________________________
>> > Soot-list mailing list
>> > Soot-list at sable.mcgill.ca
>> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>> >
>> >
>>
>>
>>
>> --
>> Eric Bodden
>> Sable Research Group, McGill University
>> Montréal, Québec, Canada
>
>



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


More information about the Soot-list mailing list