// // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // debug.hfa -- // // Author : Thierry Delisle // Created On : Mon Nov 28 12:27:26 2016 // Last Modified By : Peter A. Buhr // Last Modified On : Fri Apr 22 18:21:56 2022 // Update Count : 11 // #pragma once #include #ifdef __CFA_DEBUG__ #define __cfaabi_dbg_debug_do(...) __VA_ARGS__ #define __cfaabi_dbg_no_debug_do(...) #define __cfaabi_dbg_ctx __PRETTY_FUNCTION__ #define __cfaabi_dbg_ctx2 , __PRETTY_FUNCTION__ #define __cfaabi_dbg_ctx_param __attribute__((unused)) const char caller[] #define __cfaabi_dbg_ctx_param2 , __attribute__((unused)) const char caller[] #define __cfaabi_dbg_ctx_fwd caller #define __cfaabi_dbg_ctx_fwd2 , caller #else #define __cfaabi_dbg_debug_do(...) #define __cfaabi_dbg_no_debug_do(...) __VA_ARGS__ #define __cfaabi_dbg_ctx #define __cfaabi_dbg_ctx2 #define __cfaabi_dbg_ctx_param #define __cfaabi_dbg_ctx_param2 #define __cfaabi_dbg_ctx_fwd #define __cfaabi_dbg_ctx_fwd2 #endif #ifdef __cforall extern "C" { #endif #include extern void __cfaabi_bits_write( int fd, const char buffer[], int len ); extern void __cfaabi_bits_acquire(); extern void __cfaabi_bits_release(); extern int __cfaabi_bits_print_safe ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )); extern int __cfaabi_bits_print_nolock( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )); extern int __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list arg ); extern int __cfaabi_bits_print_buffer( int fd, char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) )); #if defined(__CFA_DEBUG_PRINT__) \ || defined(__CFA_DEBUG_PRINT_IO__) || defined(__CFA_DEBUG_PRINT_IO_CORE__) \ || defined(__CFA_DEBUG_PRINT_MONITOR__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__) \ || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__) \ || defined(__CFA_DEBUG_PRINT_READY_QUEUE__) #include #include #endif #ifdef __cforall } #endif // Deprecated: Use the versions with the new module names. #ifdef __CFA_DEBUG_PRINT__ #define __cfaabi_dbg_write( buffer, len ) __cfaabi_bits_write( STDERR_FILENO, buffer, len ) #define __cfaabi_dbg_acquire() __cfaabi_bits_acquire() #define __cfaabi_dbg_release() __cfaabi_bits_release() #define __cfaabi_dbg_print_safe(...) __cfaabi_bits_print_safe ( STDERR_FILENO, __VA_ARGS__ ) #define __cfaabi_dbg_print_nolock(...) __cfaabi_bits_print_nolock ( STDERR_FILENO, __VA_ARGS__ ) #define __cfaabi_dbg_print_buffer(...) __cfaabi_bits_print_buffer ( STDERR_FILENO, __VA_ARGS__ ) #define __cfaabi_dbg_print_buffer_decl(...) char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( STDERR_FILENO, __dbg_text, __dbg_len ); #define __cfaabi_dbg_print_buffer_local(...) __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_write( STDERR_FILENO, __dbg_text, __dbg_len ); #else #define __cfaabi_dbg_write(...) ((void)0) #define __cfaabi_dbg_acquire() ((void)0) #define __cfaabi_dbg_release() ((void)0) #define __cfaabi_dbg_print_safe(...) ((void)0) #define __cfaabi_dbg_print_nolock(...) ((void)0) #define __cfaabi_dbg_print_buffer(...) ((void)0) #define __cfaabi_dbg_print_buffer_decl(...) ((void)0) #define __cfaabi_dbg_print_buffer_local(...) ((void)0) #endif // Debug print functions and statements: // Most are wrappers around the bits printing function but are not always used. // If they are used depends if the group (first argument) is active or not. The group must be one // defined belowe. The other arguments depend on the wrapped function. #define __cfadbg_write(group, buffer, len) \ __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_write(STDERR_FILENO, buffer, len)) #define __cfadbg_acquire(group) \ __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_acquire()) #define __cfadbg_release(group) \ __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_release()) #define __cfadbg_print_safe(group, ...) \ __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_safe(STDERR_FILENO, __VA_ARGS__)) #define __cfadbg_print_nolock(group, ...) \ __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_nolock(STDERR_FILENO, __VA_ARGS__)) #define __cfadbg_print_buffer(group, ...) \ __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_buffer(STDERR_FILENO, __VA_ARGS__)) #define __cfadbg_print_buffer_decl(group, ...) \ __CFADBG_PRINT_GROUP_##group(char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( STDERR_FILENO, __dbg_text, __dbg_len )) #define __cfadbg_print_buffer_local(group, ...) \ __CFADBG_PRINT_GROUP_##group(__dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write(STDERR_FILENO, __dbg_text, __dbg_len)) // The debug print groups: #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__) # define __CFADBG_PRINT_GROUP_io(...) __VA_ARGS__ #else # define __CFADBG_PRINT_GROUP_io(...) ((void)0) #endif #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__) || defined(__CFA_DEBUG_PRINT_IO_CORE__) # define __CFADBG_PRINT_GROUP_io_core(...) __VA_ARGS__ #else # define __CFADBG_PRINT_GROUP_io_core(...) ((void)0) #endif #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_MONITOR__) # define __CFADBG_PRINT_GROUP_monitor(...) __VA_ARGS__ #else # define __CFADBG_PRINT_GROUP_monitor(...) ((void)0) #endif #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__) # define __CFADBG_PRINT_GROUP_preemption(...) __VA_ARGS__ #else # define __CFADBG_PRINT_GROUP_preemption(...) ((void)0) #endif #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__) # define __CFADBG_PRINT_GROUP_runtime_core(...) __VA_ARGS__ #else # define __CFADBG_PRINT_GROUP_runtime_core(...) ((void)0) #endif #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_READY_QUEUE__) # define __CFADBG_PRINT_GROUP_ready_queue(...) __VA_ARGS__ #else # define __CFADBG_PRINT_GROUP_ready_queue(...) ((void)0) #endif #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__) # define __CFADBG_PRINT_GROUP_exception(...) __VA_ARGS__ #else # define __CFADBG_PRINT_GROUP_exception(...) ((void)0) #endif // Local Variables: // // mode: c // // tab-width: 4 // // End: //