Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/exception.c

    re9145a3 rcbce272  
    1010// Created On       : Mon Jun 26 15:13:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Aug 17 15:45:00 2017
    13 // Update Count     : 7
     12// Last Modified On : Fri Aug  4 15:20:00 2017
     13// Update Count     : 6
    1414//
    1515
     
    2323#include <stdio.h>
    2424#include <unwind.h>
    25 #include <libhdr/libdebug.h>
    2625
    2726// FIX ME: temporary hack to keep ARM build working
     
    8079void __cfaehm__throw_resume(exception * except) {
    8180
    82         LIB_DEBUG_PRINT_SAFE("Throwing resumption exception\n");
     81        // DEBUG
     82        printf("Throwing resumption exception\n");
    8383
    8484        struct __cfaehm__try_resume_node * original_head = shared_stack.current_resume;
     
    9494        }
    9595
    96         LIB_DEBUG_PRINT_SAFE("Unhandled exception\n");
     96        printf("Unhandled exception\n");
    9797        shared_stack.current_resume = original_head;
    9898
     
    106106
    107107void __cfaehm__try_resume_setup(struct __cfaehm__try_resume_node * node,
    108                         _Bool (*handler)(exception * except)) {
     108                        int (*handler)(exception * except)) {
    109109        node->next = shared_stack.top_resume;
    110110        node->handler = handler;
     
    154154        struct exception_context_t * context = this_exception_context();
    155155
    156         LIB_DEBUG_PRINT_SAFE("Deleting Exception\n");
     156        // DEBUG
     157        printf( "Deleting Exception\n");
    157158
    158159        // Remove the exception from the list.
     
    234235
    235236void __cfaehm__throw_terminate( exception * val ) {
    236         LIB_DEBUG_PRINT_SAFE("Throwing termination exception\n");
     237        // DEBUG
     238        printf("Throwing termination exception\n");
    237239
    238240        __cfaehm__allocate_exception( val );
     
    241243
    242244void __cfaehm__rethrow_terminate(void) {
    243         LIB_DEBUG_PRINT_SAFE("Rethrowing termination exception\n");
     245        // DEBUG
     246        printf("Rethrowing termination exception\n");
    244247
    245248        __cfaehm__begin_unwind();
     
    254257{
    255258
    256         //LIB_DEBUG_PRINT_SAFE("CFA: 0x%lx\n", _Unwind_GetCFA(context));
    257         LIB_DEBUG_PRINT_SAFE("Personality function (%d, %x, %llu, %p, %p):", version, actions, exceptionClass, unwind_exception, context);
     259        // DEBUG
     260        //printf("CFA: 0x%lx\n", _Unwind_GetCFA(context));
     261        printf("Personality function (%d, %x, %llu, %p, %p):", version, actions, exceptionClass, unwind_exception, context);
    258262
    259263        // If we've reached the end of the stack then there is nothing much we can do...
    260264        if( actions & _UA_END_OF_STACK ) return _URC_END_OF_STACK;
    261265
     266        // DEBUG
    262267        if (actions & _UA_SEARCH_PHASE) {
    263                 LIB_DEBUG_PRINT_SAFE(" lookup phase");
    264         }
     268                printf(" lookup phase");
     269        }
     270        // DEBUG
    265271        else if (actions & _UA_CLEANUP_PHASE) {
    266                 LIB_DEBUG_PRINT_SAFE(" cleanup phase");
     272                printf(" cleanup phase");
    267273        }
    268274        // Just in case, probably can't actually happen
     
    300306                // Have we reach the correct frame info yet?
    301307                if( lsd_info.Start + callsite_start + callsite_len < instruction_ptr ) {
    302 #ifdef __CFA_DEBUG_PRINT__
     308                        //DEBUG BEGIN
    303309                        void * ls = (void*)lsd_info.Start;
    304310                        void * cs = (void*)callsite_start;
     
    307313                        void * ep = (void*)lsd_info.Start + callsite_start + callsite_len;
    308314                        void * ip = (void*)instruction_ptr;
    309                         LIB_DEBUG_PRINT_SAFE("\nfound %p - %p (%p, %p, %p), looking for %p\n", bp, ep, ls, cs, cl, ip);
    310 #endif // __CFA_DEBUG_PRINT__
     315                        printf("\nfound %p - %p (%p, %p, %p), looking for %p\n", bp, ep, ls, cs, cl, ip);
     316                        //DEBUG END
    311317                        continue;
    312318                }
     
    356362
    357363                                        // Based on the return value, check if we matched the exception
    358                                         if( ret == _URC_HANDLER_FOUND) {
    359                                                 LIB_DEBUG_PRINT_SAFE(" handler found\n");
    360                                         } else {
    361                                                 LIB_DEBUG_PRINT_SAFE(" no handler\n");
    362                                         }
     364                                        if( ret == _URC_HANDLER_FOUND) printf(" handler found\n");
     365                                        else printf(" no handler\n");
    363366                                        return ret;
    364367                                }
    365368
    366369                                // This is only a cleanup handler, ignore it
    367                                 LIB_DEBUG_PRINT_SAFE(" no action");
     370                                printf(" no action");
    368371                        }
    369372                        else if (actions & _UA_CLEANUP_PHASE) {
     
    385388                                _Unwind_SetIP( context, ((lsd_info.LPStart) + (callsite_landing_pad)) );
    386389
    387                                 LIB_DEBUG_PRINT_SAFE(" action\n");
     390                                // DEBUG
     391                                printf(" action\n");
    388392
    389393                                // Return have some action to run
     
    393397
    394398                // Nothing to do, move along
    395                 LIB_DEBUG_PRINT_SAFE(" no landing pad");
     399                printf(" no landing pad");
    396400        }
    397401        // No handling found
    398         LIB_DEBUG_PRINT_SAFE(" table end reached\n");
    399 
     402        printf(" table end reached\n");
     403
     404        // DEBUG
    400405        UNWIND:
    401         LIB_DEBUG_PRINT_SAFE(" unwind\n");
     406        printf(" unwind\n");
    402407
    403408        // Keep unwinding the stack
Note: See TracChangeset for help on using the changeset viewer.