[Soot-list] jump targets and weird label placement

Eric Bodden bodden at st.informatik.tu-darmstadt.de
Fri Aug 6 03:28:31 EDT 2010


Hi Lonnie.

insertBefore(a,b) does some redirection of jumps to "b". See
PatchingChain.insertBefore(..). I think this will be the cause of what
you see. There's another method insertBeforeNoRedirect(..) which may
be more appropriate in your situation.


Eric

--
Dr. Eric Bodden
Software Technology Group, Technische Universität Darmstadt, Germany
Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt



On 5 August 2010 19:17, Lonnie Princehouse <lonnie.princehouse at gmail.com> wrote:
> I've encountered some strange behavior with JTableSwitchStmt, where Soot
> seemingly generates a label in the wrong place.
> This happens when a JTableSwitchStmt is created with a jump target
> immediately following where the JTableSwitchStmt will be inserted.
>
> Unit target1, target2, target3 = ...;
>
> Unit switchStmt = new JTableSwitchStmt(foo, 0, 1,
>                Arrays.<Unit>asList(target1, target2), target3); // default
>
> body.getUnits().insertBefore(switchStmt, target3);
>
> This results in jimple code like this:
>
> label3:
>   tableswitch($foo)
>         {
>             case 0: goto label1;
>             case 1: goto label2
>             default: goto label3;
>         };
>
> The default case now causes an infinite loop. Really, we want label3 to come
> after the tableswitch statement.
> This workaround seems to solve the problem, although I have no idea why:
>
> // instead of inserting before target3, insert after predecessor of target3
> body.getUnits().insertAfter(switchStmt, body.getUnits().getPredOf(target3));
>
> As I said, the workaround fixes it, but I thought I'd put it out there as an
> FYI that there may be something weird with label generation.
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
>


More information about the Soot-list mailing list