⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cyg_trac.h

📁 eCos/RedBoot for勤研ARM AnywhereII(4510) 含全部源代码
💻 H
📖 第 1 页 / 共 5 页
字号:
    if ( ( _bool_ ) )                                           \        CYG_TRACE_docall8( _msg_, a, b, c, d, e, f, g, 0 );     \    CYG_MACRO_END
 
#define CYG_TRACE8( _bool_, _msg_, a, b, c, d, e, f, g, h )     \    CYG_MACRO_START                                             \    if ( ( _bool_ ) )                                           \        CYG_TRACE_docall8( _msg_, a, b, c, d, e, f, g, h );     \    CYG_MACRO_END

// -------------------------------------------------------------------------
// Report function entry and exit.
// In C++ the macro CYG_REPORT_FUNCTION should appear as the first line of
// any function. It will generate a message whenever the function is entered
// and when it is exited.
// In C the macro should appear as the first statement after any local variable
// definitions. No exit message will be generated unless CYG_REPORT_RETURN is
// placed just before each return.
// Where a piece of code is to be compiled with both C and C++, the above
// rules for C should be followed.

#ifdef CYGDBG_INFRA_DEBUG_FUNCTION_REPORTS
        
#ifdef __cplusplus

class Cyg_TraceFunction_Report_
{
public:
    int   cond;
    const char *func;
    const char *file;
    cyg_uint32 lnum;
#ifdef CYGDBG_INFRA_DEBUG_TRACE_MESSAGE
    char *exitmsg;
    CYG_ADDRWORD exitvalue;
    enum { UNSET = 0, SET, VOID } exitset;
#endif

    Cyg_TraceFunction_Report_(
        int condition, const char *psz_func, const char *psz_file,
        cyg_uint32 linenum)
    {
        cond = condition;
        func = psz_func;
        file = psz_file;
        lnum = linenum;
        
#ifdef CYGDBG_INFRA_DEBUG_TRACE_MESSAGE
        exitmsg = NULL;
        exitset  = UNSET;
        if ( cond )
            cyg_tracemsg( cyg_trace_enter, func, file, lnum, "enter");
#else
        if ( cond )
            cyg_tracenomsg( func, file, lnum );
#endif
    };

    Cyg_TraceFunction_Report_(
        int condition, const char *psz_func, const char *psz_file, 
        cyg_uint32 linenum, char *psz_exitmsg )
    {
        cond = condition;
        func = psz_func;
        file = psz_file;
        lnum = linenum;
#ifdef CYGDBG_INFRA_DEBUG_TRACE_MESSAGE
        exitmsg = psz_exitmsg;
        exitset  = UNSET;
        if ( cond )
            cyg_tracemsg( cyg_trace_enter, func, file, lnum, "enter");
#else
        CYG_UNUSED_PARAM( char *, psz_exitmsg );
        if ( cond )
            cyg_tracenomsg( func, file, lnum );
#endif
    };

    inline void set_exitvoid( cyg_uint32 linenum )
    {
        lnum = linenum;
#ifdef CYGDBG_INFRA_DEBUG_TRACE_MESSAGE
        CYG_ASSERT( NULL == exitmsg, "exitvoid used in typed function" );
        CYG_ASSERT( UNSET == exitset, "exitvoid used when arg already set" );
        exitset = VOID;
#endif
    }

    inline void set_exitvalue( cyg_uint32 linenum, CYG_ADDRWORD retcode )
    {
        lnum = linenum;
#ifdef CYGDBG_INFRA_DEBUG_TRACE_MESSAGE
        CYG_ASSERT( UNSET == exitset, "exitvalue used when arg already set" );
        exitvalue = retcode;
        exitset = SET;
#else
        CYG_UNUSED_PARAM( CYG_ADDRWORD, retcode );
#endif
    }

    ~Cyg_TraceFunction_Report_()
    {
        if ( cond ) {
#ifdef CYGDBG_INFRA_DEBUG_TRACE_MESSAGE
            if ( VOID == exitset )
                cyg_tracemsg( cyg_trace_return, func, file, lnum,
                              "return void");
            else if ( UNSET == exitset )
                cyg_tracemsg( cyg_trace_return, func, file, lnum,
                              "RETURNING UNSET!");
            else if ( NULL == exitmsg )
                cyg_tracemsg2( cyg_trace_return, func, file, lnum,
                               "return %08x", exitvalue, 0 );
            else
                cyg_tracemsg2( cyg_trace_return, func, file, lnum,
                               exitmsg, exitvalue, 0 );
#else
            cyg_tracenomsg( func, file, lnum );
#endif
        }
    }
};

