[aspectc-user] template parameters -- calling VS execution pointcuts
Olaf Spinczyk
Olaf.Spinczyk at informatik.uni-erlangen.de
Tue Oct 4 17:44:41 CEST 2005
Hi Mike,
I'm sorry for this late answer, but I had no internet access during the
last week.
The problem is that ac++ only weaves call advice if the parser is able
to resolve the function call. However, without the --real-instances
option, calls to functions that depend on template instances are not
resolved. This is what happens in your case.
You could try to compile your code with --real-instances (which is
"experimental"). Please, report if this parser mode works for you.
Best regards,
Olaf
Mike Mortensen wrote:
> This is a little long, just because I wanted to show the file, aspect,
> and and so forth...
>
> I'm using AspectC++ (on Linux/x86) in the context of an object-oriented
> framework that defines a
> rich hierarchy of classes. So far, that's gone well since the methods
> use pointers to classes in the
> hierarchy, but I ran into a recent issue with methods and functions that
> have arguments of
> template types in the std:: namespace, such as string, map, vector, and
> so forth.
>
>
> For example, here's a simplified example:
>
> #include <iostream>
> #include <string>
> #include <map>
> using namespace std;
>
> void tmrGetAllCellInstantiations(int a,char b,string name,
> map<int,string>& datamap);
> int tmrMain(int a, int b, double * data)
> {
> cerr << "running code for body of tmrMain..." << endl;
> map<int,string> mydata;
> tmrGetAllCellInstantiations(a,'b',"cell",mydata);
> string foo = "cell2";
> tmrGetAllCellInstantiations(a,'b',foo,mydata);
> return 0;
> }
>
> void tmrGetAllCellInstantiations(int a,char b,string
> name,map<int,string>& mydata)
> {
> cerr << "running code for body of tmrGetAllCellInstantiations..." <<
> endl;
> cerr << " a=" << a << " b=" << b << " name=" << name << endl;
> return;
> }
>
> int main()
> {
> return tmrMain(1,2,NULL);
> }
>
> As you can see, I have two functions that start with "tmr":
> int tmrMain(int a, int b, double * data)
> void tmrGetAllCellInstantiations(int a,char b,string name,
> map<int,string>& datamap);
> The tmrGetAllCellInstantiations has a map of strings as an parameter.
>
> I apply my aspect file by going into a src.in directory and doing this:
>
> /net/hpsvmmo/home/mmo/home/AspectC++/ac-0.9.3/ac++ -v1 -r AOP.xml
> --no_line --gnu --problem_spec_scope
> --config /net/hpsvmmo/home/mmo/AspectC++/ac-0.9.3/puma.config
> -I. -I/net/hpesmmo/home/mmo/AOP_Builds/StlFlow/include
> -I/net/hpesmmo/home/mmo/AOP_Builds/StlFlow/../aspects -p . -d ../src.out
>
> My aspects file has several kinds of advice that are intended to capture
> the CALL and EXECUTION of
> *all* functions starting with "tmr". I even made 2 advice bodies that
> specifically focus on tmrGetAllCellInstantiations:
>
> #include <iostream>
> using namespace std;
> aspect TimeEvent {
> pointcut call_any_tmr() =
> call("% tmr%(...)");
> pointcut exec_any_tmr() =
> execution("% tmr%(...)");
>
> advice call_any_tmr() : after() {
> cerr << " after CALLING " << JoinPoint::signature() << endl;
> }
> advice exec_any_tmr() : after() {
> cerr << " after EXECUTING " << JoinPoint::signature() << endl;
> }
> advice call("% tmrGetAllCellInstantiations(...)") : before()
> {
> cerr <<"before CALLING " << JoinPoint::signature() << endl;
> }
> advice execution("% tmrGetAllCellInstantiations(...)") : around() {
> cerr <<"around EXECUTION of tmrGetAllCellInstantiations" << endl;
> tjp->proceed();
> cerr <<"after around EXEUCTION of tmrGetAllCellInstantiations" <<
> endl;
> }
> };
>
> The result, which I can verify both by running the program and by
> looking at the AOP.xml file (which shows
> joinpoints and matching advice) is that *only* the execution of the
> tmrGetAllCellInstantiations method
> is ever matched. Any advice based on 'calling' (both for tmr% and
> tmrGetAllCellInstantiations) is not
> considered a match. The slightly garbled nature of the signature in the
> AOP.xml file:
> void tmrGetAllCellInstantiations(int,char,::std::basic_string< char
> >,::std::map< int,::std::basic_string< char > > &)
> in order to handle the fact that strings and maps are templates made me
> wonder if matching calls versus executions is confused by that.
>
> I found that if I have tmrGetAllCellInstantiations not have a string or
> map be passed as parameters (instead use a char* and a void*)
> then both the calling and execution ones match just fine. I did some
> hunting and found on the aspectc.org site that with older versions
> of AspectC++ this was an issue. I'm using version 0.9.3 (and 0.9.2) with
> g++-3.3 on Debian linux.
> I added the flags:
> --gnu --problem_spec_scope
> to my build line but it still doesn't help.
> Has anyone else seen anything like this? The odd thing to me is the fact
> that the calling pointcut does not work to match a
> function with template parameters but that the execution does work.
>
> I can work around it with using execution, but my experience has been
> that using constructs like this:
> !within("% tmr%(...)")
> works with call pointcuts but not execution pointcuts.
>
> 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