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