// These have no CYG_MACRO_START,END around because it is required
// that the scope of the object be the whole function body.  Get it?

// These are the unconditional versions:
#define CYG_REPORT_FUNCTION()                           \  Cyg_TraceFunction_Report_ cyg_tracefunction_report_(  \        1, __PRETTY_FUNCTION__,                         \        __FILE__, __LINE__ )

#define CYG_REPORT_FUNCTYPE( _exitmsg_ )                \  Cyg_TraceFunction_Report_ cyg_tracefunction_report_(  \        1, __PRETTY_FUNCTION__,                         \        __FILE__, __LINE__, _exitmsg_ )

#define CYG_REPORT_FUNCNAME( _name_ )                   \  Cyg_TraceFunction_Report_ cyg_tracefunction_report_(  \        1, _name_,                                      \        __FILE__, __LINE__ )

#define CYG_REPORT_FUNCNAMETYPE( _name_, _exitmsg_  )   \  Cyg_TraceFunction_Report_ cyg_tracefunction_report_(  \        1, _name_,                                      \        __FILE__, __LINE__, _exitmsg_ )

// These are conditioned on macro CYG_REPORT_USER_BOOL
// (which you better have defined)
#define CYG_REPORT_FUNCTIONC()                          \  Cyg_TraceFunction_Report_ cyg_tracefunction_report_(  \        CYG_REPORT_USER_BOOL, __PRETTY_FUNCTION__,      \        __FILE__, __LINE__ )

#define CYG_REPORT_FUNCTYPEC( _exitmsg_ )               \  Cyg_TraceFunction_Report_ cyg_tracefunction_report_(  \        CYG_REPORT_USER_BOOL, __PRETTY_FUNCTION__,      \        __FILE__, __LINE__, _exitmsg_ )

#define CYG_REPORT_FUNCNAMEC( _name_ )                  \  Cyg_TraceFunction_Report_ cyg_tracefunction_report_(  \        CYG_REPORT_USER_BOOL, _name_,                   \        __FILE__, __LINE__ )

#define CYG_REPORT_FUNCNAMETYPEC( _name_, _exitmsg_  )  \  Cyg_TraceFunction_Report_ cyg_tracefunction_report_(  \        CYG_REPORT_USER_BOOL, _name_,                   \        __FILE__, __LINE__, _exitmsg_ )


#define CYG_REPORT_RETURN() CYG_MACRO_START             \    cyg_tracefunction_report_.set_exitvoid( __LINE__ ); \CYG_MACRO_END

#define CYG_REPORT_RETVAL( _value_) CYG_MACRO_START     \    cyg_tracefunction_report_.set_exitvalue(            \        __LINE__, (CYG_ADDRWORD)(_value_) );            \CYG_MACRO_END


#else   // not __cplusplus


struct Cyg_TraceFunction_Report_
{
    int   cond;
    char *func;
    char *file; /* not strictly needed in plain 'C' */
    cyg_uint32 lnum; /* nor this */
#ifdef CYGDBG_INFRA_DEBUG_TRACE_MESSAGE
    char *exitmsg;
    CYG_ADDRWORD exitvalue;
    int exitset;
#endif

};

#ifdef CYGDBG_INFRA_DEBUG_TRACE_MESSAGE

#define CYG_REPORT_FUNCTION_ENTER_INTERNAL() CYG_MACRO_START            \  if ( cyg_tracefunction_report_.cond )                                 \    cyg_tracemsg( cyg_trace_enter,                                      \                  cyg_tracefunction_report_.func,                       \                  cyg_tracefunction_report_.file,                       \                  cyg_tracefunction_report_.lnum,                       \                  "enter" );                                            \CYG_MACRO_END

#define CYG_REPORT_FUNCTION_CONSTRUCT( _c_, _fn_,_fl_,_l_,_xm_,_xv_,_xs_ ) \        { _c_, _fn_, _fl_, _l_, _xm_, _xv_, _xs_ }

#else // do not CYGDBG_INFRA_DEBUG_TRACE_MESSAGE

#define CYG_REPORT_FUNCTION_ENTER_INTERNAL() CYG_MACRO_START            \  if ( cyg_tracefunction_report_.cond )                                 \    cyg_tracenomsg( cyg_tracefunction_report_.func,                     \                    cyg_tracefunction_report_.file,                     \                    cyg_tracefunction_report_.lnum );                   \CYG_MACRO_END

