Commit a5dfd97d by Nicolas Capens Committed by Nicolas Capens

Remove stray printfs.

SwiftShader shouldn't print anything to stdout in Release builds. Also refactor UNIMPLEMENTED macro to be able to take a formatted string with arguments. Bug b/73656151 Change-Id: Ibadbfba3371324ba1bd608bd51bdac5e5923a20e Reviewed-on: https://swiftshader-review.googlesource.com/21108Reviewed-by: 's avatarMerck Hung <merckhung@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent f1d777c7
......@@ -66,7 +66,7 @@ namespace sw
if(!isprint(line[0]))
{
printf("Failing on char %d\n", line[0]);
// printf("Failing on char %d\n", line[0]);
file.close();
return false;
}
......
......@@ -17,6 +17,8 @@
#include <stdio.h>
#include <stdarg.h>
namespace sw
{
void trace(const char *format, ...)
{
if(false)
......@@ -34,3 +36,4 @@ void trace(const char *format, ...)
}
}
}
}
......@@ -25,25 +25,34 @@
#undef min
#undef max
namespace sw
{
void trace(const char *format, ...);
inline void trace() {}
}
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define TRACE(format, ...) trace("[0x%0.8X]%s(" format ")\n", this, __FUNCTION__, ##__VA_ARGS__)
#define TRACE(format, ...) sw::trace("[0x%0.8X]%s(" format ")\n", this, __FUNCTION__, ##__VA_ARGS__)
#else
#define TRACE(...) ((void)0)
#endif
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define UNIMPLEMENTED() {trace("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); ASSERT(false);}
#define UNIMPLEMENTED(...) do { \
sw::trace("\t! Unimplemented: %s(%d): ", __FUNCTION__, __LINE__); \
sw::trace(##__VA_ARGS__); \
sw::trace("\n"); \
ASSERT(false); \
} while(0)
#else
#define UNIMPLEMENTED() ((void)0)
#define UNIMPLEMENTED(...) ((void)0)
#endif
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define ASSERT(expression) {if(!(expression)) trace("\t! Assert failed in %s(%d): " #expression "\n", __FUNCTION__, __LINE__); assert(expression);}
#define ASSERT(expression) {if(!(expression)) sw::trace("\t! Assert failed in %s(%d): " #expression "\n", __FUNCTION__, __LINE__); assert(expression);}
#else
#define ASSERT assert
#endif
#endif // __ANDROID__
#endif // !__ANDROID__
#endif // Debug_hpp
......@@ -66,7 +66,8 @@ void AndroidEnterDebugger();
AndroidEnterDebugger(); \
} while(0)
#define UNIMPLEMENTED() do { \
// TODO: Handle __VA_ARGS__ (can be empty)
#define UNIMPLEMENTED(...) do { \
ALOGE("badness: unimplemented: %s %s:%d", \
__FUNCTION__, __FILE__, __LINE__); \
AndroidEnterDebugger(); \
......
......@@ -34,7 +34,7 @@ namespace es
#else
static void output(const char *format, va_list vararg)
{
if(false)
if(true)
{
static FILE* file = nullptr;
if(!file)
......@@ -45,6 +45,7 @@ namespace es
if(file)
{
vfprintf(file, format, vararg);
fflush(file);
}
}
}
......
......@@ -29,8 +29,9 @@
namespace es
{
// Outputs text to the debugging log
void trace(const char *format, ...);
// Outputs text to the debugging log
void trace(const char *format, ...);
inline void trace() {}
}
// A macro to output a trace of a function call and its arguments to the debugging log
......@@ -69,12 +70,14 @@ namespace es
// A macro to indicate unimplemented functionality
#undef UNIMPLEMENTED
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define UNIMPLEMENTED() do { \
FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \
#define UNIMPLEMENTED(...) do { \
es::trace("\t! Unimplemented: %s(%d): ", __FUNCTION__, __LINE__); \
es::trace(##__VA_ARGS__); \
es::trace("\n"); \
assert(false); \
} while(0)
#else
#define UNIMPLEMENTED() FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__)
#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
......
......@@ -23,7 +23,7 @@
#include "ParseHelper.h"
#ifdef TRACE_ENABLED
extern "C" {
namespace sh {
void Trace(const char *format, ...) {
if (!format) return;
......@@ -39,6 +39,6 @@ void Trace(const char *format, ...) {
parseContext->trace(buf);
}
}
} // extern "C"
} // namespace sh
#endif // TRACE_ENABLED
......@@ -30,42 +30,37 @@
#endif // _DEBUG
// Outputs text to the debug log
namespace sh {
#ifdef TRACE_ENABLED
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void Trace(const char* format, ...);
#ifdef __cplusplus
#else
inline void Trace(const char* format, ...) {}
#endif
inline void Trace() {}
}
#endif // __cplusplus
#else // TRACE_ENABLED
#define Trace(...) ((void)0)
#endif // TRACE_ENABLED
// A macro asserting a condition and outputting failures to the debug log
#undef ASSERT
#define ASSERT(expression) do { \
if(!(expression)) \
Trace("Assert failed: %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
sh::Trace("Assert failed: %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
assert(expression); \
} while(0)
#undef UNIMPLEMENTED
#define UNIMPLEMENTED() do { \
Trace("Unimplemented invoked: %s(%d)\n", __FUNCTION__, __LINE__); \
#define UNIMPLEMENTED(...) do { \
sh::Trace("Unimplemented invoked: %s(%d): ", __FUNCTION__, __LINE__); \
sh::Trace(##__VA_ARGS__); \
sh::Trace("\n"); \
assert(false); \
} while(0)
#undef UNREACHABLE
#define UNREACHABLE(value) do { \
Trace("Unreachable reached: %s(%d). %s: %d\n", __FUNCTION__, __LINE__, #value, value); \
sh::Trace("Unreachable reached: %s(%d). %s: %d\n", __FUNCTION__, __LINE__, #value, value); \
assert(false); \
} while(0)
#endif // __ANDROID__
#endif // !__ANDROID__
#endif // COMPILER_DEBUG_H_
......@@ -962,8 +962,7 @@ void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x,
}
else
{
printf("internalformat = %x, colorbufferFormat = %X\n", internalformat, colorbufferFormat);
UNIMPLEMENTED();
UNIMPLEMENTED("internalformat = %x, colorbufferFormat = %X", internalformat, colorbufferFormat);
return error(GL_INVALID_OPERATION);
}
......
......@@ -28,6 +28,7 @@ namespace vk
{
// Outputs text to the debugging log
void trace(const char *format, ...);
inline void trace() {}
}
// A macro to output a trace of a function call and its arguments to the debugging log
......@@ -66,8 +67,10 @@ void trace(const char *format, ...);
// A macro to indicate unimplemented functionality
#undef UNIMPLEMENTED
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define UNIMPLEMENTED() do { \
FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \
#define UNIMPLEMENTED(...) do { \
vk::trace("\t! Unimplemented: %s(%d): ", __FUNCTION__, __LINE__); \
vk::trace(##__VA_ARGS__); \
vk::trace("\n"); \
assert(false); \
} while(0)
#else
......
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