[Soot-list] PatchingChain.insertBefore(Chain<E> toInsert, E point): bug?
Eric Bodden
bodden at st.informatik.tu-darmstadt.de
Thu Dec 10 02:28:34 EST 2009
Hi Khilan.
Thanks for the patch. This looks like a correct patch to an actual bug
to me. I will try it out with our test suite today.
Eric
--
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
2009/12/9 Khilan Gudka <khilan at doc.ic.ac.uk>:
> Hi,
> The method PatchingChain.insertBefore(Chain<E> toInsert, E point) inserts
> the chain "toInsert" just before "point" in the receiver chain. It does this
> by calling PatchingChain.insertBefore(E toInsert, E point) for each Unit in
> a reversed version of toInsert. To keep the correct control flow,
> PatchingChain.insertBefore(E toInsert, E point) redirects jumps to "point"
> to jump to "toInsert" instead. However, I've found that this leads to bugs
> when inserting a chain that contains jumps itself. For example, inserting
> the jimple code:
> if $r == 0 goto label0;
> staticinvoke <mypackage.MyClass: void m()>();
> label0:
> staticinvoke <mypackage.MyClass: void n()>();
> Which corresponds to:
> if($r) {
> MyClass.m();
> }
> MyClass.n();
> Would be turned into the following when using the
> above PatchingChain.insertBefore(Chain<E> toInsert, E point) method:
> label0:
> if $r == 0 goto label0;
> staticinvoke <mypackage.MyClass: void m()>();
> staticinvoke <mypackage.MyClass: void n()>();
> The reason being that when insertBefore(E toInsert, E point) is repeatedly
> called, the jump to "staticinvoke <mypackage.MyClass: void n()>();" is
> redirected to the first statement "if $r == 0 goto label0;".
> I think the solution is to, lastly, redirect jumps to "point" to the first
> unit in toInsert (here is a snippet from the bottom
> of PatchingChain.insertBefore(Chain<E> toInsert, E point) and the proposed
> changes are in bold):
> E previousPoint = point;
> Iterator<E> it = backwardList.iterator();
> while (it.hasNext())
> {
> E o = it.next();
> insertBeforeNoRedirect(o, previousPoint);
> previousPoint = o;
> }
> ((Unit) point).redirectJumpsToThisTo((Unit) toInsert.getFirst());
> Does this make sense or have I overlooked something?
> Thanks,
> Khilan
> _______________________________________________
> 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