Changeset 36982fc for src/libcfa/libhdr
- Timestamp:
- Nov 29, 2017, 2:50:33 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 875a72f
- Parents:
- 8a0a64d9
- Location:
- src/libcfa/libhdr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/libhdr/libdebug.c
r8a0a64d9 r36982fc 28 28 extern "C" { 29 29 30 void __ lib_debug_write( const char *in_buffer, int len ) {30 void __cfaabi_dbg_bits_write( const char *in_buffer, int len ) { 31 31 // ensure all data is written 32 32 for ( int count = 0, retcode; count < len; count += retcode ) { … … 44 44 } 45 45 46 void __ lib_debug_acquire() __attribute__((__weak__)) {}47 void __ lib_debug_release() __attribute__((__weak__)) {}46 void __cfaabi_dbg_bits_acquire() __attribute__((__weak__)) {} 47 void __cfaabi_dbg_bits_release() __attribute__((__weak__)) {} 48 48 49 void __ lib_debug_print_safe ( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )) {49 void __cfaabi_dbg_bits_print_safe ( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )) { 50 50 va_list args; 51 51 52 52 va_start( args, fmt ); 53 __ lib_debug_acquire();53 __cfaabi_dbg_bits_acquire(); 54 54 55 55 int len = vsnprintf( buffer, buffer_size, fmt, args ); 56 __ lib_debug_write( buffer, len );56 __cfaabi_dbg_bits_write( buffer, len ); 57 57 58 __ lib_debug_release();58 __cfaabi_dbg_bits_release(); 59 59 va_end( args ); 60 60 } 61 61 62 void __ lib_debug_print_nolock( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )) {62 void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )) { 63 63 va_list args; 64 64 … … 66 66 67 67 int len = vsnprintf( buffer, buffer_size, fmt, args ); 68 __ lib_debug_write( buffer, len );68 __cfaabi_dbg_bits_write( buffer, len ); 69 69 70 70 va_end( args ); 71 71 } 72 72 73 void __ lib_debug_print_vararg( const char fmt[], va_list args ) {73 void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list args ) { 74 74 int len = vsnprintf( buffer, buffer_size, fmt, args ); 75 __ lib_debug_write( buffer, len );75 __cfaabi_dbg_bits_write( buffer, len ); 76 76 } 77 77 78 void __ lib_debug_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format (printf, 3, 4) )) {78 void __cfaabi_dbg_bits_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format (printf, 3, 4) )) { 79 79 va_list args; 80 80 … … 82 82 83 83 int len = vsnprintf( in_buffer, in_buffer_size, fmt, args ); 84 __ lib_debug_write( in_buffer, len );84 __cfaabi_dbg_bits_write( in_buffer, len ); 85 85 86 86 va_end( args ); -
src/libcfa/libhdr/libdebug.h
r8a0a64d9 r36982fc 17 17 18 18 #ifdef __CFA_DEBUG__ 19 #define LIB_DEBUG_DO(...) __VA_ARGS__20 #define LIB_NO_DEBUG_DO(...)21 #define DEBUG_CTX__PRETTY_FUNCTION__22 #define DEBUG_CTX2 , __PRETTY_FUNCTION__23 #define DEBUG_CTX_PARAMconst char * caller24 #define DEBUG_CTX_PARAM2 , const char * caller19 #define __cfaabi_dbg_debug_do(...) __VA_ARGS__ 20 #define __cfaabi_dbg_no_debug_do(...) 21 #define __cfaabi_dbg_ctx __PRETTY_FUNCTION__ 22 #define __cfaabi_dbg_ctx2 , __PRETTY_FUNCTION__ 23 #define __cfaabi_dbg_ctx_param const char * caller 24 #define __cfaabi_dbg_ctx_param2 , const char * caller 25 25 #else 26 #define LIB_DEBUG_DO(...)27 #define LIB_NO_DEBUG_DO(...) __VA_ARGS__28 #define DEBUG_CTX29 #define DEBUG_CTX230 #define DEBUG_CTX_PARAM31 #define DEBUG_CTX_PARAM226 #define __cfaabi_dbg_debug_do(...) 27 #define __cfaabi_dbg_no_debug_do(...) __VA_ARGS__ 28 #define __cfaabi_dbg_ctx 29 #define __cfaabi_dbg_ctx2 30 #define __cfaabi_dbg_ctx_param 31 #define __cfaabi_dbg_ctx_param2 32 32 #endif 33 33 34 #if !defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__)) 35 #define verify(x) assert(x) 36 #define verifyf(x, ...) assertf(x, __VA_ARGS__) 37 #else 38 #define verify(x) 39 #define verifyf(x, ...) 40 #endif 41 34 __cfaabi::ehm 35 __cfaabi::dbg 36 __cfaabi::rt 37 __cfaabi::mem 42 38 43 39 #ifdef __cforall … … 47 43 #include <stdio.h> 48 44 49 extern void __ lib_debug_write( const char *buffer, int len );50 extern void __ lib_debug_acquire();51 extern void __ lib_debug_release();52 extern void __ lib_debug_print_safe ( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) ));53 extern void __ lib_debug_print_nolock( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) ));54 extern void __ lib_debug_print_vararg( const char fmt[], va_list arg );55 extern void __ lib_debug_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format (printf, 3, 4) ));45 extern void __cfaabi_dbg_bits_write( const char *buffer, int len ); 46 extern void __cfaabi_dbg_bits_acquire(); 47 extern void __cfaabi_dbg_bits_release(); 48 extern void __cfaabi_dbg_bits_print_safe ( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )); 49 extern void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )); 50 extern void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list arg ); 51 extern void __cfaabi_dbg_bits_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format (printf, 3, 4) )); 56 52 #ifdef __cforall 57 53 } … … 59 55 60 56 #ifdef __CFA_DEBUG_PRINT__ 61 #define LIB_DEBUG_WRITE( buffer, len ) __lib_debug_write( buffer, len )62 #define LIB_DEBUG_ACQUIRE() __lib_debug_acquire()63 #define LIB_DEBUG_RELEASE() __lib_debug_release()64 #define LIB_DEBUG_PRINT_SAFE(...) __lib_debug_print_safe (__VA_ARGS__)65 #define LIB_DEBUG_PRINT_NOLOCK(...) __lib_debug_print_nolock (__VA_ARGS__)66 #define LIB_DEBUG_PRINT_BUFFER(...) __lib_debug_print_buffer (__VA_ARGS__)67 #define LIB_DEBUG_PRINT_BUFFER_DECL(...) char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __lib_debug_write( __dbg_text, __dbg_len );68 #define LIB_DEBUG_PRINT_BUFFER_LOCAL(...) __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __lib_debug_write( __dbg_text, __dbg_len );57 #define __cfaabi_dbg_write( buffer, len ) __cfaabi_dbg_bits_write( buffer, len ) 58 #define __cfaabi_dbg_acquire() __cfaabi_dbg_bits_acquire() 59 #define __cfaabi_dbg_release() __cfaabi_dbg_bits_release() 60 #define __cfaabi_dbg_print_safe(...) __cfaabi_dbg_bits_print_safe (__VA_ARGS__) 61 #define __cfaabi_dbg_print_nolock(...) __cfaabi_dbg_bits_print_nolock (__VA_ARGS__) 62 #define __cfaabi_dbg_print_buffer(...) __cfaabi_dbg_bits_print_buffer (__VA_ARGS__) 63 #define __cfaabi_dbg_print_buffer_decl(...) char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_bits_write( __dbg_text, __dbg_len ); 64 #define __cfaabi_dbg_print_buffer_local(...) __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_bits_write( __dbg_text, __dbg_len ); 69 65 #else 70 #define LIB_DEBUG_WRITE(...) ((void)0)71 #define LIB_DEBUG_ACQUIRE() ((void)0)72 #define LIB_DEBUG_RELEASE() ((void)0)73 #define LIB_DEBUG_PRINT_SAFE(...) ((void)0)74 #define LIB_DEBUG_PRINT_NOLOCK(...) ((void)0)75 #define LIB_DEBUG_PRINT_BUFFER(...) ((void)0)76 #define LIB_DEBUG_PRINT_BUFFER_DECL(...) ((void)0)77 #define LIB_DEBUG_PRINT_BUFFER_LOCAL(...) ((void)0)66 #define __cfaabi_dbg_write(...) ((void)0) 67 #define __cfaabi_dbg_acquire() ((void)0) 68 #define __cfaabi_dbg_release() ((void)0) 69 #define __cfaabi_dbg_print_safe(...) ((void)0) 70 #define __cfaabi_dbg_print_nolock(...) ((void)0) 71 #define __cfaabi_dbg_print_buffer(...) ((void)0) 72 #define __cfaabi_dbg_print_buffer_decl(...) ((void)0) 73 #define __cfaabi_dbg_print_buffer_local(...) ((void)0) 78 74 #endif 79 75
Note: See TracChangeset
for help on using the changeset viewer.