示例#1
0
int
__kmp_debug_assert(
    char const *  msg,
    char const *  file,
    int           line
) {

    if ( file == NULL ) {
        file = KMP_I18N_STR( UnknownFile );
    } else {
        // Remove directories from path, leave only file name. File name is enough, there is no need
        // in bothering developers and customers with full paths.
        char const * slash = strrchr( file, '/' );
        if ( slash != NULL ) {
            file = slash + 1;
        }; // if
    }; // if

#ifdef KMP_DEBUG
    __kmp_acquire_bootstrap_lock( & __kmp_stdio_lock );
    __kmp_debug_printf( "Assertion failure at %s(%d): %s.\n", file, line, msg );
    __kmp_release_bootstrap_lock( & __kmp_stdio_lock );
#ifdef USE_ASSERT_BREAK
#if KMP_OS_WINDOWS
    DebugBreak();
#endif
#endif // USE_ASSERT_BREAK
#ifdef USE_ASSERT_STALL
    /*    __kmp_infinite_loop(); */
    for(;;);
#endif // USE_ASSERT_STALL
#ifdef USE_ASSERT_SEG
    {
        int volatile * ZERO = (int*) 0;
        ++ (*ZERO);
    }
#endif // USE_ASSERT_SEG
#endif

    __kmp_msg(
        kmp_ms_fatal,
        KMP_MSG( AssertionFailure, file, line ),
        KMP_HNT( SubmitBugReport ),
        __kmp_msg_null
    );

    return 0;

} // __kmp_debug_assert
示例#2
0
static void
dump_cons_stack( int gtid, struct cons_header * p ) {
    int i;
    int tos = p->stack_top;
    kmp_str_buf_t buffer;
    __kmp_str_buf_init( & buffer );
    __kmp_str_buf_print( & buffer, "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n" );
    __kmp_str_buf_print( & buffer, "Begin construct stack with %d items for thread %d\n", tos, gtid );
    __kmp_str_buf_print( & buffer, "     stack_top=%d { P=%d, W=%d, S=%d }\n", tos, p->p_top, p->w_top, p->s_top );
    for ( i = tos; i > 0; i-- ) {
        struct cons_data * c = & ( p->stack_data[ i ] );
        __kmp_str_buf_print( & buffer, "        stack_data[%2d] = { %s (%s) %d %p }\n", i, cons_text_c[ c->type ], get_src( c->ident ), c->prev, c->name );
    }; // for i
    __kmp_str_buf_print( & buffer, "End construct stack for thread %d\n", gtid );
    __kmp_str_buf_print( & buffer, "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n" );
    __kmp_debug_printf( "%s", buffer.str );
    __kmp_str_buf_free( & buffer );
}