[Soot-list] Jimple: distinguish if and if else

Eric Bodden bodden at st.informatik.tu-darmstadt.de
Thu Mar 31 11:14:04 EDT 2011


Hi Pedro.

Thanks for the visualization. That helps.

One way to do this is to use a dominator analysis, e.g.
MHGDominatorsFinder. A statement s post-dominates a statement t if
every path starting at t has to go through s.

In the if-example you have, the statement that the if-statement jumps
to, i.e., the nop at the bottom, post-dominates the if-statement
itself. In the if-else-example, this is not the case: there is a path
(the left branch) which goes through the if statement but never goes
through the nop statement that the if jumps to.

HTH,
Eric

On 31 March 2011 16:46, Pedro Louro <pedrolour at gmail.com> wrote:
> Hello Eric,
>
> I´m not getting how can I test if some statement is the end of the if
> block or not.
> Giving a visual example, in attachment there are two examples, one
> normal if and one if else.
> In both cases the JIfStmt points to two different statements - I get
> one by the units.getSuccOf and the other by the UnitBoxes - the nop,
> and the goto nop.
> The difference is that in the normal if the nop is the end of the if
> block, which is not the case with if else. I´ve tryied the
> getBoxesPointingToThis().size() but the number is 1 in both cases.
>
> Thank you for your great help!
>
> Best Regards
> Pedro Louro
>
> On 31 March 2011 08:20, Eric Bodden
> <bodden at st.informatik.tu-darmstadt.de> wrote:
>> Hi Pedro.
>>
>> I think that's something you can just figure out by looking at the
>> code following the if statement. If after the if statement you have a
>> jump directly to the end of the "if block" then it's a "normal if". If
>> there's other code in front of that goto then you have an
>> if-then-else.
>>
>> Eric
>>
>> On 31 March 2011 02:25, Pedro Louro <pedrolour at gmail.com> wrote:
>>> Hello,
>>>
>>> When I´m analysing a JIfStmt, is there any practical way of
>>> distinguish if it is just an if or an if+else?
>>> In any case the JIfStmt has a bifurcation and I´m not seeing a
>>> straight forward way to test this.
>>>
>>> Best Regards
>>> Pedro Louro
>>> _______________________________________________
>>> Soot-list mailing list
>>> Soot-list at sable.mcgill.ca
>>> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>>>
>>
>>
>>
>> --
>> Dr. Eric Bodden, http://bodden.de/
>> Principal Investigator in Secure Services at CASED
>> Coordinator of the CASED Advisory Board of Study Affairs
>> PostDoc at Software Technology Group, Technische Universität Darmstadt
>> Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
>> Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>>
>



-- 
Dr. Eric Bodden, http://bodden.de/
Principal Investigator in Secure Services at CASED
Coordinator of the CASED Advisory Board of Study Affairs
PostDoc at Software Technology Group, Technische Universität Darmstadt
Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt


More information about the Soot-list mailing list