#define CYG_REPORT_FUNCTION_CONSTRUCT( _c_, _fn_,_fl_,_l_,_xm_,_xv_,_xs_ ) \        { _c_, _fn_, _fl_, _l_ }

#endif // not CYGDBG_INFRA_DEBUG_TRACE_MESSAGE

// These have no CYG_MACRO_START,END around because it is required
// that the scope of the object be the whole function body.  Get it?

// These are the unconditional versions:
#define CYG_REPORT_FUNCTION()                                           \    struct Cyg_TraceFunction_Report_ cyg_tracefunction_report_ =        \    CYG_REPORT_FUNCTION_CONSTRUCT(                                      \        1, __PRETTY_FUNCTION__, __FILE__, __LINE__, NULL, 0, 0 );       \    CYG_REPORT_FUNCTION_ENTER_INTERNAL()

#define CYG_REPORT_FUNCTYPE( _exitmsg_ )                                \    struct Cyg_TraceFunction_Report_ cyg_tracefunction_report_ =        \    CYG_REPORT_FUNCTION_CONSTRUCT(                                      \        1, __PRETTY_FUNCTION__, __FILE__, __LINE__, _exitmsg_, 0, 0 );  \    CYG_REPORT_FUNCTION_ENTER_INTERNAL()

#define CYG_REPORT_FUNCNAME( _name_ )                                   \    struct Cyg_TraceFunction_Report_ cyg_tracefunction_report_ =        \    CYG_REPORT_FUNCTION_CONSTRUCT(                                      \        1, _name_, __FILE__, __LINE__, NULL, 0, 0 );                    \    CYG_REPORT_FUNCTION_ENTER_INTERNAL()

#define CYG_REPORT_FUNCNAMETYPE( _name_, _exitmsg_  )                   \    struct Cyg_TraceFunction_Report_ cyg_tracefunction_report_ =        \    CYG_REPORT_FUNCTION_CONSTRUCT(                                      \        1, _name_, __FILE__, __LINE__, _exitmsg_, 0, 0 );               \    CYG_REPORT_FUNCTION_ENTER_INTERNAL()

// These are conditioned on macro CYG_REPORT_USER_BOOL
// (which you better have defined)
#define CYG_REPORT_FUNCTIONC()                                          \    struct Cyg_TraceFunction_Report_ cyg_tracefunction_report_ =        \    CYG_REPORT_FUNCTION_CONSTRUCT(                                      \        CYG_REPORT_USER_BOOL,                                           \        __PRETTY_FUNCTION__, __FILE__, __LINE__, NULL, 0, 0 );          \    CYG_REPORT_FUNCTION_ENTER_INTERNAL()

#define CYG_REPORT_FUNCTYPEC( _exitmsg_ )                               \    struct Cyg_TraceFunction_Report_ cyg_tracefunction_report_ =        \    CYG_REPORT_FUNCTION_CONSTRUCT(                                      \        CYG_REPORT_USER_BOOL,                                           \        __PRETTY_FUNCTION__, __FILE__, __LINE__, _exitmsg_, 0, 0 );     \    CYG_REPORT_FUNCTION_ENTER_INTERNAL()

#define CYG_REPORT_FUNCNAMEC( _name_ )                                  \    struct Cyg_TraceFunction_Report_ cyg_tracefunction_report_ =        \    CYG_REPORT_FUNCTION_CONSTRUCT(                                      \        CYG_REPORT_USER_BOOL,                                           \        _name_, __FILE__, __LINE__, NULL, 0, 0 );                       \    CYG_REPORT_FUNCTION_ENTER_INTERNAL()

#define CYG_REPORT_FUNCNAMETYPEC( _name_, _exitmsg_  )                  \    struct Cyg_TraceFunction_Report_ cyg_tracefunction_report_ =        \    CYG_REPORT_FUNCTION_CONSTRUCT(                                      \        CYG_REPORT_USER_BOOL,                                           \        _name_, __FILE__, __LINE__, _exitmsg_, 0, 0 );                  \    CYG_REPORT_FUNCTION_ENTER_INTERNAL()

#ifdef CYGDBG_INFRA_DEBUG_TRACE_MESSAGE

#define CYG_REPORT_RETURN() CYG_MACRO_START                             \    CYG_ASSERT( NULL == cyg_tracefunction_report_.exitmsg,              \                "exitvoid used in typed function" );                    \    CYG_ASSERT( 0 == cyg_tracefunction_report_.exitset,                 \                "exitvoid used when arg already set" );                 \    cyg_tracefunction_report_.lnum = __LINE__;                          \    cyg_tracefunction_report_.exitset = 2;                              \

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -