Information Technology Reference
In-Depth Information
The result of “weaving” (i.e., performing
source-to-source transformation) the above source
code is the following. The weaving process has
defined additional classes and inline functions to
support the specified trace functionality. It has
also redirected control flow according to the trace
requirement (after call to function). (Box 2)
Aspect-oriented programming and other forms
of source-to-source transformation are useful for
selective and precise instrumentation of source
code. Modification of source code is portable with
respect to different processor architectures. The
performance impact of the measurement is often
minimal because instrumentation is customized
Box 2.
#ifndef __ac_fwd_TraceAspect__
#define __ac_fwd_TraceAspect__
class TraceAspect;
namespace AC {
inline void invoke_TraceAspect_TraceAspect_a0_after();
}
#endif
#line 1 “main.cc”
#include <stdio.h>
#include <pthread.h>
pthread_mutex_t * mute;
int main()
{
pthread_mutex_init(mute, NULL);
pthread_mutex_lock(mute);
pthread_mutex_unlock(mute);
return 0;
}
/* Function generated by aspect weaver to call the “trace” aspect
after calls to pthread_mutex_lock */
inline int __call__ZN10ReadPacketEv_0_0 (::pthread_mutex_t * arg0) {
AC::ResultBuffer< int > result;
::new (&result) int (::pthread_mutex_lock(arg0));
AC::invoke_TraceAspect_TraceAspect_a0_after ();
return (int)result;
}
void ReadPacket()
{
__call__ZN10ReadPacketEv_0_0 (mute);
pthread_mutex_unlock(mute);
}
continued on following page
 
Search WWH ::




Custom Search