[aspectc-user] A bug in JoinPoint method generation?

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Fri Dec 15 10:25:01 CET 2006


Hi,

although I haven't found the right bugzilla entry yet, it is a known
problem. It is a bug. This is what happens:

ac++ analyses the advice code in order to find out which parts of the
join point API are actually used. Based on this information the amount
of context information, which the wrapper code for affected join points
has to provide, can be tailored down to the minimum. The problem is that
templates that are instantiated by the advice code are not analyzed yet.
Therefore, ac++ does not know that the arg and result functions are
needed and, thus, doesn't generate them. Bang.

As a workaround you can simply the needed join point API functions
within the advice body.

BTW, you can also implement a different behavior for functions that are
declared as returning void at compile time. You could use the result
type (provided by the join point API) as a template parameter. The
template could be specialized for the argument type 'void'.

I'm sorry for the inconvenience.

Olaf


Panu Bloigu wrote:
> Hello.
> 
> I think I have found a bug in the weaver. I have the following two files:
> 
> ================
> File main.cpp
> ================
> template<class TJP> static void no_access(TJP* tjp)
> {
> tjp->result();
> tjp->arg(TJP::ARGS-1); // or tjp->arg(0) or ...
> }
> 
> int m1(){return 0;}
> void m2(int i){}
> int main()
> {
> m1();
> m2(1);
> return 0;
> }
> 
> ================
> File AnAspect.ah
> ================
> #ifndef ANASPECT_AH_
> #define ANASPECT_AH_
> aspect AnAspect
> {
> advice execution("int m1()" || "void m2(int)") : around()
> {
> tjp->proceed();
> // tjp->result();
> // tjp->arg(JoinPoint::ARGS-1);
> no_access(tjp);
> }
> };
> #endif /*ANASPECT_AH_*/
> 
> Now the compiler tells me the following:
> 
> ==============================================================================
> 
> 
> **** Incremental build of configuration Debug for project ContextAccess
> ****
> 
> make -k all
> Building file: ../main.cpp
> Invoking: GCC C++ Compiler
> /opt/eclipse-3.1.2/plugins/org.aspectc.compiler.linux_0.9.93/AC/ag++
> --c_compiler g++ -k -r repo.acp -p .. -c ../main.cpp --Xcompiler -o
> main.o -D_useAC -O0 -g3 -Wall -fmessage-length=0 -I..
> ../main.cpp: In function ‘void no_access(TJP*) [with TJP =
> TJP__ZN2m1Ev_0]’:
> ../AnAspect.ah:10: instantiated from ‘void
> AnAspect::__a0_around(JoinPoint*) [with JoinPoint = TJP__ZN2m1Ev_0]’
> main.acc:233: instantiated from ‘void
> AC::invoke_AnAspect_AnAspect_a0_around(JoinPoint*) [with JoinPoint =
> TJP__ZN2m1Ev_0]’
> main.acc:107: instantiated from here
> ../main.cpp:4: error: ‘struct TJP__ZN2m1Ev_0’ has no member named ‘arg’
> ../main.cpp: In function ‘void no_access(TJP*) [with TJP =
> TJP__ZN2m2Ei_0]’:
> ../AnAspect.ah:10: instantiated from ‘void
> AnAspect::__a0_around(JoinPoint*) [with JoinPoint = TJP__ZN2m2Ei_0]’
> main.acc:233: instantiated from ‘void
> AC::invoke_AnAspect_AnAspect_a0_around(JoinPoint*) [with JoinPoint =
> TJP__ZN2m2Ei_0]’
> main.acc:159: instantiated from here
> ../main.cpp:3: error: ‘struct TJP__ZN2m2Ei_0’ has no member named ‘result’
> error: Execution failed: "g++" -c -xc++ "main.acc" -xnone -I"../"
> -D"_useAC" -O0 -g3 -Wall -fmessage-length=0 -I".." -o "main.o"
> make: *** [main.o] Error 1
> make: Target `all' not remade because of errors.
> Build complete for project ContextAccess
> =============================================================================
> 
> 
> Obviously the case is that result() is not generated for the structure
> representating the join point at method m2() and respectively arg() is
> not generated for the structure representating the context of m1().
> However, if I uncomment the two lines in the advice code, compilation
> goes just fine. I guess that all I'm asking is that whether this is a
> bug or not? If it's not a bug, could someone please elaborate a little
> on what's going on here. Of course, one might ask that why do I need
> methods for getting non-existing result/arguments, but in the document
> "Advances in AOP with AspectC++" it is said that tjp->result() should
> return 0 if the function has no return value (I take "no return value"
> meaning that the function is declared as returning void). Or maybe there
> is something wrong with my code that causes this behaviour?
> 
> 
> Panu.
> 
> 
> 
> _______________________________________________
> 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