Changeset 142930b
- Timestamp:
- Dec 13, 2023, 4:45:21 PM (12 months ago)
- Branches:
- master
- Children:
- 21ad568
- Parents:
- 3e49c477
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/exception.c
r3e49c477 r142930b 55 55 } 56 56 57 struct __cfaehm_base_exception_t * __cfaehm_get_current_exception(void) {58 return this_exception_context()->current_exception;59 }60 57 61 58 // RESUMPTION ================================================================ … … 312 309 struct _Unwind_Context * unwind_context) 313 310 { 314 // __cfadbg_print_safe(exception, "CFA: 0x%lx\n", _Unwind_GetCFA(context));311 //! __cfadbg_print_safe(exception, "CFA: 0x%lx\n", _Unwind_GetCFA(unwind_context)); 315 312 __cfadbg_print_safe(exception, "Personality function (%d, %x, %llu, %p, %p):", 316 313 version, actions, exception_class, unwind_exception, unwind_context); … … 482 479 // and simply linked from libcfa but there is one problem left, see the exception table for details 483 480 __attribute__((noinline)) 484 int__cfaehm_try_terminate(void (*try_block)(),485 __attribute__((unused))void (*catch_block)(int index, exception_t * except),481 void __cfaehm_try_terminate(void (*try_block)(), 482 void (*catch_block)(int index, exception_t * except), 486 483 __attribute__((unused)) int (*match_block)(exception_t * except)) { 487 484 //! volatile int xy = 0; 488 //! printf("%p %p %p \n", &try_block, &match_block, &xy);485 //! printf("%p %p %p %p\n", &try_block, &catch_block, &match_block, &xy); 489 486 490 487 // Setup the personality routine and exception table. … … 510 507 511 508 // Normal return for when there is no throw. 512 return 0;509 return; 513 510 514 511 // Exceptionnal path … … 521 518 asm volatile (".CATCH:"); 522 519 523 return EXCEPT_TO_NODE( this_exception_context()->current_exception )->handler_index; 520 // Exception handler 521 // Note: Saving the exception context on the stack breaks termination exceptions. 522 catch_block( EXCEPT_TO_NODE( this_exception_context()->current_exception )->handler_index, 523 this_exception_context()->current_exception ); 524 524 } 525 525 -
libcfa/src/exception.h
r3e49c477 r142930b 43 43 extern struct __cfavir_type_info __cfatid_exception_t; 44 44 45 struct __cfaehm_base_exception_t * __cfaehm_get_current_exception(void);46 45 47 46 void __cfaehm_cancel_stack(exception_t * except) __attribute__((noreturn)); … … 58 57 59 58 // Function catches termination exceptions. 60 int__cfaehm_try_terminate(59 void __cfaehm_try_terminate( 61 60 void (*try_block)(), 62 61 void (*catch_block)(int index, exception_t * except), -
src/ControlStruct/ExceptTranslate.cpp
r3e49c477 r142930b 482 482 ast::FunctionDecl * terminate_catch, 483 483 ast::FunctionDecl * terminate_match ) { 484 // { 485 // int __handler_index = __cfaehm_try_terminate(`try`, `match`); 486 // if ( __handler_index ) { 487 // `catch`( __handler_index, __cfaehm_get_current_exception() ); 488 // } 489 // } 490 491 ast::ObjectDecl * index = new ast::ObjectDecl( loc, "__handler_index", 492 new ast::BasicType( ast::BasicType::SignedInt ), 493 new ast::SingleInit( loc, 494 new ast::UntypedExpr( loc, 495 new ast::NameExpr( loc, "__cfaehm_try_terminate" ), 496 { 497 new ast::VariableExpr( loc, try_wrapper ), 498 new ast::VariableExpr( loc, terminate_catch ), 499 new ast::VariableExpr( loc, terminate_match ), 500 } 501 ) 502 ) 503 ); 504 505 return new ast::CompoundStmt( loc, { 506 new ast::DeclStmt( loc, index ), 507 new ast::IfStmt( loc, 508 new ast::VariableExpr( loc, index ), 509 new ast::ExprStmt( loc, 510 new ast::UntypedExpr( loc, 511 new ast::VariableExpr( loc, terminate_catch ), 512 { 513 new ast::VariableExpr( loc, index ), 514 new ast::UntypedExpr( loc, 515 new ast::NameExpr( loc, "__cfaehm_get_current_exception" ) 516 ), 517 } 518 ) 519 ) 520 ), 521 } ); 484 // { __cfaehm_try_terminate(`try`, `catch`, `match`); } 485 486 ast::UntypedExpr * caller = new ast::UntypedExpr(loc, new ast::NameExpr(loc, 487 "__cfaehm_try_terminate" ) ); 488 caller->args.push_back( new ast::VariableExpr(loc, try_wrapper ) ); 489 caller->args.push_back( new ast::VariableExpr(loc, terminate_catch ) ); 490 caller->args.push_back( new ast::VariableExpr(loc, terminate_match ) ); 491 492 ast::CompoundStmt * callStmt = new ast::CompoundStmt(loc); 493 callStmt->push_back( new ast::ExprStmt( loc, caller ) ); 494 return callStmt; 522 495 } 523 496
Note: See TracChangeset
for help on using the changeset viewer.