diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-07-11 23:29:50 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-07-11 23:31:02 +0200 |
commit | 70dd5e7c66b1fe3f82e5b4db2406050baba15f05 (patch) | |
tree | 3f012200ef3c934f33db1a4ef2b790fae3141860 /gfx/angle/src/common/debug.h | |
parent | 3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff) | |
parent | 8481fa25d246f1968d0a254ee3c6cdd82c60781a (diff) | |
download | UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.gz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.lz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.xz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.zip |
Merge branch 'ANGLE-rollback'
This resolves #624
Note: Cherry-picked some fixes on top of the ANGLE version that we want to keep.
Diffstat (limited to 'gfx/angle/src/common/debug.h')
-rwxr-xr-x | gfx/angle/src/common/debug.h | 90 |
1 files changed, 40 insertions, 50 deletions
diff --git a/gfx/angle/src/common/debug.h b/gfx/angle/src/common/debug.h index 9356090ae..ccc80e802 100755 --- a/gfx/angle/src/common/debug.h +++ b/gfx/angle/src/common/debug.h @@ -57,20 +57,7 @@ void InitializeDebugAnnotations(DebugAnnotator *debugAnnotator); void UninitializeDebugAnnotations(); bool DebugAnnotationsActive(); -// This class is used to explicitly ignore values in the conditional logging macros. This avoids -// compiler warnings like "value computed is not used" and "statement has no effect". -class LogMessageVoidify -{ - public: - LogMessageVoidify() {} - // This has to be an operator with a precedence lower than << but higher than ?: - void operator&(std::ostream &) {} -}; - -// This can be any ostream, it is unused, but needs to be a valid reference. -std::ostream &DummyStream(); - -} // namespace gl +} #if defined(ANGLE_ENABLE_DEBUG_TRACE) || defined(ANGLE_ENABLE_DEBUG_ANNOTATIONS) #define ANGLE_TRACE_ENABLED @@ -117,58 +104,61 @@ std::ostream &DummyStream(); #undef ANGLE_TRACE_ENABLED #endif -#if defined(COMPILER_GCC) || defined(__clang__) -#define ANGLE_CRASH() __builtin_trap() -#else -#define ANGLE_CRASH() ((void)(*(volatile char *)0 = 0)) -#endif - #if !defined(NDEBUG) #define ANGLE_ASSERT_IMPL(expression) assert(expression) #else // TODO(jmadill): Detect if debugger is attached and break. -#define ANGLE_ASSERT_IMPL(expression) ANGLE_CRASH() +#define ANGLE_ASSERT_IMPL(expression) abort() #endif // !defined(NDEBUG) -// Helper macro which avoids evaluating the arguments to a stream if the condition doesn't hold. -// Condition is evaluated once and only once. -#define ANGLE_LAZY_STREAM(stream, condition) \ - !(condition) ? static_cast<void>(0) : ::gl::LogMessageVoidify() & (stream) - -#if defined(NDEBUG) && !defined(ANGLE_ENABLE_ASSERTS) -#define ANGLE_ASSERTS_ON 0 -#else -#define ANGLE_ASSERTS_ON 1 -#endif - // A macro asserting a condition and outputting failures to the debug log -#if ANGLE_ASSERTS_ON -#define ASSERT(expression) \ - (expression ? static_cast<void>(0) \ - : (ERR("\t! Assert failed in %s(%d): %s\n", __FUNCTION__, __LINE__, #expression), \ - ANGLE_ASSERT_IMPL(expression))) +#if defined(ANGLE_ENABLE_ASSERTS) +#define ASSERT(expression) \ + { \ + if (!(expression)) \ + { \ + ERR("\t! Assert failed in %s(%d): %s\n", __FUNCTION__, __LINE__, #expression); \ + ANGLE_ASSERT_IMPL(expression); \ + } \ + } \ + ANGLE_EMPTY_STATEMENT +#define UNUSED_ASSERTION_VARIABLE(variable) #else -#define ASSERT(condition) \ - ANGLE_LAZY_STREAM(::gl::DummyStream(), ANGLE_ASSERTS_ON ? !(condition) : false) \ - << "Check failed: " #condition ". " -#endif // ANGLE_ASSERTS_ON +#define ASSERT(expression) (void(0)) +#define UNUSED_ASSERTION_VARIABLE(variable) ((void)variable) +#endif #define UNUSED_VARIABLE(variable) ((void)variable) // A macro to indicate unimplemented functionality -#ifndef NOASSERT_UNIMPLEMENTED + +#if defined (ANGLE_TEST_CONFIG) #define NOASSERT_UNIMPLEMENTED 1 #endif -#define UNIMPLEMENTED() \ - { \ - ERR("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \ - ASSERT(NOASSERT_UNIMPLEMENTED); \ - } \ - ANGLE_EMPTY_STATEMENT +// Define NOASSERT_UNIMPLEMENTED to non zero to skip the assert fail in the unimplemented checks +// This will allow us to test with some automated test suites (eg dEQP) without crashing +#ifndef NOASSERT_UNIMPLEMENTED +#define NOASSERT_UNIMPLEMENTED 0 +#endif + +#if !defined(NDEBUG) +#define UNIMPLEMENTED() { \ + FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \ + assert(NOASSERT_UNIMPLEMENTED); \ + } ANGLE_EMPTY_STATEMENT +#else + #define UNIMPLEMENTED() FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__) +#endif // A macro for code which is not expected to be reached under valid assumptions -#define UNREACHABLE() \ - (ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__), ASSERT(false)) +#if !defined(NDEBUG) +#define UNREACHABLE() { \ + ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \ + assert(false); \ + } ANGLE_EMPTY_STATEMENT +#else + #define UNREACHABLE() ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__) +#endif #endif // COMMON_DEBUG_H_ |