Commit 14aa40f0 by Jamie Madill

Print ERR() errors to the debug output on Windows.

We can switch this on for Debug only. This will help developers catch bugs more easily, and will only show up for internal errors and major performance caveats. Currently it's far too easy to miss these messages - it requires manually modifying debug.h, looking at a text file and potentially also running Chromium with an special flag. BUG=angle:663 Change-Id: I75b3bd05fbc75d21607b9957134db8e8990c77b1 Reviewed-on: https://chromium-review.googlesource.com/239191Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 054369e3
......@@ -182,7 +182,8 @@ enum DebugTraceOutputType
DebugTraceOutputTypeBeginEvent
};
static void output(bool traceInDebugOnly, DebugTraceOutputType outputType, const char *format, va_list vararg)
static void output(bool traceInDebugOnly, MessageType messageType, DebugTraceOutputType outputType,
const char *format, va_list vararg)
{
if (perfActive())
{
......@@ -204,6 +205,20 @@ static void output(bool traceInDebugOnly, DebugTraceOutputType outputType, const
}
}
std::string formattedMessage;
UNUSED_TRACE_VARIABLE(formattedMessage);
#if !defined(NDEBUG) && defined(_MSC_VER)
if (messageType == MESSAGE_ERR)
{
if (formattedMessage.empty())
{
formattedMessage = FormatString(format, vararg);
}
OutputDebugString(formattedMessage.c_str());
}
#endif
#if defined(ANGLE_ENABLE_DEBUG_TRACE)
#if defined(NDEBUG)
if (traceInDebugOnly)
......@@ -211,7 +226,10 @@ static void output(bool traceInDebugOnly, DebugTraceOutputType outputType, const
return;
}
#endif // NDEBUG
std::string formattedMessage = FormatString(format, vararg);
if (formattedMessage.empty())
{
formattedMessage = FormatString(format, vararg);
}
static std::ofstream file(TRACE_OUTPUT_FILE, std::ofstream::app);
if (file)
......@@ -227,14 +245,14 @@ static void output(bool traceInDebugOnly, DebugTraceOutputType outputType, const
#endif // ANGLE_ENABLE_DEBUG_TRACE
}
void trace(bool traceInDebugOnly, const char *format, ...)
void trace(bool traceInDebugOnly, MessageType messageType, const char *format, ...)
{
va_list vararg;
va_start(vararg, format);
#if defined(ANGLE_ENABLE_DEBUG_ANNOTATIONS)
output(traceInDebugOnly, DebugTraceOutputTypeSetMarker, format, vararg);
output(traceInDebugOnly, messageType, DebugTraceOutputTypeSetMarker, format, vararg);
#else
output(traceInDebugOnly, DebugTraceOutputTypeNone, format, vararg);
output(traceInDebugOnly, messageType, DebugTraceOutputTypeNone, format, vararg);
#endif
va_end(vararg);
}
......@@ -260,9 +278,9 @@ ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...)
va_list vararg;
va_start(vararg, format);
#if defined(ANGLE_ENABLE_DEBUG_ANNOTATIONS)
output(true, DebugTraceOutputTypeBeginEvent, format, vararg);
output(true, MESSAGE_EVENT, DebugTraceOutputTypeBeginEvent, format, vararg);
#else
output(true, DebugTraceOutputTypeNone, format, vararg);
output(true, MESSAGE_EVENT, DebugTraceOutputTypeNone, format, vararg);
#endif // ANGLE_ENABLE_DEBUG_ANNOTATIONS
va_end(vararg);
}
......
......@@ -20,8 +20,16 @@
namespace gl
{
enum MessageType
{
MESSAGE_TRACE,
MESSAGE_FIXME,
MESSAGE_ERR,
MESSAGE_EVENT,
};
// Outputs text to the debugging log, or the debugging window
void trace(bool traceInDebugOnly, const char *format, ...);
void trace(bool traceInDebugOnly, MessageType messageType, const char *format, ...);
// Returns whether D3DPERF is active.
bool perfActive();
......@@ -43,21 +51,21 @@ namespace gl
// A macro to output a trace of a function call and its arguments to the debugging log
#if defined(ANGLE_ENABLE_DEBUG_TRACE) || defined(ANGLE_ENABLE_DEBUG_ANNOTATIONS)
#define TRACE(message, ...) gl::trace(true, "trace: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define TRACE(message, ...) gl::trace(true, gl::MESSAGE_TRACE, "trace: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define TRACE(message, ...) (void(0))
#endif
// A macro to output a function call and its arguments to the debugging log, to denote an item in need of fixing.
#if defined(ANGLE_ENABLE_DEBUG_TRACE) || defined(ANGLE_ENABLE_DEBUG_ANNOTATIONS)
#define FIXME(message, ...) gl::trace(false, "fixme: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define FIXME(message, ...) gl::trace(false, gl::MESSAGE_FIXME, "fixme: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define FIXME(message, ...) (void(0))
#endif
// A macro to output a function call and its arguments to the debugging log, in case of error.
#if defined(ANGLE_ENABLE_DEBUG_TRACE) || defined(ANGLE_ENABLE_DEBUG_ANNOTATIONS)
#define ERR(message, ...) gl::trace(false, "err: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define ERR(message, ...) gl::trace(false, gl::MESSAGE_ERR, "err: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define ERR(message, ...) (void(0))
#endif
......
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