Changeset b7898ac for libcfa


Ignore:
Timestamp:
Dec 18, 2023, 12:24:06 PM (7 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
9fba8e6
Parents:
5546eee4
Message:

Another attempt at fixing execptions. It is very close to the last attempt but the offsets have been updated and checked.

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/exception.c

    r5546eee4 rb7898ac  
    5555}
    5656
     57struct __cfaehm_base_exception_t * __cfaehm_get_current_termination(void) {
     58        return this_exception_context()->current_exception;
     59}
     60
    5761
    5862// RESUMPTION ================================================================
     
    309313                struct _Unwind_Context * unwind_context)
    310314{
    311         //! __cfadbg_print_safe(exception, "CFA: 0x%lx\n", _Unwind_GetCFA(unwind_context));
     315        __cfadbg_print_safe(exception, "CFA: 0x%p\n", (void*)_Unwind_GetCFA(unwind_context));
    312316        __cfadbg_print_safe(exception, "Personality function (%d, %x, %llu, %p, %p):",
    313317                        version, actions, exception_class, unwind_exception, unwind_context);
     
    411415                                _Unwind_Word match_pos =
    412416#                               if defined( __x86_64 )
    413                                     _Unwind_GetCFA(unwind_context) + 8;
     417                                        _Unwind_GetCFA(unwind_context);
    414418#                               elif defined( __i386 )
    415                                     _Unwind_GetCFA(unwind_context) + 24;
     419                                        _Unwind_GetCFA(unwind_context) + 20;
    416420#                               elif defined( __ARM_ARCH )
    417                                     _Unwind_GetCFA(unwind_context) + 40;
     421                                        _Unwind_GetCFA(unwind_context) + 16;
    418422#                               endif
     423                                //! printf("match_pos: %p\n", (void*)match_pos);
     424                                //! fflush(stdout);
    419425                                int (*matcher)(exception_t *) = *(int(**)(exception_t *))match_pos;
    420426
     
    479485// and simply linked from libcfa but there is one problem left, see the exception table for details
    480486__attribute__((noinline))
    481 void __cfaehm_try_terminate(void (*try_block)(),
    482                 void (*catch_block)(int index, exception_t * except),
     487int __cfaehm_try_terminate(void (*try_block)(),
    483488                __attribute__((unused)) int (*match_block)(exception_t * except)) {
    484489        //! volatile int xy = 0;
    485         //! printf("%p %p %p %p\n", &try_block, &catch_block, &match_block, &xy);
     490        //! printf("%p %p %p\n", &try_block, &match_block, &xy);
     491        //! fflush(stdout);
    486492
    487493        // Setup the personality routine and exception table.
     
    507513
    508514        // Normal return for when there is no throw.
    509         return;
     515        return 0;
    510516
    511517        // Exceptionnal path
     
    518524        asm volatile (".CATCH:");
    519525
    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 );
     526        return EXCEPT_TO_NODE( this_exception_context()->current_exception )->handler_index;
    524527}
    525528
  • libcfa/src/exception.h

    r5546eee4 rb7898ac  
    4444
    4545
     46struct __cfaehm_base_exception_t * __cfaehm_get_current_termination(void);
     47
     48
    4649void __cfaehm_cancel_stack(exception_t * except) __attribute__((noreturn));
    4750
     
    5760
    5861// Function catches termination exceptions.
    59 void __cfaehm_try_terminate(
     62int __cfaehm_try_terminate(
    6063        void (*try_block)(),
    61         void (*catch_block)(int index, exception_t * except),
    6264        int (*match_block)(exception_t * except));
    6365
Note: See TracChangeset for help on using the changeset viewer.