Beispiel #1
0
void _error_context_pop( void )
{
	error_context_t* context = get_thread_error_context();
	if( context )
	{
		FOUNDATION_ASSERT_MSG( context->depth, "Error context stack underflow" );
		--context->depth;
	}
}
Beispiel #2
0
void _error_context_thread_deallocate( void )
{
	error_context_t* context = get_thread_error_context();
	if( context )
	{
		FOUNDATION_ASSERT_MSG( !context->depth, "Error context thread exit with non-zero context stack" );
		memory_deallocate( context );
		set_thread_error_context( 0 );
	}
}
Beispiel #3
0
void _error_context_push( const char* name, const char* data )
{
	error_context_t* context = get_thread_error_context();
	if( !context )
	{
		context = memory_allocate_zero( sizeof( error_context_t ), 0, MEMORY_PERSISTENT );
		set_thread_error_context( context );
	}
	FOUNDATION_ASSERT_MSG( context->depth < BUILD_SIZE_ERROR_CONTEXT_DEPTH, "Error context stack overflow" );
	context->frame[ context->depth ].name = name;
	context->frame[ context->depth ].data = data;
	if( context->depth < BUILD_SIZE_ERROR_CONTEXT_DEPTH-1 )
		++context->depth;
}
Beispiel #4
0
void _error_context_buffer( char* buffer, unsigned int size )
{
	error_context_t* context = get_thread_error_context();
	if( context )
	{
		int i, written;
		error_frame_t* frame = context->frame;
		for( i = 0; size && ( i < context->depth ); ++i, ++frame )
		{
			written = snprintf( buffer, size, "When %s: %s\n", frame->name ? frame->name : "<something>", frame->data ? frame->data : "" );
			if( ( written > 0 ) && ( written <= (int)size ) )
			{
				buffer += written;
				size -= written;
			}
			else
				break;
		}
	}
}
Beispiel #5
0
error_context_t* _error_context( void )
{
	return get_thread_error_context();
}
Beispiel #6
0
void _error_context_clear( void )
{
	error_context_t* context = get_thread_error_context();
	if( context )
		context->depth = 0;
}