Changes in libcfa/src/exception.c [73530d9:851fd92]
- File:
-
- 1 edited
-
libcfa/src/exception.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/exception.c
r73530d9 r851fd92 10 10 // Created On : Mon Jun 26 15:13:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Apr 03 11:57:00 202013 // Update Count : 1 412 // Last Modified On : Tue Apr 14 12:01:00 2020 13 // Update Count : 18 14 14 // 15 15 … … 28 28 #include <unwind.h> 29 29 #include <bits/debug.hfa> 30 #include "stdhdr/assert.h" 30 31 31 32 // FIX ME: temporary hack to keep ARM build working … … 75 76 // RESUMPTION ================================================================ 76 77 78 static void reset_top_resume(struct __cfaehm_try_resume_node ** store) { 79 this_exception_context()->top_resume = *store; 80 } 81 77 82 void __cfaehm_throw_resume(exception_t * except) { 78 83 struct exception_context_t * context = this_exception_context(); 79 84 80 __cfaabi_dbg_print_safe("Throwing resumption exception\n"); 81 85 __cfadbg_print_safe(exception, "Throwing resumption exception\n"); 86 87 __attribute__((cleanup(reset_top_resume))) 82 88 struct __cfaehm_try_resume_node * original_head = context->top_resume; 83 89 struct __cfaehm_try_resume_node * current = context->top_resume; … … 86 92 context->top_resume = current->next; 87 93 if (current->handler(except)) { 88 context->top_resume = original_head;89 94 return; 90 95 } 91 96 } 92 97 93 __cfaabi_dbg_print_safe("Unhandled exception\n"); 94 context->top_resume = original_head; 98 __cfadbg_print_safe(exception, "Unhandled exception\n"); 95 99 96 100 // Fall back to termination: … … 176 180 struct exception_context_t * context = this_exception_context(); 177 181 178 __cfa abi_dbg_print_safe("Deleting Exception\n");182 __cfadbg_print_safe(exception, "Deleting Exception\n"); 179 183 180 184 // Remove the exception from the list. … … 213 217 struct _Unwind_Context * unwind_context, 214 218 void * stop_param) { 215 if ( actions & _UA_END_OF_STACK ) exit(1); 216 if ( actions & _UA_CLEANUP_PHASE ) return _URC_NO_REASON; 217 218 return _URC_FATAL_PHASE2_ERROR; 219 // Verify actions follow the rules we expect. 220 verify((actions & _UA_CLEANUP_PHASE) && (actions & _UA_FORCE_UNWIND)); 221 verify(!(actions & (_UA_SEARCH_PHASE | _UA_HANDER_FRAME))); 222 223 if ( actions & _UA_END_OF_STACK ) { 224 exit(1); 225 } else { 226 return _URC_NO_REASON; 227 } 219 228 } 220 229 … … 252 261 253 262 void __cfaehm_throw_terminate( exception_t * val ) { 254 __cfa abi_dbg_print_safe("Throwing termination exception\n");263 __cfadbg_print_safe(exception, "Throwing termination exception\n"); 255 264 256 265 __cfaehm_allocate_exception( val ); … … 259 268 260 269 void __cfaehm_rethrow_terminate(void) { 261 __cfa abi_dbg_print_safe("Rethrowing termination exception\n");270 __cfadbg_print_safe(exception, "Rethrowing termination exception\n"); 262 271 263 272 __cfaehm_begin_unwind(); … … 275 284 { 276 285 277 //__cfa abi_dbg_print_safe("CFA: 0x%lx\n", _Unwind_GetCFA(context));278 __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):", 279 288 version, actions, exception_class, unwind_exception, unwind_context); 280 289 281 // If we've reached the end of the stack then there is nothing much we can do... 282 if (actions & _UA_END_OF_STACK) return _URC_END_OF_STACK; 283 290 // Verify that actions follow the rules we expect. 291 // This function should never be called at the end of the stack. 292 verify(!(actions & _UA_END_OF_STACK)); 293 // Either only the search phase flag is set or... 284 294 if (actions & _UA_SEARCH_PHASE) { 285 __cfaabi_dbg_print_safe(" lookup phase"); 286 } 287 else if (actions & _UA_CLEANUP_PHASE) { 288 __cfaabi_dbg_print_safe(" cleanup phase"); 289 } 290 // Just in case, probably can't actually happen 291 else { 292 printf(" error\n"); 293 return _URC_FATAL_PHASE1_ERROR; 295 verify(actions == _UA_SEARCH_PHASE); 296 __cfadbg_print_safe(exception, " lookup phase"); 297 // ... we are in clean-up phase. 298 } else { 299 verify(actions & _UA_CLEANUP_PHASE); 300 __cfadbg_print_safe(exception, " cleanup phase"); 301 // We shouldn't be the handler frame during forced unwind. 302 if (actions & _UA_HANDLER_FRAME) { 303 verify(!(actions & _UA_FORCE_UNWIND)); 304 __cfadbg_print_safe(exception, " (handler frame)"); 305 } else if (actions & _UA_FORCE_UNWIND) { 306 __cfadbg_print_safe(exception, " (force unwind)"); 307 } 294 308 } 295 309 … … 331 345 void * ep = (void*)lsd_info.Start + callsite_start + callsite_len; 332 346 void * ip = (void*)instruction_ptr; 333 __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", 334 348 bp, ep, ls, cs, cl, ip); 335 349 #endif // __CFA_DEBUG_PRINT__ … … 346 360 if ( 0 == callsite_landing_pad ) { 347 361 // Nothing to do, move along 348 __cfa abi_dbg_print_safe(" no landing pad");362 __cfadbg_print_safe(exception, " no landing pad"); 349 363 } else if (actions & _UA_SEARCH_PHASE) { 350 364 // In search phase, these means we found a potential handler we must check. … … 384 398 // Based on the return value, check if we matched the exception 385 399 if (ret == _URC_HANDLER_FOUND) { 386 __cfa abi_dbg_print_safe(" handler found\n");400 __cfadbg_print_safe(exception, " handler found\n"); 387 401 } else { 388 __cfa abi_dbg_print_safe(" no handler\n");402 __cfadbg_print_safe(exception, " no handler\n"); 389 403 } 390 404 return ret; … … 392 406 393 407 // This is only a cleanup handler, ignore it 394 __cfa abi_dbg_print_safe(" no action");395 } else if (actions & _UA_CLEANUP_PHASE){408 __cfadbg_print_safe(exception, " no action"); 409 } else { 396 410 // In clean-up phase, no destructors here but this could be the handler. 397 411 … … 414 428 _Unwind_SetIP( unwind_context, ((lsd_info.LPStart) + (callsite_landing_pad)) ); 415 429 416 __cfa abi_dbg_print_safe(" action\n");430 __cfadbg_print_safe(exception, " action\n"); 417 431 418 432 // Return have some action to run … … 421 435 } 422 436 // No handling found 423 __cfa abi_dbg_print_safe(" table end reached\n");437 __cfadbg_print_safe(exception, " table end reached"); 424 438 425 439 UNWIND: 426 __cfa abi_dbg_print_safe(" unwind\n");440 __cfadbg_print_safe(exception, " unwind\n"); 427 441 428 442 // Keep unwinding the stack … … 431 445 432 446 #pragma GCC push_options 433 #pragma GCC optimize( "O0")447 #pragma GCC optimize(0) 434 448 435 449 // Try statements are hoisted out see comments for details. While this could probably be unique … … 528 542 " .quad __gcfa_personality_v0\n" 529 543 #else // then __i386 530 " .long __gcfa_personality_v0\n"544 " .long __gcfa_personality_v0\n" 531 545 #endif 532 546 );
Note:
See TracChangeset
for help on using the changeset viewer.