[Soot-list] Extract method with preserved jumps

Attila Bartha at.bartha at gmail.com
Sat Nov 28 04:32:45 EST 2009


Hi Eric

Thank you, it works now with cloned units. 
Cloning units preserves references to locals as well as targets of jumps.
Targets must be changed, obviously. 

For locals, it depends, I guess. So far it works fine, if I use the same
instances in both bodies.
Do you know any existing analysis for which locals definitely have to be
cloned, too?

Attila


-----Original Message-----
From: eric.bodden at googlemail.com [mailto:eric.bodden at googlemail.com] On
Behalf Of Eric Bodden
Sent: Mittwoch, 25. November 2009 19:51
To: Attila Bartha
Cc: soot-list
Subject: Re: [Soot-list] Extract method with preserved jumps

Hi Attila.

You should never ever try to use the *same* Unit instances in multiple
method bodies. Always try to clone the units or to somehow else make
copies of them. Otherwise you will definitely run into the problems
you mention.

JimpleBody implements a clone() method. I think that should help you there.

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/11/25 Attila Bartha <at.bartha at gmail.com>:
> Hi
>
>
>
> I am trying to extract selected Jimple code into a new method, i.e. move a
> range of units from body A to a new method’s body B.
>
> Adding the units to the B’s unit chain works fine. Jumps are preserved.
>
> However, when I remove those units form A’s unit chain, the jumps are
> removed, too. Thus, it changes the units in B!
>
> This is probably because PatchingChain remove(Object) calls
> ((Unit)obj).redirectJumpsToThisTo(successor); , and there is no
alternative
> remove method.
>
>
>
> How can I make sure that the jumps are preserved when removing them from
A?
>
> Is there such an example in one of the existing transformations?
>
> Or can it be fixed by replacing A’s unit chain with a new one to avoid
> having to call remove() ?
>
>
>
> Regards
>
>
>
> Attila
>
>
>
> _______________________________________________
> 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