Re: [abc-users] Determine a basic block

From: Eric Bodden <eric.bodden_at_mail.mcgill.ca>
Date: Mon, 21 Apr 2008 09:15:45 -0400

Hi Thomas.

I think the problem lies in:
abc.weaving.weaver.ShadowPointsSetter.setShadowPointsPass1(SootClass)

Right now this method is prepare to handle StmtShadowMatches and
BodyShadowMatches but I guess your shadow match is neither of those,
right? Therefore you might have to subclass ShadowPointsSetter. The
points is that you need to have created a correct version of
ShadowPoints with the correct begin/end Jimple statements.

Eric

On 21/04/2008, Thomas Pawlitzki <mailinglist_at_pawlitzki.name> wrote:
> Hello Eric,
>
> 2008/4/16, Eric Bodden <eric.bodden_at_mail.mcgill.ca>:
>
> > Yes that could work but that would certainly be overkill. try/catch is
> > modeled via traps in Jimple which is also cumbersome. Adding tags as I
> > proposed earlier would be a lot easier. You can add tags to any
> > soot.Unit just by calling unit.addTag(...).
>
>
> This i have done. Here is the snipped from my jrag-File:
>
> public void ExhibitBlock.jimplify2(Body b) {
> b.setLine(this);
> soot.jimple.Stmt startBlock = newLabel();
> startBlock.addTag(new
> abc.ja.iiia.soot.tags.BlockInfoTag(getJoinpointtype().type().typeName(),
> "block-start"));
> b.addLabel(startBlock);
>
> for(int i = 0; i < getNumStmt(); i++) getStmt(i).jimplify2(b);
>
> soot.jimple.Stmt stopBlock = newLabel();
> stopBlock.addTag(new
> abc.ja.iiia.soot.tags.BlockInfoTag(getJoinpointtype().type().typeName(),
> "block-stop"));
> b.addLabel(stopBlock);
> }
>
> Now I am able to identify block starts and ends in my
> BlockShadowMatch. I create a new BlockShadowMatch everytime a block
> end is found. The shadow match contains the begin and the end
> statement.
>
> But now i have difficulties in proceeding.
> I defined a new PointcutExpr BlockPointcutExpr (extending PointcutExpr)
> and craeted a weaving.aspectinfo.BlockPointcut.
>
> When i declare a block-pointcut for an advice i can compile the source
> without errors.
> But only before-advices act as desiered.
>
> Here are some snippets from my test-code:
>
> from my test class:
>
> public static void main(String[] args) {
>
>
> System.out.println("before the block");
> System.out.println();
>
> exhibit new Testing() {
> int times = 3;
> for(int i = 0; i < times; i++)
> System.out.println("Hello World! "+i);
> };
>
> System.out.println();
> System.out.println("after the block");
>
>
> Test t = new Test();
> t.foo();
> }
>
>
> The exhibit new Testing is the block i want to be matched.
>
> And here are my test-advices:
> before() : block (aspectjtest.Testing) {
> System.out.println("\tbefore - TESTING - "+thisJoinPoint);
> }
>
> after() : block (aspectjtest.Testing) {
> System.out.println("\tafter - TESTING - "+thisJoinPoint);
> }
>
> And here is the output i get when i run the code:
>
> before the block
>
> before - TESTING - block(ClassNotFoundException aspectjtest.Test.(Test))
> after - TESTING - block(ClassNotFoundException aspectjtest.Test.(Test))
> Hello World! 0
> Hello World! 1
> Hello World! 2
>
> after the block
> ...
>
> As you can see the after did not match AFTER the block.
>
> Perhaps you can give me a hint how to fix this.
>
> Thanks.
>
> Greetings,
>
> Thomas
>
>

-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada
Received on Mon Apr 21 2008 - 14:15:56 BST

This archive was generated by hypermail 2.2.0 : Mon Apr 21 2008 - 14:30:11 BST