📄 cyg_trac.h
字号:
CYG_REPORT_FUNCARGVOID() void function entryCYG_REPORT_FUNCARG1( format, arg ) printf-style toCYG_REPORT_FUNCARG8( format, arg1...arg8 ) printf-styleCYG_REPORT_FUNCARG1X( arg ) toCYG_REPORT_FUNCARG8X( arg1...arg8 ) use %08xCYG_REPORT_FUNCARG1Y... use %xCYG_REPORT_FUNCARG1D... use %dCYG_REPORT_FUNCARG1XV... use "arg=%08x"CYG_REPORT_FUNCARG1YV... use "arg=%x"CYG_REPORT_FUNCARG1DV... use "arg=%d"---------------------------------------------------------------------------Internal Documentation======================The required functions which are used by the tracing macros are externC void cyg_tracenomsg( char *psz_func, char *psz_file, cyg_uint32 linenum ); externC void cyg_tracemsg( cyg_uint32 what, char *psz_func, char *psz_file, cyg_uint32 linenum, char *psz_msg ); externC void cyg_tracemsg2( cyg_uint32 what, char *psz_func, char *psz_file, cyg_uint32 linenum, char *psz_msg, CYG_ADDRWORD arg0, CYG_ADDRWORD arg1 ); // extended in the obvious way for 4,6,8 argumentsThese functions should expect psz_func and psz_file to possibly be NULL incase those facilities are not available in the compilation environment, anddo something safe in such cases. A NULL message should really be dealtwith safely also, just logging "execution here" info like cyg_tracenomsg().Discussion of possible underlying implementations-------------------------------------------------It is intended that the functions that get called can simply print the infothey are given in as fancy a format as you like, or they could do theprintf-type formatting and log the resulting text in a buffer. They gettold the type of event (function-entry, function-arguments, function-exitor plain tracing info) and so can perform fancy indenting, for example, tomake call stack inspection more obvious to humans. It is also intendedthat a more compact logging arrangement be possible, for example one whichrecords, in 32-bit words (CYG_ADDRWORDs), the addresses of the file,function and msg strings, the line number and the arguments. This has theimplication that the msg string should not be constructed dynamically butbe static ie. a plain quoted C string. The number of arguments also mustbe recorded, and if it is chosen to save string arguments in the bufferrather than just their addresses (which could be invalid by the time thelogged information is processed) some flagging of which arguments arestrings must be provided. The system could also be extended to deal withfloats of whichever size fir in a CYG_ADDRWORD; these would probablyrequire special treatment also. With these considerations in mind, themaximum number of parameters in a single trace message has been set to 8,so that a byte bitset could be used to indicate which arguments arestrings, another for those which are floats, and the count of argumentsalso fits in a byte as number or a bitset.****************************************************************************/#include <pkgconf/infra.h>#include <cyg/infra/cyg_ass.h>// -------------------------------------------------------------------------// CYGDBG_INFRA_DEBUG_FUNCTION_PSEUDOMACRO is dealt with in cyg_ass.h.// -------------------------------------------------------------------------#ifdef CYGDBG_USE_TRACING// -------------------------------------------------------------------------// We define macros and appropriate prototypes for the trace/fail// system. These are:// CYG_TRACE0..8 - trace if boolean// CYG_TRACEPROC - default no comment proc entry// CYG_TRACEPROCOUT - default no comment proc exit// these are executed to deal with tracing - breakpoint?externC voidcyg_tracenomsg( char *psz_func, char *psz_file, cyg_uint32 linenum );// provide every other one of these as a space/caller bloat compromise.# ifdef CYGDBG_INFRA_DEBUG_TRACE_MESSAGEenum cyg_trace_what{ cyg_trace_trace = 0, cyg_trace_enter, cyg_trace_args, cyg_trace_return,// cyg_trace_,// cyg_trace_,};externC voidcyg_tracemsg( cyg_uint32 what, char *psz_func, char *psz_file, cyg_uint32 linenum, char *psz_msg );externC voidcyg_tracemsg2( cyg_uint32 what, char *psz_func, char *psz_file, cyg_uint32 linenum, char *psz_msg, CYG_ADDRWORD arg0, CYG_ADDRWORD arg1 );externC voidcyg_tracemsg4( cyg_uint32 what, char *psz_func, char *psz_file, cyg_uint32 linenum, char *psz_msg, CYG_ADDRWORD arg0, CYG_ADDRWORD arg1, CYG_ADDRWORD arg2, CYG_ADDRWORD arg3 );externC voidcyg_tracemsg6( cyg_uint32 what, char *psz_func, char *psz_file, cyg_uint32 linenum, char *psz_msg, CYG_ADDRWORD arg0, CYG_ADDRWORD arg1, CYG_ADDRWORD arg2, CYG_ADDRWORD arg3, CYG_ADDRWORD arg4, CYG_ADDRWORD arg5 );externC voidcyg_tracemsg8( cyg_uint32 what, char *psz_func, char *psz_file, cyg_uint32 linenum, char *psz_msg, CYG_ADDRWORD arg0, CYG_ADDRWORD arg1, CYG_ADDRWORD arg2, CYG_ADDRWORD arg3, CYG_ADDRWORD arg4, CYG_ADDRWORD arg5, CYG_ADDRWORD arg6, CYG_ADDRWORD arg7 );#endif // CYGDBG_INFRA_DEBUG_TRACE_MESSAGE// -------------------------------------------------------------------------# ifdef CYGDBG_INFRA_DEBUG_TRACE_MESSAGE# define CYG_TRACE_docall0( _msg_ ) \ cyg_tracemsg( cyg_trace_trace, \ __PRETTY_FUNCTION__, __FILE__, __LINE__, _msg_ );# define CYG_TRACE_docall2( _msg_, _arg0_, _arg1_ ) \ cyg_tracemsg2( cyg_trace_trace, \ __PRETTY_FUNCTION__, __FILE__, __LINE__, _msg_, \ (CYG_ADDRWORD)_arg0_, (CYG_ADDRWORD)_arg1_ );# define CYG_TRACE_docall4( _msg_, _arg0_, _arg1_ , _arg2_, _arg3_ ) \ cyg_tracemsg4( cyg_trace_trace, \ __PRETTY_FUNCTION__, __FILE__, __LINE__, _msg_, \ (CYG_ADDRWORD)_arg0_, (CYG_ADDRWORD)_arg1_, \ (CYG_ADDRWORD)_arg2_, (CYG_ADDRWORD)_arg3_ );# define CYG_TRACE_docall6( _msg_, _arg0_, _arg1_ , _arg2_, _arg3_, \ _arg4_, _arg5_ ) \ cyg_tracemsg6( cyg_trace_trace, \ __PRETTY_FUNCTION__, __FILE__, __LINE__, _msg_, \ (CYG_ADDRWORD)_arg0_, (CYG_ADDRWORD)_arg1_, \ (CYG_ADDRWORD)_arg2_, (CYG_ADDRWORD)_arg3_, \ (CYG_ADDRWORD)_arg4_, (CYG_ADDRWORD)_arg5_ );# define CYG_TRACE_docall8( _msg_, _arg0_, _arg1_ , _arg2_, _arg3_, \ _arg4_, _arg5_, _arg6_, _arg7_ ) \ cyg_tracemsg8( cyg_trace_trace, \ __PRETTY_FUNCTION__, __FILE__, __LINE__, _msg_, \ (CYG_ADDRWORD)_arg0_, (CYG_ADDRWORD)_arg1_, \ (CYG_ADDRWORD)_arg2_, (CYG_ADDRWORD)_arg3_, \ (CYG_ADDRWORD)_arg4_, (CYG_ADDRWORD)_arg5_, \ (CYG_ADDRWORD)_arg6_, (CYG_ADDRWORD)_arg7_ );# else // do not CYGDBG_INFRA_DEBUG_TRACE_MESSAGE# define CYG_TRACE_docall0( _msg_ ) \ cyg_tracenomsg( __PRETTY_FUNCTION__, __FILE__, __LINE__ );# define CYG_TRACE_docall2( _msg_, _arg0_, _arg1_ ) \ cyg_tracenomsg( __PRETTY_FUNCTION__, __FILE__, __LINE__ );# define CYG_TRACE_docall4( _msg_, _arg0_, _arg1_ , _arg2_, _arg3_ ) \ cyg_tracenomsg( __PRETTY_FUNCTION__, __FILE__, __LINE__ );# define CYG_TRACE_docall6( _msg_, _arg0_, _arg1_ , _arg2_, _arg3_, \ _arg4_, _arg5_ ) \ cyg_tracenomsg( __PRETTY_FUNCTION__, __FILE__, __LINE__ );# define CYG_TRACE_docall8( _msg_, _arg0_, _arg1_, _arg2_, _arg3_, \ _arg4_, _arg5_, _arg6_, _arg7_ ) \ cyg_tracenomsg( __PRETTY_FUNCTION__, __FILE__, __LINE__ );#endif// -------------------------------------------------------------------------// Conditioned trace; if the condition is false, fail.#define CYG_TRACE0( _bool_, _msg_ ) \ CYG_MACRO_START \ if ( ( _bool_ ) ) \ CYG_TRACE_docall0( _msg_ ); \ CYG_MACRO_END#define CYG_TRACE1( _bool_, _msg_, a ) \ CYG_MACRO_START \ if ( ( _bool_ ) ) \ CYG_TRACE_docall2( _msg_, a, 0 ); \ CYG_MACRO_END #define CYG_TRACE2( _bool_, _msg_, a, b ) \ CYG_MACRO_START \ if ( ( _bool_ ) ) \ CYG_TRACE_docall2( _msg_, a, b ); \ CYG_MACRO_END#define CYG_TRACE3( _bool_, _msg_, a, b, c ) \ CYG_MACRO_START \ if ( ( _bool_ ) ) \ CYG_TRACE_docall4( _msg_, a, b, c, 0 ); \ CYG_MACRO_END #define CYG_TRACE4( _bool_, _msg_, a, b, c, d ) \ CYG_MACRO_START \ if ( ( _bool_ ) ) \ CYG_TRACE_docall4( _msg_, a, b, c, d ); \ CYG_MACRO_END#define CYG_TRACE5( _bool_, _msg_, a, b, c, d, e ) \ CYG_MACRO_START \ if ( ( _bool_ ) ) \ CYG_TRACE_docall6( _msg_, a, b, c, d, e, 0 ); \ CYG_MACRO_END #define CYG_TRACE6( _bool_, _msg_, a, b, c, d, e, f ) \ CYG_MACRO_START \ if ( ( _bool_ ) ) \ CYG_TRACE_docall6( _msg_, a, b, c, d, e, f ); \ CYG_MACRO_END#define CYG_TRACE7( _bool_, _msg_, a, b, c, d, e, f, g ) \ CYG_MACRO_START \ 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 __cplusplusclass Cyg_TraceFunction_Report_{public: int cond; char *func; 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, char *psz_func, 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");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -