[Soot-list] Possible bug in PatchingChain.insertBefore(List, Object)

Prof. Laurie HENDREN hendren at cs.mcgill.ca
Thu Jun 1 08:25:12 EDT 2006


Hi Henry,

It might be a good idea for us to add a new insert method that
does as you intend.   I wouldn't want to change the existing
method because of the large amount of code already using Soot, which
may depend on the current behaviour.

Do you want to provide an alternate method and suggest a good name
for it.  We would have to document the difference between the
two methods.

Cheers, Laurie


+-----------------------------------------------------------------
| Laurie Hendren --- laurie.hendren at mcgill.ca
| Associate Dean (Academic), Faculty of Science,
| Dawson Hall, McGill University, 853 Sherbrooke St W,
| Montreal QC H3A 2T6 Canada, 514-398-7179, fax 514-398-1774
+----------------------------------------------------------------
| For contact and home page info as Professor, Computer Science:
| http://www.sable.mcgill.ca/~hendren   ---  hendren at cs.mcgill.ca
| Research: http://www.sable.mcgill.ca  http://aspectbench.org
+----------------------------------------------------------------

On Thu, 1 Jun 2006, Henry Falconer wrote:

> > > I have an idea that might partially explain this: some of the code I'm
> > > inserting contains jumps to 'point' that I want to keep intact after
> > > they're inserted. For example, say this block of code, 'toInsert', is a
> > > while loop that I've constructed. Before I insert the while loop, I've
> >set
> > > the target of the if statement at the top, which represents the loop
> > > condition, to the same 'point' that I'm passing to insertBefore(), so
> >that
> > > it exits properly when this loop is inserted into the method.
> > > insertBefore() now redirects the if statement's target, so that if the
> > > loop condition fails, it just jumps back to the loop condition again, so
> > > you have an infinite loop.
> >
> >You can always use insertAfter and redirect jumps yourself or insert
> >before and make sure to go back through those units you added and "fix"
> >the jumps.
>
> Yeah, that's what I've done, I wrote an alternative insertBefore() as a
> static method in my own code, and then I just call that instead of the Soot
> version. It doesn't use getBoxesPointingToThis(), but goes through the
> target chain looking for Ifs and Gotos, then redirects them if necessary,
> and then uses insertAfter() to insert 'toInsert'. That way, no jumps in
> 'toInsert' are ever affected.
>
> >The insertBefore(List toInsert, Unit point) method which takes a list to
> >insert reverses that list and then calls the other insertBefore(Unit
> >insert, Unit point) for each element in the list.. obviously this will
> >redirect any jumps that get added before the last (first) element.
>
> I tried to understand what the Soot code was doing and I thought this part
> was probably the source of the problem. My point is that inserting a while
> loop, or any code with a jump to the insertion point, seems like quite a
> reasonable thing to do - I'm sure I'm not the first person to have tried.
> Don't you think it makes more sense to alter the behaviour in Soot, rather
> than work around it? When the jump redirection is done, surely the expected
> behaviour is to exclude the code you're inserting? I can't think of any
> reason why the alternative would be considered correct.
>
> Henry
>
>
> _______________________________________________
> 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