Commit d57e0db3 by Olli Etuaho

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/267411Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 84115c92
...@@ -113,8 +113,6 @@ ...@@ -113,8 +113,6 @@
'compiler/translator/VersionGLSL.h', 'compiler/translator/VersionGLSL.h',
'compiler/translator/blocklayout.cpp', 'compiler/translator/blocklayout.cpp',
'compiler/translator/blocklayout.h', 'compiler/translator/blocklayout.h',
'compiler/translator/compilerdebug.cpp',
'compiler/translator/compilerdebug.h',
'compiler/translator/depgraph/DependencyGraph.cpp', 'compiler/translator/depgraph/DependencyGraph.cpp',
'compiler/translator/depgraph/DependencyGraph.h', 'compiler/translator/depgraph/DependencyGraph.h',
'compiler/translator/depgraph/DependencyGraphBuilder.cpp', 'compiler/translator/depgraph/DependencyGraphBuilder.cpp',
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#ifndef COMPILER_TRANSLATOR_BASETYPES_H_ #ifndef COMPILER_TRANSLATOR_BASETYPES_H_
#define COMPILER_TRANSLATOR_BASETYPES_H_ #define COMPILER_TRANSLATOR_BASETYPES_H_
#include "compiler/translator/compilerdebug.h" #include "common/debug.h"
// //
// Precision qualifiers // Precision qualifiers
......
...@@ -237,6 +237,7 @@ size_t CallDAG::findIndex(const TIntermAggregate *function) const ...@@ -237,6 +237,7 @@ size_t CallDAG::findIndex(const TIntermAggregate *function) const
{ {
TOperator op = function->getOp(); TOperator op = function->getOp();
ASSERT(op == EOpPrototype || op == EOpFunction || op == EOpFunctionCall); ASSERT(op == EOpPrototype || op == EOpFunction || op == EOpFunctionCall);
UNUSED_ASSERTION_VARIABLE(op);
auto it = mFunctionIdToIndex.find(function->getFunctionId()); auto it = mFunctionIdToIndex.find(function->getFunctionId());
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
#include <limits> #include <limits>
#include <stdio.h> #include <stdio.h>
#include "compiler/translator/PoolAlloc.h"
#include "compiler/translator/compilerdebug.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/debug.h"
#include "compiler/translator/PoolAlloc.h"
struct TSourceLoc { struct TSourceLoc {
int first_file; int first_file;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "compiler/translator/Diagnostics.h" #include "compiler/translator/Diagnostics.h"
#include "compiler/translator/compilerdebug.h" #include "common/debug.h"
#include "compiler/translator/InfoSink.h" #include "compiler/translator/InfoSink.h"
#include "compiler/preprocessor/SourceLocation.h" #include "compiler/preprocessor/SourceLocation.h"
...@@ -50,11 +50,6 @@ void TDiagnostics::writeInfo(Severity severity, ...@@ -50,11 +50,6 @@ void TDiagnostics::writeInfo(Severity severity,
sink << "'" << token << "' : " << reason << " " << extra << "\n"; sink << "'" << token << "' : " << reason << " " << extra << "\n";
} }
void TDiagnostics::writeDebug(const std::string& str)
{
mInfoSink.debug << str;
}
void TDiagnostics::print(ID id, void TDiagnostics::print(ID id,
const pp::SourceLocation& loc, const pp::SourceLocation& loc,
const std::string& text) const std::string& text)
......
...@@ -29,8 +29,6 @@ class TDiagnostics : public pp::Diagnostics, angle::NonCopyable ...@@ -29,8 +29,6 @@ class TDiagnostics : public pp::Diagnostics, angle::NonCopyable
const std::string& token, const std::string& token,
const std::string& extra); const std::string& extra);
void writeDebug(const std::string& str);
protected: protected:
virtual void print(ID id, virtual void print(ID id,
const pp::SourceLocation& loc, const pp::SourceLocation& loc,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <sstream> #include <sstream>
#include "compiler/translator/compilerdebug.h" #include "common/debug.h"
#include "compiler/translator/Diagnostics.h" #include "compiler/translator/Diagnostics.h"
static TBehavior getBehavior(const std::string& str) static TBehavior getBehavior(const std::string& str)
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
// //
#include "compiler/translator/InitializeVariables.h" #include "compiler/translator/InitializeVariables.h"
#include "compiler/translator/compilerdebug.h"
#include "common/debug.h"
namespace namespace
{ {
......
...@@ -1495,6 +1495,7 @@ void TIntermTraverser::updateTree() ...@@ -1495,6 +1495,7 @@ void TIntermTraverser::updateTree()
bool replaced = replacement.parent->replaceChildNode( bool replaced = replacement.parent->replaceChildNode(
replacement.original, replacement.replacement); replacement.original, replacement.replacement);
ASSERT(replaced); ASSERT(replaced);
UNUSED_ASSERTION_VARIABLE(replaced);
if (!replacement.originalBecomesChildOfReplacement) if (!replacement.originalBecomesChildOfReplacement)
{ {
...@@ -1517,5 +1518,6 @@ void TIntermTraverser::updateTree() ...@@ -1517,5 +1518,6 @@ void TIntermTraverser::updateTree()
bool replaced = replacement.parent->replaceChildNodeWithMultiple( bool replaced = replacement.parent->replaceChildNodeWithMultiple(
replacement.original, replacement.replacements); replacement.original, replacement.replacements);
ASSERT(replaced); ASSERT(replaced);
UNUSED_ASSERTION_VARIABLE(replaced);
} }
} }
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
// //
#include "compiler/translator/OutputGLSLBase.h" #include "compiler/translator/OutputGLSLBase.h"
#include "compiler/translator/compilerdebug.h"
#include "common/debug.h"
#include <cfloat> #include <cfloat>
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <stdio.h> #include <stdio.h>
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/debug.h"
#include "common/utilities.h" #include "common/utilities.h"
#include "compiler/translator/BuiltInFunctionEmulator.h" #include "compiler/translator/BuiltInFunctionEmulator.h"
#include "compiler/translator/BuiltInFunctionEmulatorHLSL.h" #include "compiler/translator/BuiltInFunctionEmulatorHLSL.h"
...@@ -26,7 +27,6 @@ ...@@ -26,7 +27,6 @@
#include "compiler/translator/UniformHLSL.h" #include "compiler/translator/UniformHLSL.h"
#include "compiler/translator/UtilsHLSL.h" #include "compiler/translator/UtilsHLSL.h"
#include "compiler/translator/blocklayout.h" #include "compiler/translator/blocklayout.h"
#include "compiler/translator/compilerdebug.h"
#include "compiler/translator/util.h" #include "compiler/translator/util.h"
namespace sh namespace sh
...@@ -185,6 +185,7 @@ void OutputHLSL::output(TIntermNode *treeRoot, TInfoSinkBase &objSink) ...@@ -185,6 +185,7 @@ void OutputHLSL::output(TIntermNode *treeRoot, TInfoSinkBase &objSink)
// Now that we are done changing the AST, do the analyses need for HLSL generation // Now that we are done changing the AST, do the analyses need for HLSL generation
CallDAG::InitResult success = mCallDag.init(treeRoot, &objSink); CallDAG::InitResult success = mCallDag.init(treeRoot, &objSink);
ASSERT(success == CallDAG::INITDAG_SUCCESS); ASSERT(success == CallDAG::INITDAG_SUCCESS);
UNUSED_ASSERTION_VARIABLE(success);
mASTMetadataList = CreateASTMetadataHLSL(treeRoot, mCallDag); mASTMetadataList = CreateASTMetadataHLSL(treeRoot, mCallDag);
// Output the body and footer first to determine what has to go in the header // Output the body and footer first to determine what has to go in the header
......
...@@ -198,11 +198,6 @@ void TParseContext::warning(const TSourceLoc& loc, ...@@ -198,11 +198,6 @@ void TParseContext::warning(const TSourceLoc& loc,
srcLoc, reason, token, extraInfo); srcLoc, reason, token, extraInfo);
} }
void TParseContext::trace(const char* str)
{
diagnostics.writeDebug(str);
}
// //
// Same error message for all places assignments don't work. // Same error message for all places assignments don't work.
// //
......
...@@ -78,7 +78,6 @@ struct TParseContext { ...@@ -78,7 +78,6 @@ struct TParseContext {
const char* extraInfo=""); const char* extraInfo="");
void warning(const TSourceLoc& loc, const char* reason, const char* token, void warning(const TSourceLoc& loc, const char* reason, const char* token,
const char* extraInfo=""); const char* extraInfo="");
void trace(const char* str);
void recover(); void recover();
// This method is guaranteed to succeed, even if no variable with 'name' exists. // This method is guaranteed to succeed, even if no variable with 'name' exists.
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
#include "common/debug.h"
#include "compiler/translator/RegenerateStructNames.h" #include "compiler/translator/RegenerateStructNames.h"
#include "compiler/translator/compilerdebug.h"
void RegenerateStructNames::visitSymbol(TIntermSymbol *symbol) void RegenerateStructNames::visitSymbol(TIntermSymbol *symbol)
{ {
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
#include "common/debug.h"
#include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h" #include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h"
#include "compiler/translator/compilerdebug.h"
#include <algorithm> #include <algorithm>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <GLSLANG/ShaderLang.h> #include <GLSLANG/ShaderLang.h>
#include "compiler/translator/compilerdebug.h" #include "common/debug.h"
namespace sh namespace sh
{ {
......
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
#define COMPILER_TRANSLATOR_TYPES_H_ #define COMPILER_TRANSLATOR_TYPES_H_
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/debug.h"
#include "compiler/translator/BaseTypes.h" #include "compiler/translator/BaseTypes.h"
#include "compiler/translator/Common.h" #include "compiler/translator/Common.h"
#include "compiler/translator/compilerdebug.h"
struct TPublicType; struct TPublicType;
class TType; class TType;
......
//
// 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
//
// 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_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment