Changes in / [730f4f1:7c6b262]
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/exception.c
r730f4f1 r7c6b262 121 121 122 122 123 // MEMORY MANAGEMENT ========================================================= 123 // TERMINATION =============================================================== 124 125 // MEMORY MANAGEMENT (still for integers) 126 // May have to move to cfa for constructors and destructors (references). 124 127 125 128 // How to clean up an exception in various situations. … … 200 203 } 201 204 202 // CANCELLATION ============================================================== 205 // If this isn't a rethrow (*except==0), delete the provided exception. 206 void __cfaehm_cleanup_terminate( void * except ) { 207 if ( *(void**)except ) __cfaehm_delete_exception( *(exception_t **)except ); 208 } 203 209 204 210 // Function needed by force unwind … … 222 228 } 223 229 224 // Cancel the current stack, prefroming approprate clean-up and messaging.225 static __attribute__((noreturn)) void __cfaehm_cancel_stack(226 exception_t * exception ) {227 // TODO: Detect current stack and pick a particular stop-function.228 _Unwind_Reason_Code ret;229 ret = _Unwind_ForcedUnwind( &this_exception_storage, _Stop_Fn, (void*)0x22 );230 printf("UNWIND ERROR %d after force unwind\n", ret);231 abort();232 }233 234 235 // TERMINATION ===============================================================236 237 // If this isn't a rethrow (*except==0), delete the provided exception.238 void __cfaehm_cleanup_terminate( void * except ) {239 if ( *(void**)except ) __cfaehm_delete_exception( *(exception_t **)except );240 }241 242 230 // The exception that is being thrown must already be stored. 243 231 static __attribute__((noreturn)) void __cfaehm_begin_unwind(void) { … … 257 245 // the whole stack. 258 246 259 // No handler found, go to the default operation.260 // Currently this will always be a cancellation.261 247 if ( ret == _URC_END_OF_STACK ) { 262 __cfadbg_print_safe(exception, "Uncaught exception %p\n", &this_exception_storage); 263 264 __cfaehm_cancel_stack(this_exception_context()->current_exception); 248 // No proper handler was found. This can be handled in many ways, C++ calls std::terminate. 249 // Here we force unwind the stack, basically raising a cancellation. 250 printf("Uncaught exception %p\n", &this_exception_storage); 251 252 ret = _Unwind_ForcedUnwind( &this_exception_storage, _Stop_Fn, (void*)0x22 ); 253 printf("UNWIND ERROR %d after force unwind\n", ret); 254 abort(); 265 255 } 266 256 -
tests/exceptions/.expect/resume.txt
r730f4f1 r7c6b262 4 4 end of try clause 5 5 Exiting: simple try clause 6 7 catch-all8 6 9 7 throwing child exception -
tests/exceptions/.expect/terminate.txt
r730f4f1 r7c6b262 3 3 simple catch 4 4 Exiting: simple catch clause 5 6 catch-all7 5 8 6 throwing child exception -
tests/exceptions/resume.cfa
r730f4f1 r7c6b262 19 19 loud_exit a = "simple catch clause"; 20 20 printf("simple catch\n"); 21 }22 printf("\n");23 24 // Throw catch-all test.25 try {26 throwResume &(zen){};27 } catchResume (exception_t * error) {28 printf("catch-all\n");29 21 } 30 22 printf("\n"); -
tests/exceptions/terminate.cfa
r730f4f1 r7c6b262 17 17 printf("end of try clause\n"); 18 18 } catch (zen * error) { 19 19 loud_exit a = "simple catch clause"; 20 20 printf("simple catch\n"); 21 }22 printf("\n");23 24 // Throw catch-all test.25 try {26 throw &(zen){};27 } catch (exception_t * error) {28 printf("catch-all\n");29 21 } 30 22 printf("\n");
Note: See TracChangeset
for help on using the changeset viewer.