michael@0: // michael@0: // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: // compiler_debug.h: Debugging utilities. michael@0: michael@0: #ifndef COMPILER_DEBUG_H_ michael@0: #define COMPILER_DEBUG_H_ michael@0: michael@0: #include michael@0: michael@0: #ifdef _DEBUG michael@0: #define TRACE_ENABLED // define to enable debug message tracing michael@0: #endif // _DEBUG michael@0: michael@0: // Outputs text to the debug log michael@0: #ifdef TRACE_ENABLED michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif // __cplusplus michael@0: void Trace(const char* format, ...); michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif // __cplusplus michael@0: michael@0: #else // TRACE_ENABLED michael@0: michael@0: #define Trace(...) ((void)0) michael@0: michael@0: #endif // TRACE_ENABLED michael@0: michael@0: // A macro asserting a condition and outputting failures to the debug log michael@0: #define ASSERT(expression) do { \ michael@0: if(!(expression)) \ michael@0: Trace("Assert failed: %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \ michael@0: assert(expression); \ michael@0: } while(0) michael@0: michael@0: #define UNIMPLEMENTED() do { \ michael@0: Trace("Unimplemented invoked: %s(%d)\n", __FUNCTION__, __LINE__); \ michael@0: assert(false); \ michael@0: } while(0) michael@0: michael@0: #define UNREACHABLE() do { \ michael@0: Trace("Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \ michael@0: assert(false); \ michael@0: } while(0) michael@0: michael@0: #endif // COMPILER_DEBUG_H_ michael@0: