Changeset 307a732 for src/libcfa


Ignore:
Timestamp:
Jul 4, 2017, 11:52:33 AM (8 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:
44f44617, 67fa9f9, ad0be81
Parents:
86f384b
Message:

The exception handling code compilers and translates, but the translation crashes.

Location:
src/libcfa
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/Makefile.am

    r86f384b r307a732  
    5050
    5151libobjs = ${headers:=.o}
    52 libsrc = libcfa-prelude.c interpose.c libhdr/libdebug.c ${headers:=.c}
     52libsrc = libcfa-prelude.c interpose.c libhdr/libdebug.c ${headers:=.c} exception.c
    5353
    5454# not all platforms support concurrency, add option do disable it
  • src/libcfa/Makefile.in

    r86f384b r307a732  
    102102        containers/pair.c containers/result.c containers/vector.c \
    103103        concurrency/coroutine.c concurrency/thread.c \
    104         concurrency/kernel.c concurrency/monitor.c \
     104        concurrency/kernel.c concurrency/monitor.c exception.c \
    105105        concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \
    106106        concurrency/invoke.c concurrency/preemption.c
     
    126126        libcfa_d_a-interpose.$(OBJEXT) \
    127127        libhdr/libcfa_d_a-libdebug.$(OBJEXT) $(am__objects_2) \
    128         $(am__objects_3)
     128        libcfa_d_a-exception.$(OBJEXT) $(am__objects_3)
    129129am_libcfa_d_a_OBJECTS = $(am__objects_4)
    130130libcfa_d_a_OBJECTS = $(am_libcfa_d_a_OBJECTS)
     
    136136        containers/pair.c containers/result.c containers/vector.c \
    137137        concurrency/coroutine.c concurrency/thread.c \
    138         concurrency/kernel.c concurrency/monitor.c \
     138        concurrency/kernel.c concurrency/monitor.c exception.c \
    139139        concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \
    140140        concurrency/invoke.c concurrency/preemption.c
     
    158158        libcfa_a-interpose.$(OBJEXT) \
    159159        libhdr/libcfa_a-libdebug.$(OBJEXT) $(am__objects_6) \
    160         $(am__objects_7)
     160        libcfa_a-exception.$(OBJEXT) $(am__objects_7)
    161161am_libcfa_a_OBJECTS = $(am__objects_8)
    162162libcfa_a_OBJECTS = $(am_libcfa_a_OBJECTS)
     
    328328libobjs = ${headers:=.o}
    329329libsrc = libcfa-prelude.c interpose.c libhdr/libdebug.c ${headers:=.c} \
    330         $(am__append_4)
     330        exception.c $(am__append_4)
    331331libcfa_a_SOURCES = ${libsrc}
    332332libcfa_a_CFLAGS = -nodebug -O2
     
    514514
    515515@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-assert.Po@am__quote@
     516@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-exception.Po@am__quote@
    516517@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-fstream.Po@am__quote@
    517518@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-interpose.Po@am__quote@
     
    524525@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-stdlib.Po@am__quote@
    525526@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-assert.Po@am__quote@
     527@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-exception.Po@am__quote@
    526528@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-fstream.Po@am__quote@
    527529@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-interpose.Po@am__quote@
     
    850852@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-monitor.obj `if test -f 'concurrency/monitor.c'; then $(CYGPATH_W) 'concurrency/monitor.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/monitor.c'; fi`
    851853
     854libcfa_d_a-exception.obj: exception.c
     855@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-exception.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-exception.Tpo -c -o libcfa_d_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi`
     856@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-exception.Tpo $(DEPDIR)/libcfa_d_a-exception.Po
     857@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='exception.c' object='libcfa_d_a-exception.obj' libtool=no @AMDEPBACKSLASH@
     858@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     859@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi`
     860
    852861concurrency/libcfa_d_a-alarm.o: concurrency/alarm.c
    853862@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-alarm.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-alarm.Tpo -c -o concurrency/libcfa_d_a-alarm.o `test -f 'concurrency/alarm.c' || echo '$(srcdir)/'`concurrency/alarm.c
     
    11431152@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    11441153@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-monitor.obj `if test -f 'concurrency/monitor.c'; then $(CYGPATH_W) 'concurrency/monitor.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/monitor.c'; fi`
     1154
     1155libcfa_a-exception.obj: exception.c
     1156@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-exception.obj -MD -MP -MF $(DEPDIR)/libcfa_a-exception.Tpo -c -o libcfa_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi`
     1157@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-exception.Tpo $(DEPDIR)/libcfa_a-exception.Po
     1158@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='exception.c' object='libcfa_a-exception.obj' libtool=no @AMDEPBACKSLASH@
     1159@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1160@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi`
    11451161
    11461162concurrency/libcfa_a-alarm.o: concurrency/alarm.c
  • src/libcfa/exception.c

    r86f384b r307a732  
    4444// RESUMPTION ================================================================
    4545
    46 void __cfaehm__throw_resume(exception except) {
    47 
    48         // DEBUG
    49         printf("Throwing resumption exception %d\n", except);
    50 
    51         struct __try_resume_node * original_head = shared_stack.current_resume;
    52         struct __try_resume_node * current =
     46void __cfaehm__throw_resumption(exception * except) {
     47
     48        // DEBUG
     49        printf("Throwing resumption exception %d\n", *except);
     50
     51        struct __cfaehm__try_resume_node * original_head = shared_stack.current_resume;
     52        struct __cfaehm__try_resume_node * current =
    5353                (original_head) ? original_head->next : shared_stack.top_resume;
    5454
    5555        for ( ; current ; current = current->next) {
    5656                shared_stack.current_resume = current;
    57                 if (current->try_to_handle(except)) {
     57                if (current->handler(except)) {
    5858                        shared_stack.current_resume = original_head;
    5959                        return;
     
    6161        }
    6262
    63         printf("Unhandled exception %d\n", except);
     63        printf("Unhandled exception %d\n", *except);
    6464        shared_stack.current_resume = original_head;
    6565
    6666        // Fall back to termination:
    67         __cfaehm__throw_terminate(except);
     67        __cfaehm__throw_termination(except);
    6868        // TODO: Default handler for resumption.
    6969}
     
    7373 * after the node is built but before it is made the top node.
    7474 */
    75 void __try_resume_setup(struct __try_resume_node * node,
    76                         bool (*handler)(exception except)) {
     75void __cfaehm__try_resume_setup(struct __cfaehm__try_resume_node * node,
     76                        int (*handler)(exception * except)) {
    7777        node->next = shared_stack.top_resume;
    78         node->try_to_handle = handler;
     78        node->handler = handler;
    7979        shared_stack.top_resume = node;
    8080}
    8181
    82 void __try_resume_cleanup(struct __try_resume_node * node) {
     82void __cfaehm__try_resume_cleanup(struct __cfaehm__try_resume_node * node) {
    8383        shared_stack.top_resume = node->next;
    8484}
     
    111111}
    112112
    113 void __cfaehm__throw_terminate( int val ) {
     113void __cfaehm__throw_termination( exception * val ) {
    114114        // Store the current exception
    115         shared_stack.current_exception = val;
    116 
    117         // DEBUG
    118         printf("Throwing termination exception %d\n", val);
     115        shared_stack.current_exception = *val;
     116
     117        // DEBUG
     118        printf("Throwing termination exception %d\n", *val);
    119119
    120120        // Call stdlibc to raise the exception
     
    147147
    148148// Nesting this the other way would probably be faster.
    149 void __cfaehm__rethrow_terminate(void) {
     149void __cfaehm__rethrow_termination(void) {
    150150        // DEBUG
    151151        printf("Rethrowing termination exception\n");
    152152
    153         __cfaehm__throw_terminate(shared_stack.current_exception);
     153        __cfaehm__throw_termination(&shared_stack.current_exception);
    154154}
    155155
     
    322322// for details
    323323__attribute__((noinline))
    324 void __try_terminate(void (*try_block)(),
    325                 void (*catch_block)(int index, exception except),
    326                 __attribute__((unused)) int (*match_block)(exception except)) {
     324void __cfaehm__try_terminate(void (*try_block)(),
     325                void (*catch_block)(int index, exception * except),
     326                __attribute__((unused)) int (*match_block)(exception * except)) {
    327327        //! volatile int xy = 0;
    328328        //! printf("%p %p %p %p\n", &try_block, &catch_block, &match_block, &xy);
     
    364364        // Exception handler
    365365        catch_block(shared_stack.current_handler_index,
    366                     shared_stack.current_exception);
     366                    &shared_stack.current_exception);
    367367}
    368368
     
    384384        // Body uses language specific data and therefore could be modified arbitrarily
    385385        ".LLSDACSBCFA2:\n"                                              // BODY start
    386         "       .uleb128 .TRYSTART-__try_terminate\n"           // Handled area start  (relative to start of function)
     386        "       .uleb128 .TRYSTART-__cfaehm__try_terminate\n"           // Handled area start  (relative to start of function)
    387387        "       .uleb128 .TRYEND-.TRYSTART\n"                           // Handled area length
    388         "       .uleb128 .CATCH-__try_terminate\n"                              // Hanlder landing pad adress  (relative to start of function)
     388        "       .uleb128 .CATCH-__cfaehm__try_terminate\n"                              // Hanlder landing pad adress  (relative to start of function)
    389389        "       .uleb128 1\n"                                           // Action code, gcc seems to use always 0
    390390        ".LLSDACSECFA2:\n"                                              // BODY end
    391391        "       .text\n"                                                        // TABLE footer
    392         "       .size   __try_terminate, .-__try_terminate\n"
     392        "       .size   __cfaehm__try_terminate, .-__cfaehm__try_terminate\n"
    393393        "       .ident  \"GCC: (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901\"\n"
    394394//      "       .section        .note.GNU-stack,\"x\",@progbits\n"
  • src/libcfa/exception.h

    r86f384b r307a732  
    3838// Data structure creates a list of resume handlers.
    3939struct __cfaehm__try_resume_node {
    40     __cfaehm__try_resume_node * next;
     40    struct __cfaehm__try_resume_node * next;
    4141    int (*handler)(exception * except);
    4242};
    4343
    4444void __cfaehm__try_resume_setup(
    45     __cfaehm__try_resume_node * node,
     45    struct __cfaehm__try_resume_node * node,
    4646    int (*handler)(exception * except));
    4747void __cfaehm__try_resume_cleanup(
    48     __cfaehm__try_resume_node * node);
     48    struct __cfaehm__try_resume_node * node);
    4949
    5050// Check for a standard way to call fake deconstructors.
Note: See TracChangeset for help on using the changeset viewer.