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 ...@@ -66,7 +66,7 @@ namespace sw
if(!isprint(line[0])) if(!isprint(line[0]))
{ {
printf("Failing on char %d\n", line[0]); // printf("Failing on char %d\n", line[0]);
file.close(); file.close();
return false; return false;
} }
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
namespace sw
{
void trace(const char *format, ...) void trace(const char *format, ...)
{ {
if(false) if(false)
...@@ -34,3 +36,4 @@ void trace(const char *format, ...) ...@@ -34,3 +36,4 @@ void trace(const char *format, ...)
} }
} }
} }
}
...@@ -25,25 +25,34 @@ ...@@ -25,25 +25,34 @@
#undef min #undef min
#undef max #undef max
namespace sw
{
void trace(const char *format, ...); void trace(const char *format, ...);
inline void trace() {}
}
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) #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 #else
#define TRACE(...) ((void)0) #define TRACE(...) ((void)0)
#endif #endif
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) #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 #else
#define UNIMPLEMENTED() ((void)0) #define UNIMPLEMENTED(...) ((void)0)
#endif #endif
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) #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 #else
#define ASSERT assert #define ASSERT assert
#endif #endif
#endif // __ANDROID__ #endif // !__ANDROID__
#endif // Debug_hpp #endif // Debug_hpp
...@@ -66,7 +66,8 @@ void AndroidEnterDebugger(); ...@@ -66,7 +66,8 @@ void AndroidEnterDebugger();
AndroidEnterDebugger(); \ AndroidEnterDebugger(); \
} while(0) } while(0)
#define UNIMPLEMENTED() do { \ // TODO: Handle __VA_ARGS__ (can be empty)
#define UNIMPLEMENTED(...) do { \
ALOGE("badness: unimplemented: %s %s:%d", \ ALOGE("badness: unimplemented: %s %s:%d", \
__FUNCTION__, __FILE__, __LINE__); \ __FUNCTION__, __FILE__, __LINE__); \
AndroidEnterDebugger(); \ AndroidEnterDebugger(); \
......
...@@ -34,7 +34,7 @@ namespace es ...@@ -34,7 +34,7 @@ namespace es
#else #else
static void output(const char *format, va_list vararg) static void output(const char *format, va_list vararg)
{ {
if(false) if(true)
{ {
static FILE* file = nullptr; static FILE* file = nullptr;
if(!file) if(!file)
...@@ -45,6 +45,7 @@ namespace es ...@@ -45,6 +45,7 @@ namespace es
if(file) if(file)
{ {
vfprintf(file, format, vararg); vfprintf(file, format, vararg);
fflush(file);
} }
} }
} }
......
...@@ -29,8 +29,9 @@ ...@@ -29,8 +29,9 @@
namespace es namespace es
{ {
// Outputs text to the debugging log // Outputs text to the debugging log
void trace(const char *format, ...); 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 // A macro to output a trace of a function call and its arguments to the debugging log
...@@ -69,12 +70,14 @@ namespace es ...@@ -69,12 +70,14 @@ namespace es
// A macro to indicate unimplemented functionality // A macro to indicate unimplemented functionality
#undef UNIMPLEMENTED #undef UNIMPLEMENTED
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define UNIMPLEMENTED() do { \ #define UNIMPLEMENTED(...) do { \
FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \ es::trace("\t! Unimplemented: %s(%d): ", __FUNCTION__, __LINE__); \
es::trace(##__VA_ARGS__); \
es::trace("\n"); \
assert(false); \ assert(false); \
} while(0) } while(0)
#else #else
#define UNIMPLEMENTED() FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__) #define UNIMPLEMENTED(...) FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__)
#endif #endif
// A macro for code which is not expected to be reached under valid assumptions // A macro for code which is not expected to be reached under valid assumptions
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "ParseHelper.h" #include "ParseHelper.h"
#ifdef TRACE_ENABLED #ifdef TRACE_ENABLED
extern "C" { namespace sh {
void Trace(const char *format, ...) { void Trace(const char *format, ...) {
if (!format) return; if (!format) return;
...@@ -39,6 +39,6 @@ void Trace(const char *format, ...) { ...@@ -39,6 +39,6 @@ void Trace(const char *format, ...) {
parseContext->trace(buf); parseContext->trace(buf);
} }
} }
} // extern "C" } // namespace sh
#endif // TRACE_ENABLED #endif // TRACE_ENABLED
...@@ -30,42 +30,37 @@ ...@@ -30,42 +30,37 @@
#endif // _DEBUG #endif // _DEBUG
// Outputs text to the debug log // Outputs text to the debug log
namespace sh {
#ifdef TRACE_ENABLED #ifdef TRACE_ENABLED
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void Trace(const char* format, ...); 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 // A macro asserting a condition and outputting failures to the debug log
#undef ASSERT #undef ASSERT
#define ASSERT(expression) do { \ #define ASSERT(expression) do { \
if(!(expression)) \ if(!(expression)) \
Trace("Assert failed: %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \ sh::Trace("Assert failed: %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
assert(expression); \ assert(expression); \
} while(0) } while(0)
#undef UNIMPLEMENTED #undef UNIMPLEMENTED
#define UNIMPLEMENTED() do { \ #define UNIMPLEMENTED(...) do { \
Trace("Unimplemented invoked: %s(%d)\n", __FUNCTION__, __LINE__); \ sh::Trace("Unimplemented invoked: %s(%d): ", __FUNCTION__, __LINE__); \
sh::Trace(##__VA_ARGS__); \
sh::Trace("\n"); \
assert(false); \ assert(false); \
} while(0) } while(0)
#undef UNREACHABLE #undef UNREACHABLE
#define UNREACHABLE(value) do { \ #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); \ assert(false); \
} while(0) } while(0)
#endif // __ANDROID__ #endif // !__ANDROID__
#endif // COMPILER_DEBUG_H_ #endif // COMPILER_DEBUG_H_
...@@ -962,8 +962,7 @@ void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, ...@@ -962,8 +962,7 @@ void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x,
} }
else else
{ {
printf("internalformat = %x, colorbufferFormat = %X\n", internalformat, colorbufferFormat); UNIMPLEMENTED("internalformat = %x, colorbufferFormat = %X", internalformat, colorbufferFormat);
UNIMPLEMENTED();
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
......
...@@ -28,6 +28,7 @@ namespace vk ...@@ -28,6 +28,7 @@ namespace vk
{ {
// Outputs text to the debugging log // Outputs text to the debugging log
void trace(const char *format, ...); 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 // 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, ...); ...@@ -66,8 +67,10 @@ void trace(const char *format, ...);
// A macro to indicate unimplemented functionality // A macro to indicate unimplemented functionality
#undef UNIMPLEMENTED #undef UNIMPLEMENTED
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define UNIMPLEMENTED() do { \ #define UNIMPLEMENTED(...) do { \
FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \ vk::trace("\t! Unimplemented: %s(%d): ", __FUNCTION__, __LINE__); \
vk::trace(##__VA_ARGS__); \
vk::trace("\n"); \
assert(false); \ assert(false); \
} while(0) } while(0)
#else #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