Changeset e9145a3 for src/libcfa


Ignore:
Timestamp:
Aug 17, 2017, 4:13:42 PM (7 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
8f6dfe7
Parents:
21f0aa8
Message:

Updated exception tests to exception structures. Should be re-orginized still.

Location:
src/libcfa
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/exception.c

    r21f0aa8 re9145a3  
    1010// Created On       : Mon Jun 26 15:13:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Aug  4 15:20:00 2017
    13 // Update Count     : 6
     12// Last Modified On : Thr Aug 17 15:45:00 2017
     13// Update Count     : 7
    1414//
    1515
     
    2323#include <stdio.h>
    2424#include <unwind.h>
     25#include <libhdr/libdebug.h>
    2526
    2627// FIX ME: temporary hack to keep ARM build working
     
    7980void __cfaehm__throw_resume(exception * except) {
    8081
    81         // DEBUG
    82         printf("Throwing resumption exception\n");
     82        LIB_DEBUG_PRINT_SAFE("Throwing resumption exception\n");
    8383
    8484        struct __cfaehm__try_resume_node * original_head = shared_stack.current_resume;
     
    9494        }
    9595
    96         printf("Unhandled exception\n");
     96        LIB_DEBUG_PRINT_SAFE("Unhandled exception\n");
    9797        shared_stack.current_resume = original_head;
    9898
     
    106106
    107107void __cfaehm__try_resume_setup(struct __cfaehm__try_resume_node * node,
    108                         int (*handler)(exception * except)) {
     108                        _Bool (*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         // DEBUG
    157         printf( "Deleting Exception\n");
     156        LIB_DEBUG_PRINT_SAFE("Deleting Exception\n");
    158157
    159158        // Remove the exception from the list.
     
    235234
    236235void __cfaehm__throw_terminate( exception * val ) {
    237         // DEBUG
    238         printf("Throwing termination exception\n");
     236        LIB_DEBUG_PRINT_SAFE("Throwing termination exception\n");
    239237
    240238        __cfaehm__allocate_exception( val );
     
    243241
    244242void __cfaehm__rethrow_terminate(void) {
    245         // DEBUG
    246         printf("Rethrowing termination exception\n");
     243        LIB_DEBUG_PRINT_SAFE("Rethrowing termination exception\n");
    247244
    248245        __cfaehm__begin_unwind();
     
    257254{
    258255
    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);
     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);
    262258
    263259        // If we've reached the end of the stack then there is nothing much we can do...
    264260        if( actions & _UA_END_OF_STACK ) return _URC_END_OF_STACK;
    265261
    266         // DEBUG
    267262        if (actions & _UA_SEARCH_PHASE) {
    268                 printf(" lookup phase");
    269         }
    270         // DEBUG
     263                LIB_DEBUG_PRINT_SAFE(" lookup phase");
     264        }
    271265        else if (actions & _UA_CLEANUP_PHASE) {
    272                 printf(" cleanup phase");
     266                LIB_DEBUG_PRINT_SAFE(" cleanup phase");
    273267        }
    274268        // Just in case, probably can't actually happen
     
    306300                // Have we reach the correct frame info yet?
    307301                if( lsd_info.Start + callsite_start + callsite_len < instruction_ptr ) {
    308                         //DEBUG BEGIN
     302#ifdef __CFA_DEBUG_PRINT__
    309303                        void * ls = (void*)lsd_info.Start;
    310304                        void * cs = (void*)callsite_start;
     
    313307                        void * ep = (void*)lsd_info.Start + callsite_start + callsite_len;
    314308                        void * ip = (void*)instruction_ptr;
    315                         printf("\nfound %p - %p (%p, %p, %p), looking for %p\n", bp, ep, ls, cs, cl, ip);
    316                         //DEBUG END
     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__
    317311                        continue;
    318312                }
     
    362356
    363357                                        // Based on the return value, check if we matched the exception
    364                                         if( ret == _URC_HANDLER_FOUND) printf(" handler found\n");
    365                                         else printf(" no handler\n");
     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                                        }
    366363                                        return ret;
    367364                                }
    368365
    369366                                // This is only a cleanup handler, ignore it
    370                                 printf(" no action");
     367                                LIB_DEBUG_PRINT_SAFE(" no action");
    371368                        }
    372369                        else if (actions & _UA_CLEANUP_PHASE) {
     
    388385                                _Unwind_SetIP( context, ((lsd_info.LPStart) + (callsite_landing_pad)) );
    389386
    390                                 // DEBUG
    391                                 printf(" action\n");
     387                                LIB_DEBUG_PRINT_SAFE(" action\n");
    392388
    393389                                // Return have some action to run
     
    397393
    398394                // Nothing to do, move along
    399                 printf(" no landing pad");
     395                LIB_DEBUG_PRINT_SAFE(" no landing pad");
    400396        }
    401397        // No handling found
    402         printf(" table end reached\n");
    403 
    404         // DEBUG
     398        LIB_DEBUG_PRINT_SAFE(" table end reached\n");
     399
    405400        UNWIND:
    406         printf(" unwind\n");
     401        LIB_DEBUG_PRINT_SAFE(" unwind\n");
    407402
    408403        // Keep unwinding the stack
  • src/libcfa/exception.h

    r21f0aa8 re9145a3  
    1010// Created On       : Mon Jun 26 15:11:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Aug  4 15:20:00 2017
    13 // Update Count     : 5
     12// Last Modified On : Thr Aug 17 15:44:00 2017
     13// Update Count     : 6
    1414//
    1515
     
    5555struct __cfaehm__try_resume_node {
    5656    struct __cfaehm__try_resume_node * next;
    57     int (*handler)(exception * except);
     57    _Bool (*handler)(exception * except);
    5858};
    5959
     
    6161void __cfaehm__try_resume_setup(
    6262    struct __cfaehm__try_resume_node * node,
    63     int (*handler)(exception * except));
     63    _Bool (*handler)(exception * except));
    6464void __cfaehm__try_resume_cleanup(
    6565    struct __cfaehm__try_resume_node * node);
Note: See TracChangeset for help on using the changeset viewer.