Ignore:
Timestamp:
Dec 11, 2023, 1:05:50 PM (5 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
dab9fb93
Parents:
81da3da4
Message:

Try terminate now does not call the catch function, now they have the same caller. This involved updating some platform dependent code which should be correct in all cases.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/exception.c

    r81da3da4 r2554f24  
    5555}
    5656
     57struct __cfaehm_base_exception_t * __cfaehm_get_current_exception(void) {
     58        return this_exception_context()->current_exception;
     59}
    5760
    5861// RESUMPTION ================================================================
     
    309312                struct _Unwind_Context * unwind_context)
    310313{
    311 
    312314        //__cfadbg_print_safe(exception, "CFA: 0x%lx\n", _Unwind_GetCFA(context));
    313315        __cfadbg_print_safe(exception, "Personality function (%d, %x, %llu, %p, %p):",
     
    412414                                _Unwind_Word match_pos =
    413415#                               if defined( __x86_64 )
     416                                    _Unwind_GetCFA(unwind_context);
     417#                               elif defined( __i386 )
    414418                                    _Unwind_GetCFA(unwind_context) + 8;
    415 #                               elif defined( __i386 )
    416                                     _Unwind_GetCFA(unwind_context) + 24;
    417419#                               elif defined( __ARM_ARCH )
    418                                     _Unwind_GetCFA(unwind_context) + 40;
     420                                    _Unwind_GetCFA(unwind_context) + 16;
    419421#                               endif
    420422                                int (*matcher)(exception_t *) = *(int(**)(exception_t *))match_pos;
     
    480482// and simply linked from libcfa but there is one problem left, see the exception table for details
    481483__attribute__((noinline))
    482 void __cfaehm_try_terminate(void (*try_block)(),
    483                 void (*catch_block)(int index, exception_t * except),
     484int __cfaehm_try_terminate(void (*try_block)(),
    484485                __attribute__((unused)) int (*match_block)(exception_t * except)) {
    485486        //! volatile int xy = 0;
    486         //! printf("%p %p %p %p\n", &try_block, &catch_block, &match_block, &xy);
     487        //! printf("%p %p %p\n", &try_block, &match_block, &xy);
    487488
    488489        // Setup the personality routine and exception table.
     
    508509
    509510        // Normal return for when there is no throw.
    510         return;
     511        return 0;
    511512
    512513        // Exceptionnal path
     
    519520        asm volatile (".CATCH:");
    520521
    521         // Exception handler
    522         // Note: Saving the exception context on the stack breaks termination exceptions.
    523         catch_block( EXCEPT_TO_NODE( this_exception_context()->current_exception )->handler_index,
    524                      this_exception_context()->current_exception );
     522        return EXCEPT_TO_NODE( this_exception_context()->current_exception )->handler_index;
    525523}
    526524
Note: See TracChangeset for help on using the changeset viewer.