blob: 24cb6aa9a4962720824929e69d5a02ac22402c3a [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
Alexis Hetua818c452015-06-11 13:06:58 -040042#undef ASSERT
John Bauman66b8ab22014-05-06 15:57:45 -040043#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 Hetua818c452015-06-11 13:06:58 -040049#undef UNIMPLEMENTED
John Bauman66b8ab22014-05-06 15:57:45 -040050#define UNIMPLEMENTED() do { \
51 Trace("Unimplemented invoked: %s(%d)\n", __FUNCTION__, __LINE__); \
52 assert(false); \
53} while(0)
54
Alexis Hetua818c452015-06-11 13:06:58 -040055#undef UNREACHABLE
John Bauman66b8ab22014-05-06 15:57:45 -040056#define UNREACHABLE() do { \
57 Trace("Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \
58 assert(false); \
59} while(0)
60
Greg Hartmand61ac5f2015-04-09 18:48:53 -070061#endif // __ANDROID__
John Bauman66b8ab22014-05-06 15:57:45 -040062#endif // COMPILER_DEBUG_H_
63