Ignore:
Timestamp:
Dec 3, 2020, 3:33:18 PM (3 years ago)
Author:
Colby Alexander Parsons <caparsons@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
9082e0f1, cad1df1
Parents:
a78c3ff (diff), 0f88a225 (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/interpose.cfa

    ra78c3ff raeb31b1  
    220220}
    221221
     222static volatile int __abort_stage = 0;
     223
    222224// Cannot forward va_list.
    223225void __abort( bool signalAbort, const char fmt[], va_list args ) {
    224         void * kernel_data = kernel_abort();                            // must be done here to lock down kernel
    225         int len;
    226 
    227         signal( SIGABRT, SIG_DFL );                                                     // prevent final "real" abort from recursing to handler
    228 
    229         len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
    230         __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    231 
    232         assert( fmt );
    233         len = vsnprintf( abort_text, abort_text_size, fmt, args );
    234         __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    235 
    236         if ( fmt[strlen( fmt ) - 1] != '\n' ) {                         // add optional newline if missing at the end of the format text
    237                 __cfaabi_bits_write( STDERR_FILENO, "\n", 1 );
    238         } // if
    239         kernel_abort_msg( kernel_data, abort_text, abort_text_size );
    240 
    241         __cfaabi_backtrace( signalAbort ? 4 : 2 );
    242 
    243         __cabi_libc.abort();                                                            // print stack trace in handler
     226        int stage = __atomic_add_fetch( &__abort_stage, 1, __ATOMIC_SEQ_CST );
     227
     228        // First stage: stop the cforall kernel and print
     229        if(stage == 1) {
     230                // increment stage
     231                stage = __atomic_add_fetch( &__abort_stage, 1, __ATOMIC_SEQ_CST );
     232
     233                // must be done here to lock down kernel
     234                void * kernel_data = kernel_abort();
     235                int len;
     236
     237                signal( SIGABRT, SIG_DFL );                                                     // prevent final "real" abort from recursing to handler
     238
     239                len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
     240                __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     241
     242                assert( fmt );
     243                len = vsnprintf( abort_text, abort_text_size, fmt, args );
     244                __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     245
     246                // add optional newline if missing at the end of the format text
     247                if ( fmt[strlen( fmt ) - 1] != '\n' ) {
     248                        __cfaabi_bits_write( STDERR_FILENO, "\n", 1 );
     249                } // if
     250                kernel_abort_msg( kernel_data, abort_text, abort_text_size );
     251        }
     252
     253        // Second stage: print the backtrace
     254        if(stage == 2) {
     255                // increment stage
     256                stage = __atomic_add_fetch( &__abort_stage, 1, __ATOMIC_SEQ_CST );
     257
     258                // print stack trace in handler
     259                __cfaabi_backtrace( signalAbort ? 4 : 2 );
     260        }
     261
     262        do {
     263                // Finally call abort
     264                __cabi_libc.abort();
     265
     266                // Loop so that we never return
     267        } while(true);
    244268}
    245269
Note: See TracChangeset for help on using the changeset viewer.