gfx/angle/src/common/debug.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 //
michael@0 2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
michael@0 3 // Use of this source code is governed by a BSD-style license that can be
michael@0 4 // found in the LICENSE file.
michael@0 5 //
michael@0 6
michael@0 7 // debug.h: Debugging utilities.
michael@0 8
michael@0 9 #ifndef COMMON_DEBUG_H_
michael@0 10 #define COMMON_DEBUG_H_
michael@0 11
michael@0 12 #include <stdio.h>
michael@0 13 #include <assert.h>
michael@0 14
michael@0 15 #include "common/angleutils.h"
michael@0 16
michael@0 17 #if !defined(TRACE_OUTPUT_FILE)
michael@0 18 #define TRACE_OUTPUT_FILE "debug.txt"
michael@0 19 #endif
michael@0 20
michael@0 21 namespace gl
michael@0 22 {
michael@0 23 // Outputs text to the debugging log
michael@0 24 void trace(bool traceFileDebugOnly, const char *format, ...);
michael@0 25
michael@0 26 // Returns whether D3DPERF is active.
michael@0 27 bool perfActive();
michael@0 28
michael@0 29 // Pairs a D3D begin event with an end event.
michael@0 30 class ScopedPerfEventHelper
michael@0 31 {
michael@0 32 public:
michael@0 33 ScopedPerfEventHelper(const char* format, ...);
michael@0 34 ~ScopedPerfEventHelper();
michael@0 35
michael@0 36 private:
michael@0 37 DISALLOW_COPY_AND_ASSIGN(ScopedPerfEventHelper);
michael@0 38 };
michael@0 39 }
michael@0 40
michael@0 41 // A macro to output a trace of a function call and its arguments to the debugging log
michael@0 42 #if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
michael@0 43 #define TRACE(message, ...) (void(0))
michael@0 44 #else
michael@0 45 #define TRACE(message, ...) gl::trace(true, "trace: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
michael@0 46 #endif
michael@0 47
michael@0 48 // A macro to output a function call and its arguments to the debugging log, to denote an item in need of fixing.
michael@0 49 #if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
michael@0 50 #define FIXME(message, ...) (void(0))
michael@0 51 #else
michael@0 52 #define FIXME(message, ...) gl::trace(false, "fixme: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
michael@0 53 #endif
michael@0 54
michael@0 55 // A macro to output a function call and its arguments to the debugging log, in case of error.
michael@0 56 #if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
michael@0 57 #define ERR(message, ...) (void(0))
michael@0 58 #else
michael@0 59 #define ERR(message, ...) gl::trace(false, "err: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
michael@0 60 #endif
michael@0 61
michael@0 62 // A macro to log a performance event around a scope.
michael@0 63 #if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
michael@0 64 #define EVENT(message, ...) (void(0))
michael@0 65 #elif defined(_MSC_VER)
michael@0 66 #define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper ## __LINE__(__FUNCTION__ message "\n", __VA_ARGS__);
michael@0 67 #else
michael@0 68 #define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper(message "\n", ##__VA_ARGS__);
michael@0 69 #endif
michael@0 70
michael@0 71 // A macro asserting a condition and outputting failures to the debug log
michael@0 72 #if !defined(NDEBUG)
michael@0 73 #define ASSERT(expression) do { \
michael@0 74 if(!(expression)) \
michael@0 75 ERR("\t! Assert failed in %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
michael@0 76 assert(expression); \
michael@0 77 } while(0)
michael@0 78 #else
michael@0 79 #define ASSERT(expression) (void(0))
michael@0 80 #endif
michael@0 81
michael@0 82 // A macro to indicate unimplemented functionality
michael@0 83 #if !defined(NDEBUG)
michael@0 84 #define UNIMPLEMENTED() do { \
michael@0 85 FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \
michael@0 86 assert(false); \
michael@0 87 } while(0)
michael@0 88 #else
michael@0 89 #define UNIMPLEMENTED() FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__)
michael@0 90 #endif
michael@0 91
michael@0 92 // A macro for code which is not expected to be reached under valid assumptions
michael@0 93 #if !defined(NDEBUG)
michael@0 94 #define UNREACHABLE() do { \
michael@0 95 ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \
michael@0 96 assert(false); \
michael@0 97 } while(0)
michael@0 98 #else
michael@0 99 #define UNREACHABLE() ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__)
michael@0 100 #endif
michael@0 101
michael@0 102 // A macro that determines whether an object has a given runtime type. MSVC uses _CPPRTTI.
michael@0 103 // GCC uses __GXX_RTTI, but the macro was introduced in version 4.3, so we assume that all older
michael@0 104 // versions support RTTI.
michael@0 105 #if !defined(NDEBUG) && (!defined(_MSC_VER) || defined(_CPPRTTI)) && (!defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) || defined(__GXX_RTTI))
michael@0 106 #define HAS_DYNAMIC_TYPE(type, obj) (dynamic_cast<type >(obj) != NULL)
michael@0 107 #else
michael@0 108 #define HAS_DYNAMIC_TYPE(type, obj) true
michael@0 109 #endif
michael@0 110
michael@0 111 // A macro functioning as a compile-time assert to validate constant conditions
michael@0 112 #define META_ASSERT(condition) typedef int COMPILE_TIME_ASSERT_##__LINE__[static_cast<bool>(condition)?1:-1]
michael@0 113
michael@0 114 #endif // COMMON_DEBUG_H_

mercurial