[aspectc-user] recording advice context

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Thu Sep 8 08:32:08 CEST 2005

Hello Mike,

ac++ transforms advice into member functions of the aspect, which 
becomes a normal C++ class. Therefore, __FILE__ and __LINE__ don't help 

The only way to find out the filename and line for a join point 
("shadow") (in the current version) is to print its ID 
(JoinPoint::JPID). With this ID you can lookup the file and line 
information in the generated project repository (-r option). The project 
repository is an XML file with a quite simple structure.

This workaround is, of course, not satisfying. Therefore, future 
versions of AspectC++ (including 1.0pre1) will have an extended join 
point API that allows advice code to access the file and line 
information at runtime.

I also agree that the signature of the calling function at a call join 
point would also be desirable. We will work on this issue, but a 
solution will not be integrated in the next release.

Best regards,


Mike Mortensen wrote:
> Hi,
> This may be a really basic question about the JoinPoint API...
> I am using before advice as a development aspect to trace all calls into 
> a particular library function. I want to track the last call to a 
> particular library call (because the library calls exit rather than 
> throwing
> an exception), but I'd also like to write out (for my own use) all 
> calling contexts --
> specifically the name of the static function or method that called the 
> library call.
> If the methods being called are all part of a class (otherClass), then I 
> can write
> out the signature of each method call in otherClass, and I can use __LINE__
> and __FILE__ to quickly debug the exact call that triggered the exit:
>    #include <iostream>
>    using namespace std;
>    aspect Action {
>       advice call("% otherClass::%(...)") : before() {
>          cerr << "   Track otherClass -- before calling " <<
>    JoinPoint::signature()
>               << " at line " << __LINE__ << " of file " << __FILE__
>               << endl;
>       }
>    };
> This advice prints out things like
>    Track otherClass -- before calling unsigned int 
> otherClass::NumPortsOnNet() const at line 11 of file Aspects.ah
> so I know what methods are being called -- which is important -- but the 
> __LINE__ and __FILE__ information
> is embedded in Aspects.ah which is included in main.cc, so I don't get 
> the 'context' or caller information.
> Suppose calls to methods of otherClass exist in:
>   main
>   myClass::foo()
>   myClass::bar()
>   void f()
>   void g()
> Is there any way to print out the name of the calling function or 
> method, rather than just what is being called
> or trying to use __LINE__ and __FILE__?
> Thanks,
> Mike
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user

More information about the aspectc-user mailing list