[aspectc-user] Re: execution capture inside a given method

Olaf Spinczyk os at aspectc.org
Fri Feb 6 10:00:51 CET 2009


Hello,

Meriam Kallel wrote:
>
> Hello,
>
> I want to capture the execution of a method /m1()/ only when it is 
> executed inside a given method /m2()/:
>
> void m2()
>
> {
>
>>
> m1()
>
>>
> }
>
> knowing that /m1()/ is executed in other functions of the code.
>
> I don’t know if this is possible with aspectc++ or not.
>
> Thank you for your help.
>
> Regards
>

yes, this is possible. You can use the following pointcut expression:

call("% m1()") && within("% m2()")

If you also want your advice to be executed in cases where the control 
flow indirectly reaches m1() from m2(), e.g. m2 calls m3, m3 calls m1, 
use 'cflow':

execution("% m1()") && cflow(execution("% m2()")

The latter method is more robust, but is a little less efficient.

Best regards,

Olaf


PS: If you want to post on aspectc-user at aspectc.org, you have to be 
subscribed.




More information about the aspectc-user mailing list