[aspectc-user] context of a cflow pointcut?

Daniel Lohmann daniel.lohmann at informatik.uni-erlangen.de
Tue Feb 20 12:31:24 CET 2007


Panu Bloigu wrote:
> Hello!
> 
> thank you for the explanation. I have some comments though, if you don't
> mind.
> 
[...]
>>
>> 2) A::target() is called from within the execution advice of aspect
>> Test. The AspectC++ join-point model currently does not support
>> join-points from within code advice bodies. Hence the call in the
>> execution advice body is not considered as a potential join-point.
>>   
> If I understand this correctly, this is an instance of the bug #263?

Yep.

>> However, even if AspectC++  would consider it correctly as join-point, the code
>> would probably not yield the expected result. First, during the advice
>> execution we are  before/after/around the execution of B::wrapper(),
>> thus not yet in the cflow of B::wrapper(). Second, the instance context
>>   
> This, I think I can understand.
>> (this pointer) in an advice body is the aspect instance (of type Test),
>> hence there is no B at this calling position either.
>>   
> This, however, is something that I think should be discussed throughly
> in some piece of AspectC++ documentation. Of course, I completely
> understand that finishing the actual language implementation is
> something that you, at the moment, probably prioritize higher than the
> documentation. Anyway, this is something that IMO should find it's way
> to documentation at some point in time. What makes this hard to get, is
> that in this particular case that() actually gives a pointer to the
> enclosing aspect instead of the object whose code the advice
> instruments. And more so, this happens only if the call to be
> instrumented was added by another advice. In any other case that() gives
> a pointer to the object in whose code the instrumented call resides
> (excluding non-object cases like e.g. a call residing within main() of
> course). All in all, this has been an interesting thing to learn.

What should I say?
Of course you are right on demanding better documentation...

>> advice call("void A::target()") && cflow(execution("void B::wrapper()"))
>> && that(b) : before( B* b)
>> {
>> b->id();         // use context variable
>> tjp->that->id();     // use joinpoint API
>> std::cout<<"Success!\n";
>> }
>>   
> Unfortunately, this does not get me to where I'm going. See, problems
> arise, when I have no knowledge whatsoever of the object or the methods
> in whose cflow I want to instrument the call to A::target(). Instead,
> they're to be specified in inherited aspects. So what I'm looking at is
> something like the following:
> 
> pointcut virtual target_class() = 0;
> pointcut virtual target_methods() = 0;
> 
> advice call("void A::target()") && cflow(execution(target_methods()))
> {
>    b->id();         // use context variable
>    tjp->that->id();     // use joinpoint API
>    std::cout<<"Success!\n";
> }
> 
> Only if I could somehow extract the actual *types* from pointcut
> expressions... Then what you showed could work.

You can also use 'that' in the following way:

that("B") or that(target_class())

In this cases that() is just used as a join-point filter and not to bind
a context variable. Context access has to be performed via tjp.


Daniel

P.S. Answers to the mailing list, please.




More information about the aspectc-user mailing list