[Soot-list] try-catch-finally duplicate problem

Martin Schäf martinschaef at gmail.com
Tue Sep 2 14:30:49 EDT 2014


Two quick remarks that came up while working on a different problem:
- in soot-trunk.jar, you won't have line number tags if you analyze
bytecode (but works for source code) ... you can use soot-2.5.0.jar as a
workaround.
- from what I can see, you can identify the catch blocks in the actual
bytecode (running javap -v on the class file) because they show up as traps
with exception type "any" instead of "throwable". However, Soot translates
both into "throwable" so you lose this information ... this might be an
elegant way to find finally blocks.
Cheers,
M



On Tue, Sep 2, 2014 at 11:22 AM, Danijel Mlinarić <Danijel.Mlinaric at fer.hr>
wrote:

>  Steven, Martin thank you very much for your info.
>
> After searching for solution I was thinking that maybe I missed some
> feature in soot.
> I built method graph based on jimple statements, and I used subgraphs to
> determine and replace duplicated finally blocks.
> That solution probably doesn't cover all cases since variables are not
> exact duplicates as Martin stated.
> However I managed to eliminate goto statements and use some heuristics to
> handle variable problem, also as building traps hierarchy for nested cases.
>
> Didn't know that duplicated statements contain same line number in tags,
> this is very helpful to improve current solution.
> Thanks a lot.
>
> Regards,
> Daniel
>  ------------------------------
> *From:* Martin Schäf [martinschaef at gmail.com]
> *Sent:* Monday, September 01, 2014 17:28
> *To:* Steven Arzt
> *Cc:* Danijel Mlinarić; soot-list at cs.mcgill.ca
> *Subject:* Re: [Soot-list] try-catch-finally duplicate problem
>
>   Hi Daniel,
> not sure if it helps, but I hacked my way around this by just looking for
> subprograms that have the same type of statements and same line numbers but
> are not directly connected. Its not bullet proof but works for most cases.
> Its a bit tricky because the finally blocks are not exact duplicates.
> Variable names are different and sometimes a return turn into a goto.
> My code is here:
> https://github.com/martinschaef/jar2bpl/blob/master/jar2bpl/src/org/joogie/soot/SootBodyTransformer.java
> and the procedure you need is "
> detectDuplicatedFinallyBlocksAndCheckForSynchronizedStuff"
> Hope that helps,
> M
>
>
> On Sun, Aug 31, 2014 at 11:27 PM, Steven Arzt <Steven.Arzt at cased.de>
> wrote:
>
>> Hi Daniel,
>>
>> This happens because we get "duplicate" code from the various front-ends
>> (ASM, Dexlib). In more detail, the following is generated:
>>
>> * Run the code inside the try
>> * If an exception is caught inside the try, run the exception handler and
>> then the finally stuff
>> * If an exception is caught inside the exception handler, run the finally
>> code nevertheless
>> * If everything went alright, run the finally code
>>
>> Instead of producing copies of the finally code, we could also try to
>> identify such cases and always jump to the same label for the finally code.
>> This would then be a new features inside Soot.
>>
>> Best regards,
>> Steven
>>
>> Danijel Mlinarić <Danijel.Mlinaric at fer.hr> wrote:
>>
>>  Hello,
>>
>>  I'm trying to analyze try-catch-finally blocks using jimple and graphs,
>> problem is duplicated finally code after try and catch block.
>> Is there any way to get one finally block per try-catch-finally or soot
>> support some methods to determine equal duplicated blocks in jimple?
>>
>>  Any help is appreciated a lot.
>>
>>  Regards,
>> Daniel
>>
>> _______________________________________________
>> Soot-list mailing list
>> Soot-list at CS.McGill.CA
>> https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20140902/ce20799e/attachment.html 


More information about the Soot-list mailing list