John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // debug.h: Debugging utilities. |
| 8 | |
| 9 | #ifndef COMPILER_DEBUG_H_ |
| 10 | #define COMPILER_DEBUG_H_ |
| 11 | |
Greg Hartman | d61ac5f | 2015-04-09 18:48:53 -0700 | [diff] [blame] | 12 | #ifdef __ANDROID__ |
| 13 | #include "../../Common/DebugAndroid.hpp" |
| 14 | |
| 15 | #define Trace(...) ((void)0) |
| 16 | #else |
| 17 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 18 | #include <assert.h> |
| 19 | |
| 20 | #ifdef _DEBUG |
| 21 | #define TRACE_ENABLED // define to enable debug message tracing |
| 22 | #endif // _DEBUG |
| 23 | |
| 24 | // Outputs text to the debug log |
| 25 | #ifdef TRACE_ENABLED |
| 26 | |
| 27 | #ifdef __cplusplus |
| 28 | extern "C" { |
| 29 | #endif // __cplusplus |
| 30 | void Trace(const char* format, ...); |
| 31 | #ifdef __cplusplus |
| 32 | } |
| 33 | #endif // __cplusplus |
| 34 | |
| 35 | #else // TRACE_ENABLED |
| 36 | |
| 37 | #define Trace(...) ((void)0) |
| 38 | |
| 39 | #endif // TRACE_ENABLED |
| 40 | |
| 41 | // A macro asserting a condition and outputting failures to the debug log |
Alexis Hetu | a818c45 | 2015-06-11 13:06:58 -0400 | [diff] [blame] | 42 | #undef ASSERT
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 43 | #define ASSERT(expression) do { \ |
| 44 | if(!(expression)) \ |
| 45 | Trace("Assert failed: %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \ |
| 46 | assert(expression); \ |
| 47 | } while(0) |
| 48 | |
Alexis Hetu | a818c45 | 2015-06-11 13:06:58 -0400 | [diff] [blame] | 49 | #undef UNIMPLEMENTED
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 50 | #define UNIMPLEMENTED() do { \ |
| 51 | Trace("Unimplemented invoked: %s(%d)\n", __FUNCTION__, __LINE__); \ |
| 52 | assert(false); \ |
| 53 | } while(0) |
| 54 | |
Alexis Hetu | a818c45 | 2015-06-11 13:06:58 -0400 | [diff] [blame] | 55 | #undef UNREACHABLE
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 56 | #define UNREACHABLE() do { \ |
| 57 | Trace("Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \ |
| 58 | assert(false); \ |
| 59 | } while(0) |
| 60 | |
Greg Hartman | d61ac5f | 2015-04-09 18:48:53 -0700 | [diff] [blame] | 61 | #endif // __ANDROID__ |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 62 | #endif // COMPILER_DEBUG_H_ |
| 63 | |