@ -662,6 +662,7 @@ void __attribute__((format (printf, 6, 7))) __ast_trace(const char *file, int li
*
*/
# define ast_trace_raw(level, indent_type, ...) \
ast_debug ( level < 0 ? __scope_level : level , " " __VA_ARGS__ ) ; \
if ( TRACE_ATLEAST ( level ) ) { \
__ast_trace ( __FILE__ , __LINE__ , __PRETTY_FUNCTION__ , indent_type , 0 , " " __VA_ARGS__ ) ; \
}
@ -676,6 +677,7 @@ void __attribute__((format (printf, 6, 7))) __ast_trace(const char *file, int li
* This will print the file , line and function at the current indent level
*/
# define ast_trace(level, ...) \
ast_debug ( level < 0 ? __scope_level : level , " " __VA_ARGS__ ) ; \
if ( TRACE_ATLEAST ( level ) ) { \
__ast_trace ( __FILE__ , __LINE__ , __PRETTY_FUNCTION__ , AST_TRACE_INDENT_SAME , 0 , " " __VA_ARGS__ ) ; \
}
@ -765,6 +767,7 @@ unsigned long _ast_trace_dec_indent(void);
# define SCOPE_ENTER(level, ...) \
int __scope_level = level ; \
int __scope_task = 0 ; \
ast_debug ( __scope_level , " " __VA_ARGS__ ) ; \
if ( TRACE_ATLEAST ( level ) ) { \
__ast_trace ( __FILE__ , __LINE__ , __PRETTY_FUNCTION__ , AST_TRACE_INDENT_INC_AFTER , 0 , " " __VA_ARGS__ ) ; \
} \
@ -772,6 +775,7 @@ unsigned long _ast_trace_dec_indent(void);
# define SCOPE_ENTER_TASK(level, indent, ...) \
int __scope_level = level ; \
int __scope_task = 1 ; \
ast_debug ( __scope_level , " " __VA_ARGS__ ) ; \
if ( TRACE_ATLEAST ( level ) ) { \
__ast_trace ( __FILE__ , __LINE__ , __PRETTY_FUNCTION__ , AST_TRACE_INDENT_PROVIDED , indent , " " __VA_ARGS__ ) ; \
} \
@ -786,6 +790,7 @@ unsigned long _ast_trace_dec_indent(void);
* This macro can be used at the exit points of a statement block since it just prints the message .
*/
# define SCOPE_EXIT(...) \
ast_debug ( __scope_level , " " __VA_ARGS__ ) ; \
if ( TRACE_ATLEAST ( __scope_level ) ) { \
__ast_trace ( __FILE__ , __LINE__ , __PRETTY_FUNCTION__ , AST_TRACE_INDENT_DEC_BEFORE , 0 , " " __VA_ARGS__ ) ; \
if ( __scope_task ) { \
@ -814,6 +819,7 @@ unsigned long _ast_trace_dec_indent(void);
* }
*/
# define SCOPE_EXIT_EXPR(__expr, ...) \
ast_debug ( __scope_level , " " __VA_ARGS__ ) ; \
if ( TRACE_ATLEAST ( __scope_level ) ) { \
__ast_trace ( __FILE__ , __LINE__ , __PRETTY_FUNCTION__ , AST_TRACE_INDENT_DEC_BEFORE , 0 , " " __VA_ARGS__ ) ; \
if ( __scope_task ) { \
@ -833,6 +839,7 @@ unsigned long _ast_trace_dec_indent(void);
* needs to be returned .
*/
# define SCOPE_EXIT_RTN(...) \
ast_debug ( __scope_level , " " __VA_ARGS__ ) ; \
if ( TRACE_ATLEAST ( __scope_level ) ) { \
__ast_trace ( __FILE__ , __LINE__ , __PRETTY_FUNCTION__ , AST_TRACE_INDENT_DEC_BEFORE , 0 , " " __VA_ARGS__ ) ; \
if ( __scope_task ) { \
@ -853,6 +860,7 @@ unsigned long _ast_trace_dec_indent(void);
* needs to be returned .
*/
# define SCOPE_EXIT_RTN_VALUE(__return_value, ...) \
ast_debug ( __scope_level , " " __VA_ARGS__ ) ; \
if ( TRACE_ATLEAST ( __scope_level ) ) { \
__ast_trace ( __FILE__ , __LINE__ , __PRETTY_FUNCTION__ , AST_TRACE_INDENT_DEC_BEFORE , 0 , " " __VA_ARGS__ ) ; \
if ( __scope_task ) { \
@ -861,21 +869,79 @@ unsigned long _ast_trace_dec_indent(void);
} \
return ( __return_value )
# else
# define ast_trace_raw(__level, __indent_type, ...)
# define ast_trace(__level, ...)
# else /* AST_DEVMODE */
# define ast_trace_raw(level, indent_type, ...) \
ast_debug ( level < 0 ? __scope_level : level , " " __VA_ARGS__ )
# define ast_trace(level, ...) \
ast_debug ( level < 0 ? __scope_level : level , " " __VA_ARGS__ )
# define ast_trace_get_indent() (0)
# define ast_trace_set_indent(indent)
# define ast_trace_inc_indent()
# define ast_trace_dec_indent()
# define SCOPE_TRACE(__level, ...)
# define SCOPE_ENTER(level, ...)
# define SCOPE_ENTER_TASK(level, indent, ...)
# define SCOPE_EXIT(...)
# define SCOPE_EXIT_EXPR(__expr, ...) __expr
# define SCOPE_EXIT_RTN(...) return
# define SCOPE_EXIT_RTN_VALUE(__return_value, ...) return __return_value
# endif
# define SCOPE_ENTER(level, ...) \
int __scope_level = level ; \
ast_debug ( level , " " __VA_ARGS__ )
# define SCOPE_ENTER_TASK(level, indent, ...) \
int __scope_level = level ; \
ast_debug ( level , " " __VA_ARGS__ )
# define SCOPE_EXIT(...) \
ast_debug ( __scope_level , " " __VA_ARGS__ )
# define SCOPE_EXIT_EXPR(__expr, ...) \
ast_debug ( __scope_level , " " __VA_ARGS__ ) ; \
__expr
# define SCOPE_EXIT_RTN(...) \
ast_debug ( __scope_level , " " __VA_ARGS__ ) ; \
return
# define SCOPE_EXIT_RTN_VALUE(__return_value, ...) \
ast_debug ( __scope_level , " " __VA_ARGS__ ) ; \
return __return_value
# endif /* AST_DEVMODE */
/*!
* The following macros will print log messages before running
* the associated SCOPE_ macro .
*/
# define SCOPE_EXIT_LOG(__log_level, ...) \
( { \
ast_log ( __log_level , " " __VA_ARGS__ ) ; \
SCOPE_EXIT ( " " __VA_ARGS__ ) ; \
} )
# define SCOPE_EXIT_LOG_RTN(__log_level, ...) \
( { \
ast_log ( __log_level , " " __VA_ARGS__ ) ; \
SCOPE_EXIT_RTN ( " " __VA_ARGS__ ) ; \
} )
# define SCOPE_EXIT_LOG_RTN_VALUE(__value, __log_level, ...) \
( { \
ast_log ( __log_level , " " __VA_ARGS__ ) ; \
SCOPE_EXIT_RTN_VALUE ( __value , " " __VA_ARGS__ ) ; \
} )
# define SCOPE_EXIT_LOG_EXPR(__expr, __log_level, ...) \
( { \
ast_log ( __log_level , " " __VA_ARGS__ ) ; \
SCOPE_EXIT_EXPR ( __expr , " " __VA_ARGS__ ) ; \
} )
# define ast_trace_log(__level, __log_level, ...) \
( { \
ast_log ( __log_level , " " __VA_ARGS__ ) ; \
ast_trace ( __level < 0 ? __scope_level : __level , " " __VA_ARGS__ ) ; \
} )
# if defined(__cplusplus) || defined(c_plusplus)
}