[Soot-list] recognize catch and finally blocks

Haipeng Cai@ND hcai at nd.edu
Fri May 24 13:44:39 EDT 2013


Thanks Marc-André for your input.

I have figured out my previous question by using ExceptionalBlockGraph and
Body.Traps combined.

The catch blocks can be retrieved from the blocks given by the graph,
linking the head unit to the handler unit of one of traps. By matching each
such possible pairs, all catch blocks will be obtained. Noting that each
candidate block starts with an assignment statement that evaluates
@caughtexception to a stack variable is helpful.

It has been more grouchy for me to retrieve the finally blocks. I currently
work around it by simply looking at the ending throw statement in each
blocks from the graph above, knowing that each finally block ends with such
a throw statement. This may not be an elegant way but did do the tricks for
my tasks now.

I actually tried and played with ExceptionUnitGraph too but it seems the
really useful info it provides for me is the map from Unit to Exception,
telling what are the exceptions each unit of the graph can throw. I did not
use it given the above solution works for me, though.

Thank you again.

On Fri, May 24, 2013 at 12:26 PM, Marc-André Laverdière-Papineau <
marc-andre.laverdiere-papineau at polymtl.ca> wrote:

> Hello,
>
> Sorry for the delay, that is not something I have been dealing with often.
>
> I am looking at ExceptionalUnitGraph. The docs say:
> For every ThrowInst or ThrowStmt Unit which may explicitly throw an
> exception that would be caught by a Trap in the Body, there will be an
> edge from the throw Unit to the Trap handler's first Unit.
>
> getExceptionalSuccsOf will refer you to to the catch, so that deals with
> your problem.
>
> I am not sure of how the finally handler works out. I would guess that
> you'd have to look for gotos in the catch handler.
>
> I hope that helps a bit.
>
> Marc-André Laverdière-Papineau
> Doctorant - PhD Candidate
>
> On 20/05/13 09:23 PM, Haipeng Cai at ND wrote:
> > Hello all,
> >
> > Trying to instrument in the catch block and finally block, if there is
> > any, I am not sure if some handy routines are available for (1) telling
> > if there is any such blocks in a given method or not, esp., catch and
> > finally block separately since there might be catch blocks without a
> > finally block; and (2) if (1) is true, locating or retrieving the blocks
> > so that manipulation in them can be performed such as instrumenting
> > probes as I am asking for.
> >
> > I found there are utility classes like ExceptionalBlockGraph
> >  ExceptionalUnitGraph, both of which can be instantiated with the active
> > body of a given SootMethod, do the instance member "getTails" provide
> > direct helps in this regard? The code comments say that it will return
> > exit points of the graphs, do that tell the catch and finally blocks?
> > But still this would not tell a catch block from a finally one.
> >
> > Any advice is appreciated a lot.
> >
> > -haipeng
> >
> >
> > _______________________________________________
> > Soot-list mailing list
> > Soot-list at sable.mcgill.ca
> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> >
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130524/1d8c62b7/attachment.html 


More information about the Soot-list mailing list