Changeset 851fd92
- Timestamp:
- Apr 27, 2020, 11:36:47 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- c680a4b
- Parents:
- b25aafa
- Location:
- libcfa/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/debug.hfa
rb25aafa r851fd92 9 9 // Author : Thierry Delisle 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Feb 4 12:29:21202013 // Update Count : 911 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Apr 27 10:15:00 2020 13 // Update Count : 10 14 14 // 15 15 … … 40 40 #endif 41 41 #include <stdarg.h> 42 #include <stdio.h>43 42 44 43 extern void __cfaabi_bits_write( int fd, const char buffer[], int len ); … … 49 48 extern void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list arg ); 50 49 extern void __cfaabi_bits_print_buffer( int fd, char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) )); 50 51 #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__) \ 52 || defined(__CFA_DEBUG_PRINT_MONITOR__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__) \ 53 || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__) 54 #include <stdio.h> 55 #include <unistd.h> 56 #endif 51 57 #ifdef __cforall 52 58 } 53 59 #endif 54 60 61 // Deprecated: Use the versions with the new module names. 55 62 #ifdef __CFA_DEBUG_PRINT__ 56 63 #define __cfaabi_dbg_write( buffer, len ) __cfaabi_bits_write( STDERR_FILENO, buffer, len ) … … 73 80 #endif 74 81 82 // Debug print functions and statements: 83 // Most are wrappers around the bits printing function but are not always used. 84 // If they are used depends if the group (first argument) is active or not. The group must be one 85 // defined belowe. The other arguments depend on the wrapped function. 86 #define __cfadbg_write(group, buffer, len) \ 87 __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_write(STDERR_FILENO, buffer, len)) 88 #define __cfadbg_acquire(group) \ 89 __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_acquire()) 90 #define __cfadbg_release(group) \ 91 __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_release()) 92 #define __cfadbg_print_safe(group, ...) \ 93 __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_safe(STDERR_FILENO, __VA_ARGS__)) 94 #define __cfadbg_print_nolock(group, ...) \ 95 __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_nolock(STDERR_FILENO, __VA_ARGS__)) 96 #define __cfadbg_print_buffer(group, ...) \ 97 __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_buffer(STDERR_FILENO, __VA_ARGS__)) 98 #define __cfadbg_print_buffer_decl(group, ...) \ 99 __CFADBG_PRINT_GROUP_##group(char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( __dbg_text, __dbg_len )) 100 #define __cfadbg_print_buffer_local(group, ...) \ 101 __CFADBG_PRINT_GROUP_##group(__dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write(STDERR_FILENO, __dbg_text, __dbg_len)) 102 103 // The debug print groups: 104 #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__) 105 # define __CFADBG_PRINT_GROUP_io(...) __VA_ARGS__ 106 #else 107 # define __CFADBG_PRINT_GROUP_io(...) ((void)0) 108 #endif 109 #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_MONITOR__) 110 # define __CFADBG_PRINT_GROUP_monitor(...) __VA_ARGS__ 111 #else 112 # define __CFADBG_PRINT_GROUP_monitor(...) ((void)0) 113 #endif 114 #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__) 115 # define __CFADBG_PRINT_GROUP_preemption(...) __VA_ARGS__ 116 #else 117 # define __CFADBG_PRINT_GROUP_preemption(...) ((void)0) 118 #endif 119 #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__) 120 # define __CFADBG_PRINT_GROUP_runtime_core(...) __VA_ARGS__ 121 #else 122 # define __CFADBG_PRINT_GROUP_runtime_core(...) ((void)0) 123 #endif 124 #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_READY_QUEUE__) 125 # define __CFADBG_PRINT_GROUP_ready_queue(...) __VA_ARGS__ 126 #else 127 # define __CFADBG_PRINT_GROUP_ready_queue(...) ((void)0) 128 #endif 129 #if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__) 130 # define __CFADBG_PRINT_GROUP_exception(...) __VA_ARGS__ 131 #else 132 # define __CFADBG_PRINT_GROUP_exception(...) ((void)0) 133 #endif 134 75 135 // Local Variables: // 76 136 // mode: c // -
libcfa/src/exception.c
rb25aafa r851fd92 83 83 struct exception_context_t * context = this_exception_context(); 84 84 85 __cfa abi_dbg_print_safe("Throwing resumption exception\n");85 __cfadbg_print_safe(exception, "Throwing resumption exception\n"); 86 86 87 87 __attribute__((cleanup(reset_top_resume))) … … 96 96 } 97 97 98 __cfa abi_dbg_print_safe("Unhandled exception\n");98 __cfadbg_print_safe(exception, "Unhandled exception\n"); 99 99 100 100 // Fall back to termination: … … 180 180 struct exception_context_t * context = this_exception_context(); 181 181 182 __cfa abi_dbg_print_safe("Deleting Exception\n");182 __cfadbg_print_safe(exception, "Deleting Exception\n"); 183 183 184 184 // Remove the exception from the list. … … 218 218 void * stop_param) { 219 219 // Verify actions follow the rules we expect. 220 verify((actions & _UA_CLEANUP_PHASE) && actions & (_UA_FORCE_UNWIND));220 verify((actions & _UA_CLEANUP_PHASE) && (actions & _UA_FORCE_UNWIND)); 221 221 verify(!(actions & (_UA_SEARCH_PHASE | _UA_HANDER_FRAME))); 222 222 … … 261 261 262 262 void __cfaehm_throw_terminate( exception_t * val ) { 263 __cfa abi_dbg_print_safe("Throwing termination exception\n");263 __cfadbg_print_safe(exception, "Throwing termination exception\n"); 264 264 265 265 __cfaehm_allocate_exception( val ); … … 268 268 269 269 void __cfaehm_rethrow_terminate(void) { 270 __cfa abi_dbg_print_safe("Rethrowing termination exception\n");270 __cfadbg_print_safe(exception, "Rethrowing termination exception\n"); 271 271 272 272 __cfaehm_begin_unwind(); … … 284 284 { 285 285 286 //__cfa abi_dbg_print_safe("CFA: 0x%lx\n", _Unwind_GetCFA(context));287 __cfa abi_dbg_print_safe("Personality function (%d, %x, %llu, %p, %p):",286 //__cfadbg_print_safe(exception, "CFA: 0x%lx\n", _Unwind_GetCFA(context)); 287 __cfadbg_print_safe(exception, "Personality function (%d, %x, %llu, %p, %p):", 288 288 version, actions, exception_class, unwind_exception, unwind_context); 289 289 … … 294 294 if (actions & _UA_SEARCH_PHASE) { 295 295 verify(actions == _UA_SEARCH_PHASE); 296 __cfa abi_dbg_print_safe(" lookup phase");296 __cfadbg_print_safe(exception, " lookup phase"); 297 297 // ... we are in clean-up phase. 298 298 } else { 299 299 verify(actions & _UA_CLEANUP_PHASE); 300 __cfa abi_dbg_print_safe(" cleanup phase");300 __cfadbg_print_safe(exception, " cleanup phase"); 301 301 // We shouldn't be the handler frame during forced unwind. 302 302 if (actions & _UA_HANDLER_FRAME) { 303 303 verify(!(actions & _UA_FORCE_UNWIND)); 304 __cfa abi_dbg_print_safe(" (handler frame)");304 __cfadbg_print_safe(exception, " (handler frame)"); 305 305 } else if (actions & _UA_FORCE_UNWIND) { 306 __cfa abi_dbg_print_safe(" (force unwind)");306 __cfadbg_print_safe(exception, " (force unwind)"); 307 307 } 308 308 } … … 345 345 void * ep = (void*)lsd_info.Start + callsite_start + callsite_len; 346 346 void * ip = (void*)instruction_ptr; 347 __cfa abi_dbg_print_safe("\nfound %p - %p (%p, %p, %p), looking for %p\n",347 __cfadbg_print_safe(exception, "\nfound %p - %p (%p, %p, %p), looking for %p\n", 348 348 bp, ep, ls, cs, cl, ip); 349 349 #endif // __CFA_DEBUG_PRINT__ … … 360 360 if ( 0 == callsite_landing_pad ) { 361 361 // Nothing to do, move along 362 __cfa abi_dbg_print_safe(" no landing pad");362 __cfadbg_print_safe(exception, " no landing pad"); 363 363 } else if (actions & _UA_SEARCH_PHASE) { 364 364 // In search phase, these means we found a potential handler we must check. … … 398 398 // Based on the return value, check if we matched the exception 399 399 if (ret == _URC_HANDLER_FOUND) { 400 __cfa abi_dbg_print_safe(" handler found\n");400 __cfadbg_print_safe(exception, " handler found\n"); 401 401 } else { 402 __cfa abi_dbg_print_safe(" no handler\n");402 __cfadbg_print_safe(exception, " no handler\n"); 403 403 } 404 404 return ret; … … 406 406 407 407 // This is only a cleanup handler, ignore it 408 __cfa abi_dbg_print_safe(" no action");408 __cfadbg_print_safe(exception, " no action"); 409 409 } else { 410 410 // In clean-up phase, no destructors here but this could be the handler. … … 428 428 _Unwind_SetIP( unwind_context, ((lsd_info.LPStart) + (callsite_landing_pad)) ); 429 429 430 __cfa abi_dbg_print_safe(" action\n");430 __cfadbg_print_safe(exception, " action\n"); 431 431 432 432 // Return have some action to run … … 435 435 } 436 436 // No handling found 437 __cfa abi_dbg_print_safe(" table end reached\n");437 __cfadbg_print_safe(exception, " table end reached"); 438 438 439 439 UNWIND: 440 __cfa abi_dbg_print_safe(" unwind\n");440 __cfadbg_print_safe(exception, " unwind\n"); 441 441 442 442 // Keep unwinding the stack -
libcfa/src/interpose.cfa
rb25aafa r851fd92 15 15 16 16 #include <stdarg.h> // va_start, va_end 17 #include <stdio.h> 17 18 #include <string.h> // strlen 18 19 #include <unistd.h> // _exit, getpid
Note: See TracChangeset
for help on using the changeset viewer.