C++ 方面c++;跟踪函数控制流和输入输出参数

C++ 方面c++;跟踪函数控制流和输入输出参数,c++,arguments,trace,aspect,C++,Arguments,Trace,Aspect,我正在使用aspectc++生成程序的控制流 trace.ah: #ifndef __trace_ah__ #define __trace_ah__ #include <cstdio> // Control flow tracing example aspect trace { // print the function name before execution starts pointc

我正在使用aspectc++生成程序的控制流

trace.ah

    #ifndef __trace_ah__
    #define __trace_ah__

    #include <cstdio>
    // Control flow tracing example

    aspect trace {
            // print the function name before execution starts

            pointcut virtual methods() = "% ...::%(...)";

            advice execution (methods()) : before () {
                cout << "entering: " << JoinPoint::signature() << endl;
                // print input parameters**
            }

            advice execution(methods()) : after() {
                // print output parameters**            
                cout << "leaving: " << JoinPoint::signature() << endl;
            }
//prints return values of non void functions 
advice execution("% ...::%(...)" && !"void ...::%(...)") : after() 
{


    JoinPoint::Result res = *tjp->result();
    cout << "leaving " << tjp->signature()<< " << returning value--" << res<<endl;
}
};
    };

    #endif  
\ifndef\uu trace\u ah__
#定义跟踪__
#包括
//控制流跟踪示例
方面跟踪{
//在开始执行之前打印函数名
切入点虚拟方法()=“%…::%(…)”;
通知执行(方法()):在()之前{
不能
#ifndef_uutrace_uah__
#定义跟踪__
#包括
#包括
使用名称空间std;
模板结构ArgPrinter
{
模板静态内嵌无效工作(JP和tjp){
ArgPrinter::work(tjp);
库特
#ifndef __trace_ah__
 #define __trace_ah__

#include <cstdio>
#include <iostream>
using namespace std;

template <int I> struct ArgPrinter 
{
  template <class JP> static inline void work (JP &tjp) {
    ArgPrinter<I - 1>::work (tjp);
    cout << "Arg " << I << ": " << *tjp.template arg<I - 1> () << endl;
  }
};    

template <> struct ArgPrinter<0> 
{
  template <class JP> static inline void work (JP &tjp) {}
};

// Control flow tracing example

    aspect trace {


            pointcut virtual methods() = "% ...::%(...)";

    template <class JP> void print_args (JP &tjp) 
        {
             ArgPrinter<JP::ARGS>::work (tjp);
        }

        advice execution (methods()) : before () 
    {
                cout << "entering: " << JoinPoint::signature() << endl;
            tjp->arg(0);
        print_args (*tjp);


        }

    advice execution("% ...::%(...)" && !"void ...::%(...)") : after() 
    {   
            JoinPoint::Result res = *tjp->result();
            cout << "leaving " << tjp->signature()<< " << returning value--" << res<<endl;
    }


};
  #endif