blob: 84a12ad2f8fca0bf3a2cdabac50e365f715c8e54 [file] [log] [blame]
alokp@chromium.org91b72322010-06-02 15:50:56 +00001//
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
Geoff Lang0a73dd82014-11-19 16:18:08 -05009#ifndef COMPILER_TRANSLATOR_COMPILERDEBUG_H_
10#define COMPILER_TRANSLATOR_COMPILERDEBUG_H_
alokp@chromium.org91b72322010-06-02 15:50:56 +000011
12#include <assert.h>
13
14#ifdef _DEBUG
15#define TRACE_ENABLED // define to enable debug message tracing
16#endif // _DEBUG
17
18// Outputs text to the debug log
19#ifdef TRACE_ENABLED
20
21#ifdef __cplusplus
22extern "C" {
23#endif // __cplusplus
24void Trace(const char* format, ...);
25#ifdef __cplusplus
26}
27#endif // __cplusplus
28
29#else // TRACE_ENABLED
30
alokp@chromium.org9c212ca2010-06-02 22:53:00 +000031#define Trace(...) ((void)0)
alokp@chromium.org91b72322010-06-02 15:50:56 +000032
33#endif // TRACE_ENABLED
34
35// A macro asserting a condition and outputting failures to the debug log
36#define ASSERT(expression) do { \
37 if(!(expression)) \
38 Trace("Assert failed: %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
39 assert(expression); \
40} while(0)
41
42#define UNIMPLEMENTED() do { \
43 Trace("Unimplemented invoked: %s(%d)\n", __FUNCTION__, __LINE__); \
44 assert(false); \
45} while(0)
46
47#define UNREACHABLE() do { \
48 Trace("Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \
49 assert(false); \
50} while(0)
51
Geoff Lang0a73dd82014-11-19 16:18:08 -050052#endif // COMPILER_TRANSLATOR_COMPILERDEBUG_H_
alokp@chromium.org91b72322010-06-02 15:50:56 +000053