[aspectc-user] Weaving question
Francisco Afonso
afonsofc at hotmail.com
Wed Sep 28 10:50:58 CEST 2005
>try the following
>
>pointcut log (const char* zz) = args(zz) && call ("void nop(...)");
>
>instead of
>
> > pointcut log (int zz) = args(zz) && call ("void nop(...)");
>
>according to the example within the language reference on page 9, this
>should work.
>
Well, I think it should work for an integer too, but in the language
reference the login function is not listed, so it may be different of my
one, that is defined only as : void nop(...){};
But something strange is happening in my test program. I have tried your
suggestion and got a segmentation fault. My latest unsuccessful try was:
//--------------------------------main.cc---------------------------
#include <stdio.h>
void nop(const char *){};
void nop(int){};
class MyClass {
public:
int doit ( int aa ) {
int bb;
bb = aa * 5;
nop(bb);
char myName[10] = "here";
nop(myName);
return (bb + 2);
}
};
int main() {
MyClass mine;
mine.doit(2);
}
//------------------------------------nop.ah--------------------------------
aspect myAspect {
pointcut log1 (int zz) = args(zz) && call ("void nop(...)");
pointcut log2 (const char * name) = args(name) && call ("void nop(...)");
advice log1 (zz) : before(int zz) {
printf("The local value is %d \n", zz);
}
advice log2 (name) : before(const char * name) {
printf("The local string is %s \n", name);
}
};
//------------ command line result-------------------------------------
* Running ac++ 0.9.3
* Simple Dependency Check
* Handling Translation Unit `main.cc'.
./weave: line 1: 3716 Segmentation fault ~/aspect/ac-0.9.3/ac++ -v1
--config ~/aspect/ac-0.9.3/puma.config -I . -p . -d ../nop-out
------------------- end --------------------------
It works only if I remove the log2 advice.
That code is different of what I have planned as I wanted the nop funcion be
declared as "void nop(...)", and so I would declared it only once in the
program.
Francisco
More information about the aspectc-user
mailing list