blob: a3af34fa9eca88ae0330f23b9313d3f483a41dd2 [file] [log] [blame]
John Bauman66b8ab22014-05-06 15:57:45 -04001//
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 Hartmand61ac5f2015-04-09 18:48:53 -070012#ifdef __ANDROID__
13#include "../../Common/DebugAndroid.hpp"
14
15#define Trace(...) ((void)0)
16#else
17
John Bauman66b8ab22014-05-06 15:57:45 -040018#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
28extern "C" {
29#endif // __cplusplus
30void 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
42#define ASSERT(expression) do { \
43 if(!(expression)) \
44 Trace("Assert failed: %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
45 assert(expression); \
46} while(0)
47
48#define UNIMPLEMENTED() do { \
49 Trace("Unimplemented invoked: %s(%d)\n", __FUNCTION__, __LINE__); \
50 assert(false); \
51} while(0)
52
53#define UNREACHABLE() do { \
54 Trace("Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \
55 assert(false); \
56} while(0)
57
Greg Hartmand61ac5f2015-04-09 18:48:53 -070058#endif // __ANDROID__
John Bauman66b8ab22014-05-06 15:57:45 -040059#endif // COMPILER_DEBUG_H_
60