Remove separate compilerdebug.h in favor of debug.h
This unifies the behavior across the compiler and rest of ANGLE - for
example, one can use #define ANGLE_TEST_CONFIG to disable UNIMPLEMENTED
asserts in both the compiler and the rest of ANGLE. Compiler traces from
asserts also go to the same TRACE_OUTPUT_FILE as other traces instead of
being directed through ParseContext.
The compiler build already includes the common sources, so no changes to
build config are needed.
The original version of this change was reverted due to release mode
build issues. This version adds UNUSED_ASSERTION_VARIABLE where needed.
TEST=angle_unittests, angle_end2end_tests,
dEQP-GLES3.functional.shaders.*
BUG=angleproject:983
Change-Id: I36929020a04251b8bc834fbb3c069e10128c3082
Reviewed-on: https://chromium-review.googlesource.com/267411
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/BaseTypes.h b/src/compiler/translator/BaseTypes.h
index 18dcd3e..c174dfc 100644
--- a/src/compiler/translator/BaseTypes.h
+++ b/src/compiler/translator/BaseTypes.h
@@ -7,7 +7,7 @@
#ifndef COMPILER_TRANSLATOR_BASETYPES_H_
#define COMPILER_TRANSLATOR_BASETYPES_H_
-#include "compiler/translator/compilerdebug.h"
+#include "common/debug.h"
//
// Precision qualifiers
diff --git a/src/compiler/translator/CallDAG.cpp b/src/compiler/translator/CallDAG.cpp
index 0588921..1d1eb8b 100644
--- a/src/compiler/translator/CallDAG.cpp
+++ b/src/compiler/translator/CallDAG.cpp
@@ -237,6 +237,7 @@
{
TOperator op = function->getOp();
ASSERT(op == EOpPrototype || op == EOpFunction || op == EOpFunctionCall);
+ UNUSED_ASSERTION_VARIABLE(op);
auto it = mFunctionIdToIndex.find(function->getFunctionId());
diff --git a/src/compiler/translator/Common.h b/src/compiler/translator/Common.h
index ac1aef0..5759302 100644
--- a/src/compiler/translator/Common.h
+++ b/src/compiler/translator/Common.h
@@ -14,9 +14,9 @@
#include <limits>
#include <stdio.h>
-#include "compiler/translator/PoolAlloc.h"
-#include "compiler/translator/compilerdebug.h"
#include "common/angleutils.h"
+#include "common/debug.h"
+#include "compiler/translator/PoolAlloc.h"
struct TSourceLoc {
int first_file;
diff --git a/src/compiler/translator/Diagnostics.cpp b/src/compiler/translator/Diagnostics.cpp
index 92db3e5..593137f 100644
--- a/src/compiler/translator/Diagnostics.cpp
+++ b/src/compiler/translator/Diagnostics.cpp
@@ -6,7 +6,7 @@
#include "compiler/translator/Diagnostics.h"
-#include "compiler/translator/compilerdebug.h"
+#include "common/debug.h"
#include "compiler/translator/InfoSink.h"
#include "compiler/preprocessor/SourceLocation.h"
@@ -50,11 +50,6 @@
sink << "'" << token << "' : " << reason << " " << extra << "\n";
}
-void TDiagnostics::writeDebug(const std::string& str)
-{
- mInfoSink.debug << str;
-}
-
void TDiagnostics::print(ID id,
const pp::SourceLocation& loc,
const std::string& text)
diff --git a/src/compiler/translator/Diagnostics.h b/src/compiler/translator/Diagnostics.h
index 078bc97..df65968 100644
--- a/src/compiler/translator/Diagnostics.h
+++ b/src/compiler/translator/Diagnostics.h
@@ -29,8 +29,6 @@
const std::string& token,
const std::string& extra);
- void writeDebug(const std::string& str);
-
protected:
virtual void print(ID id,
const pp::SourceLocation& loc,
diff --git a/src/compiler/translator/DirectiveHandler.cpp b/src/compiler/translator/DirectiveHandler.cpp
index 936c00a..084c22d 100644
--- a/src/compiler/translator/DirectiveHandler.cpp
+++ b/src/compiler/translator/DirectiveHandler.cpp
@@ -8,7 +8,7 @@
#include <sstream>
-#include "compiler/translator/compilerdebug.h"
+#include "common/debug.h"
#include "compiler/translator/Diagnostics.h"
static TBehavior getBehavior(const std::string& str)
diff --git a/src/compiler/translator/InitializeVariables.cpp b/src/compiler/translator/InitializeVariables.cpp
index 2bb609a..68e2b53 100644
--- a/src/compiler/translator/InitializeVariables.cpp
+++ b/src/compiler/translator/InitializeVariables.cpp
@@ -5,7 +5,8 @@
//
#include "compiler/translator/InitializeVariables.h"
-#include "compiler/translator/compilerdebug.h"
+
+#include "common/debug.h"
namespace
{
diff --git a/src/compiler/translator/IntermNode.cpp b/src/compiler/translator/IntermNode.cpp
index 4d6da5d..5aa8478 100644
--- a/src/compiler/translator/IntermNode.cpp
+++ b/src/compiler/translator/IntermNode.cpp
@@ -1495,6 +1495,7 @@
bool replaced = replacement.parent->replaceChildNode(
replacement.original, replacement.replacement);
ASSERT(replaced);
+ UNUSED_ASSERTION_VARIABLE(replaced);
if (!replacement.originalBecomesChildOfReplacement)
{
@@ -1517,5 +1518,6 @@
bool replaced = replacement.parent->replaceChildNodeWithMultiple(
replacement.original, replacement.replacements);
ASSERT(replaced);
+ UNUSED_ASSERTION_VARIABLE(replaced);
}
}
diff --git a/src/compiler/translator/OutputGLSLBase.cpp b/src/compiler/translator/OutputGLSLBase.cpp
index 6f7568e..54069e0 100644
--- a/src/compiler/translator/OutputGLSLBase.cpp
+++ b/src/compiler/translator/OutputGLSLBase.cpp
@@ -5,7 +5,8 @@
//
#include "compiler/translator/OutputGLSLBase.h"
-#include "compiler/translator/compilerdebug.h"
+
+#include "common/debug.h"
#include <cfloat>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index 03aab78..db51120 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -11,6 +11,7 @@
#include <stdio.h>
#include "common/angleutils.h"
+#include "common/debug.h"
#include "common/utilities.h"
#include "compiler/translator/BuiltInFunctionEmulator.h"
#include "compiler/translator/BuiltInFunctionEmulatorHLSL.h"
@@ -26,7 +27,6 @@
#include "compiler/translator/UniformHLSL.h"
#include "compiler/translator/UtilsHLSL.h"
#include "compiler/translator/blocklayout.h"
-#include "compiler/translator/compilerdebug.h"
#include "compiler/translator/util.h"
namespace sh
@@ -185,6 +185,7 @@
// Now that we are done changing the AST, do the analyses need for HLSL generation
CallDAG::InitResult success = mCallDag.init(treeRoot, &objSink);
ASSERT(success == CallDAG::INITDAG_SUCCESS);
+ UNUSED_ASSERTION_VARIABLE(success);
mASTMetadataList = CreateASTMetadataHLSL(treeRoot, mCallDag);
// Output the body and footer first to determine what has to go in the header
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 9b9ca3a..7e5dcb3 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -198,11 +198,6 @@
srcLoc, reason, token, extraInfo);
}
-void TParseContext::trace(const char* str)
-{
- diagnostics.writeDebug(str);
-}
-
//
// Same error message for all places assignments don't work.
//
diff --git a/src/compiler/translator/ParseContext.h b/src/compiler/translator/ParseContext.h
index 2c3d373..a79f727 100644
--- a/src/compiler/translator/ParseContext.h
+++ b/src/compiler/translator/ParseContext.h
@@ -78,7 +78,6 @@
const char* extraInfo="");
void warning(const TSourceLoc& loc, const char* reason, const char* token,
const char* extraInfo="");
- void trace(const char* str);
void recover();
// This method is guaranteed to succeed, even if no variable with 'name' exists.
diff --git a/src/compiler/translator/RegenerateStructNames.cpp b/src/compiler/translator/RegenerateStructNames.cpp
index 767b180..5e0db2a 100644
--- a/src/compiler/translator/RegenerateStructNames.cpp
+++ b/src/compiler/translator/RegenerateStructNames.cpp
@@ -4,8 +4,8 @@
// found in the LICENSE file.
//
+#include "common/debug.h"
#include "compiler/translator/RegenerateStructNames.h"
-#include "compiler/translator/compilerdebug.h"
void RegenerateStructNames::visitSymbol(TIntermSymbol *symbol)
{
diff --git a/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp b/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp
index 8857ad5..c1fdf50 100644
--- a/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp
+++ b/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp
@@ -4,8 +4,8 @@
// found in the LICENSE file.
//
+#include "common/debug.h"
#include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h"
-#include "compiler/translator/compilerdebug.h"
#include <algorithm>
diff --git a/src/compiler/translator/ShaderVars.cpp b/src/compiler/translator/ShaderVars.cpp
index 0dbbc9e..590655f 100644
--- a/src/compiler/translator/ShaderVars.cpp
+++ b/src/compiler/translator/ShaderVars.cpp
@@ -9,7 +9,7 @@
#include <GLSLANG/ShaderLang.h>
-#include "compiler/translator/compilerdebug.h"
+#include "common/debug.h"
namespace sh
{
diff --git a/src/compiler/translator/Types.h b/src/compiler/translator/Types.h
index 6355025..f81f93d 100644
--- a/src/compiler/translator/Types.h
+++ b/src/compiler/translator/Types.h
@@ -8,10 +8,10 @@
#define COMPILER_TRANSLATOR_TYPES_H_
#include "common/angleutils.h"
+#include "common/debug.h"
#include "compiler/translator/BaseTypes.h"
#include "compiler/translator/Common.h"
-#include "compiler/translator/compilerdebug.h"
struct TPublicType;
class TType;
diff --git a/src/compiler/translator/compilerdebug.cpp b/src/compiler/translator/compilerdebug.cpp
deleted file mode 100644
index 10cbe43..0000000
--- a/src/compiler/translator/compilerdebug.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// debug.cpp: Debugging utilities.
-
-#include "compiler/translator/compilerdebug.h"
-
-#include <stdarg.h>
-#include <stdio.h>
-
-#include "compiler/translator/InitializeParseContext.h"
-#include "compiler/translator/ParseContext.h"
-
-#ifdef TRACE_ENABLED
-static const int kTraceBufferLen = 1024;
-
-extern "C" {
-void Trace(const char *format, ...) {
- if (!format) return;
-
- TParseContext* parseContext = GetGlobalParseContext();
- if (parseContext) {
- char buf[kTraceBufferLen];
- va_list args;
- va_start(args, format);
- vsnprintf(buf, kTraceBufferLen, format, args);
- va_end(args);
-
- parseContext->trace(buf);
- }
-}
-} // extern "C"
-#endif // TRACE_ENABLED
-
diff --git a/src/compiler/translator/compilerdebug.h b/src/compiler/translator/compilerdebug.h
deleted file mode 100644
index 84a12ad..0000000
--- a/src/compiler/translator/compilerdebug.h
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// debug.h: Debugging utilities.
-
-#ifndef COMPILER_TRANSLATOR_COMPILERDEBUG_H_
-#define COMPILER_TRANSLATOR_COMPILERDEBUG_H_
-
-#include <assert.h>
-
-#ifdef _DEBUG
-#define TRACE_ENABLED // define to enable debug message tracing
-#endif // _DEBUG
-
-// Outputs text to the debug log
-#ifdef TRACE_ENABLED
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-void Trace(const char* format, ...);
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-
-#else // TRACE_ENABLED
-
-#define Trace(...) ((void)0)
-
-#endif // TRACE_ENABLED
-
-// A macro asserting a condition and outputting failures to the debug log
-#define ASSERT(expression) do { \
- if(!(expression)) \
- Trace("Assert failed: %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
- assert(expression); \
-} while(0)
-
-#define UNIMPLEMENTED() do { \
- Trace("Unimplemented invoked: %s(%d)\n", __FUNCTION__, __LINE__); \
- assert(false); \
-} while(0)
-
-#define UNREACHABLE() do { \
- Trace("Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \
- assert(false); \
-} while(0)
-
-#endif // COMPILER_TRANSLATOR_COMPILERDEBUG_H_
-