Changes in src/libcfa/exception.c [307a732:fa4805f]
- File:
-
- 1 edited
-
src/libcfa/exception.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/exception.c
r307a732 rfa4805f 44 44 // RESUMPTION ================================================================ 45 45 46 void __cfaehm__throw_resum ption(exception *except) {47 48 // DEBUG 49 printf("Throwing resumption exception %d\n", *except);50 51 struct __ cfaehm__try_resume_node * original_head = shared_stack.current_resume;52 struct __ cfaehm__try_resume_node * current =46 void __cfaehm__throw_resume(exception except) { 47 48 // DEBUG 49 printf("Throwing resumption exception %d\n", except); 50 51 struct __try_resume_node * original_head = shared_stack.current_resume; 52 struct __try_resume_node * current = 53 53 (original_head) ? original_head->next : shared_stack.top_resume; 54 54 55 55 for ( ; current ; current = current->next) { 56 56 shared_stack.current_resume = current; 57 if (current-> handler(except)) {57 if (current->try_to_handle(except)) { 58 58 shared_stack.current_resume = original_head; 59 59 return; … … 61 61 } 62 62 63 printf("Unhandled exception %d\n", *except);63 printf("Unhandled exception %d\n", except); 64 64 shared_stack.current_resume = original_head; 65 65 66 66 // Fall back to termination: 67 __cfaehm__throw_terminat ion(except);67 __cfaehm__throw_terminate(except); 68 68 // TODO: Default handler for resumption. 69 69 } … … 73 73 * after the node is built but before it is made the top node. 74 74 */ 75 void __ cfaehm__try_resume_setup(struct __cfaehm__try_resume_node * node,76 int (*handler)(exception *except)) {75 void __try_resume_setup(struct __try_resume_node * node, 76 bool (*handler)(exception except)) { 77 77 node->next = shared_stack.top_resume; 78 node-> handler= handler;78 node->try_to_handle = handler; 79 79 shared_stack.top_resume = node; 80 80 } 81 81 82 void __ cfaehm__try_resume_cleanup(struct __cfaehm__try_resume_node * node) {82 void __try_resume_cleanup(struct __try_resume_node * node) { 83 83 shared_stack.top_resume = node->next; 84 84 } … … 111 111 } 112 112 113 void __cfaehm__throw_terminat ion( exception *val ) {113 void __cfaehm__throw_terminate( int val ) { 114 114 // Store the current exception 115 shared_stack.current_exception = *val;116 117 // DEBUG 118 printf("Throwing termination exception %d\n", *val);115 shared_stack.current_exception = val; 116 117 // DEBUG 118 printf("Throwing termination exception %d\n", val); 119 119 120 120 // Call stdlibc to raise the exception … … 147 147 148 148 // Nesting this the other way would probably be faster. 149 void __cfaehm__rethrow_terminat ion(void) {149 void __cfaehm__rethrow_terminate(void) { 150 150 // DEBUG 151 151 printf("Rethrowing termination exception\n"); 152 152 153 __cfaehm__throw_terminat ion(&shared_stack.current_exception);153 __cfaehm__throw_terminate(shared_stack.current_exception); 154 154 } 155 155 … … 322 322 // for details 323 323 __attribute__((noinline)) 324 void __ cfaehm__try_terminate(void (*try_block)(),325 void (*catch_block)(int index, exception *except),326 __attribute__((unused)) int (*match_block)(exception *except)) {324 void __try_terminate(void (*try_block)(), 325 void (*catch_block)(int index, exception except), 326 __attribute__((unused)) int (*match_block)(exception except)) { 327 327 //! volatile int xy = 0; 328 328 //! printf("%p %p %p %p\n", &try_block, &catch_block, &match_block, &xy); … … 364 364 // Exception handler 365 365 catch_block(shared_stack.current_handler_index, 366 &shared_stack.current_exception);366 shared_stack.current_exception); 367 367 } 368 368 … … 384 384 // Body uses language specific data and therefore could be modified arbitrarily 385 385 ".LLSDACSBCFA2:\n" // BODY start 386 " .uleb128 .TRYSTART-__ cfaehm__try_terminate\n" // Handled area start (relative to start of function)386 " .uleb128 .TRYSTART-__try_terminate\n" // Handled area start (relative to start of function) 387 387 " .uleb128 .TRYEND-.TRYSTART\n" // Handled area length 388 " .uleb128 .CATCH-__ cfaehm__try_terminate\n" // Hanlder landing pad adress (relative to start of function)388 " .uleb128 .CATCH-__try_terminate\n" // Hanlder landing pad adress (relative to start of function) 389 389 " .uleb128 1\n" // Action code, gcc seems to use always 0 390 390 ".LLSDACSECFA2:\n" // BODY end 391 391 " .text\n" // TABLE footer 392 " .size __ cfaehm__try_terminate, .-__cfaehm__try_terminate\n"392 " .size __try_terminate, .-__try_terminate\n" 393 393 " .ident \"GCC: (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901\"\n" 394 394 // " .section .note.GNU-stack,\"x\",@progbits\n"
Note:
See TracChangeset
for help on using the changeset viewer.