Ignore:
Timestamp:
Sep 1, 2020, 1:18:10 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
86c1f1c3, a77496cb
Parents:
8d8ac3b (diff), d3aa64f1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/exception.c

    r8d8ac3b r25a1cb0  
    1010// Created On       : Mon Jun 26 15:13:00 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 21 11:27:56 2020
    13 // Update Count     : 29
     12// Last Modified On : Sat Aug 29 15:52:22 2020
     13// Update Count     : 34
    1414//
    1515
     
    1818
    1919#include "exception.h"
    20 
    21 // Implementation of the secret header is hardware dependent.
    22 #if defined( __x86_64 ) || defined( __i386 )
    23 #elif defined( __ARM_ARCH )
    24 #warning FIX ME: check if anything needed for ARM
    25 #else
    26 #warning Exception Handling: No known architecture detected.
    27 #endif
    2820
    2921#include <stdlib.h>
     
    3426#include "stdhdr/assert.h"
    3527
    36 // FIX ME: temporary hack to keep ARM build working
     28#if defined( __ARM_ARCH )
     29#warning FIX ME: temporary hack to keep ARM build working
    3730#ifndef _URC_FATAL_PHASE1_ERROR
    3831#define _URC_FATAL_PHASE1_ERROR 3
     
    4134#define _URC_FATAL_PHASE2_ERROR 2
    4235#endif // ! _URC_FATAL_PHASE2_ERROR
     36#endif // __ARM_ARCH
    4337
    4438#include "lsda.h"
     
    209203                void * stop_param) {
    210204        // Verify actions follow the rules we expect.
    211         verify((actions & _UA_CLEANUP_PHASE) && (actions & _UA_FORCE_UNWIND));
    212         verify(!(actions & (_UA_SEARCH_PHASE | _UA_HANDLER_FRAME)));
     205        verify(actions & _UA_CLEANUP_PHASE);
     206        verify(actions & _UA_FORCE_UNWIND);
     207        verify(!(actions & _UA_SEARCH_PHASE));
     208        verify(!(actions & _UA_HANDLER_FRAME));
    213209
    214210        if ( actions & _UA_END_OF_STACK ) {
    215                 exit(1);
     211                abort();
    216212        } else {
    217213                return _URC_NO_REASON;
     
    219215}
    220216
    221 static struct _Unwind_Exception cancel_exception_storage;
     217__attribute__((weak)) _Unwind_Reason_Code
     218__cfaehm_cancellation_unwind( struct _Unwind_Exception * exception ) {
     219        return _Unwind_ForcedUnwind( exception, _Stop_Fn, (void*)0x22 );
     220}
    222221
    223222// Cancel the current stack, prefroming approprate clean-up and messaging.
    224223void __cfaehm_cancel_stack( exception_t * exception ) {
    225         // TODO: Detect current stack and pick a particular stop-function.
     224        __cfaehm_allocate_exception( exception );
     225
     226        struct exception_context_t * context = this_exception_context();
     227        struct __cfaehm_node * node = EXCEPT_TO_NODE(context->current_exception);
     228
     229        // Preform clean-up of any extra active exceptions.
     230        while ( node->next ) {
     231                struct __cfaehm_node * to_free = node->next;
     232                node->next = to_free->next;
     233                exception_t * except = NODE_TO_EXCEPT( to_free );
     234                except->virtual_table->free( except );
     235            free( to_free );
     236        }
     237
    226238        _Unwind_Reason_Code ret;
    227         ret = _Unwind_ForcedUnwind( &cancel_exception_storage, _Stop_Fn, (void*)0x22 );
     239        ret = __cfaehm_cancellation_unwind( &node->unwind_exception );
    228240        printf("UNWIND ERROR %d after force unwind\n", ret);
    229241        abort();
     
    608620
    609621#pragma GCC pop_options
     622
     623#elif defined( __ARM_ARCH )
     624_Unwind_Reason_Code __gcfa_personality_v0(
     625                int version,
     626                _Unwind_Action actions,
     627                unsigned long long exception_class,
     628                struct _Unwind_Exception * unwind_exception,
     629                struct _Unwind_Context * unwind_context) {
     630        return _URC_CONTINUE_UNWIND;
     631}
     632
     633__attribute__((noinline))
     634void __cfaehm_try_terminate(void (*try_block)(),
     635                void (*catch_block)(int index, exception_t * except),
     636                __attribute__((unused)) int (*match_block)(exception_t * except)) {
     637}
     638#else
     639        #error unsupported hardware architecture
    610640#endif // __x86_64 || __i386
Note: See TracChangeset for help on using the changeset viewer.