Enable Release ASSERT in ANGLE.
This will mainly affect the Chromium bots.
BUG=angleproject:790
Change-Id: I0c4318e83eedba851f15b3b139551cdb6a2fde12
Reviewed-on: https://chromium-review.googlesource.com/346103
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/common/debug.cpp b/src/common/debug.cpp
index 1fcc062..746da5e 100644
--- a/src/common/debug.cpp
+++ b/src/common/debug.cpp
@@ -7,19 +7,54 @@
// debug.cpp: Debugging utilities.
#include "common/debug.h"
-#include "common/platform.h"
-#include "common/angleutils.h"
#include <stdarg.h>
-#include <vector>
-#include <fstream>
+
#include <cstdio>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+#include "common/angleutils.h"
+#include "common/platform.h"
+#include "common/Optional.h"
namespace gl
{
namespace
{
+
+class FormattedString final : angle::NonCopyable
+{
+ public:
+ FormattedString(const char *format, va_list vararg) : mFormat(format)
+ {
+ va_copy(mVarArg, vararg);
+ }
+
+ const char *c_str() { return str().c_str(); }
+
+ const std::string &str()
+ {
+ if (!mMessage.valid())
+ {
+ mMessage = FormatString(mFormat, mVarArg);
+ }
+ return mMessage.value();
+ }
+
+ size_t length()
+ {
+ c_str();
+ return mMessage.value().length();
+ }
+
+ private:
+ const char *mFormat;
+ va_list mVarArg;
+ Optional<std::string> mMessage;
+};
enum DebugTraceOutputType
{
DebugTraceOutputTypeNone,
@@ -52,19 +87,15 @@
}
}
- std::string formattedMessage;
- UNUSED_VARIABLE(formattedMessage);
+ FormattedString formattedMessage(format, vararg);
-#if !defined(NDEBUG) && defined(_MSC_VER)
if (messageType == MESSAGE_ERR)
{
- if (formattedMessage.empty())
- {
- formattedMessage = FormatString(format, vararg);
- }
+ std::cerr << formattedMessage.c_str();
+#if !defined(NDEBUG) && defined(_MSC_VER)
OutputDebugStringA(formattedMessage.c_str());
+#endif // !defined(NDEBUG) && defined(_MSC_VER)
}
-#endif
#if defined(ANGLE_ENABLE_DEBUG_TRACE)
#if defined(NDEBUG)
@@ -72,12 +103,7 @@
{
return;
}
-#endif // NDEBUG
- if (formattedMessage.empty())
- {
- formattedMessage = FormatString(format, vararg);
- }
-
+#endif // NDEBUG
static std::ofstream file(TRACE_OUTPUT_FILE, std::ofstream::app);
if (file)
{
@@ -87,9 +113,9 @@
#if defined(ANGLE_ENABLE_DEBUG_TRACE_TO_DEBUGGER)
OutputDebugStringA(formattedMessage.c_str());
-#endif // ANGLE_ENABLE_DEBUG_TRACE_TO_DEBUGGER
+#endif // ANGLE_ENABLE_DEBUG_TRACE_TO_DEBUGGER
-#endif // ANGLE_ENABLE_DEBUG_TRACE
+#endif // ANGLE_ENABLE_DEBUG_TRACE
}
} // namespace