Turn on tracing on Android by default.
Log errors on UNIMPLEMENTED() rather than aborting.
For now ASSERT() will still abort.
Change-Id: I4db66934d0cd69b557fd2989e0c120a5fa372b99
Reviewed-on: https://swiftshader-review.googlesource.com/2691
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Greg Hartman <ghartman@google.com>
diff --git a/src/Common/Debug.cpp b/src/Common/Debug.cpp
index 5919551..b06e98f 100644
--- a/src/Common/Debug.cpp
+++ b/src/Common/Debug.cpp
@@ -13,7 +13,7 @@
#ifdef __ANDROID__
#include <utils/String8.h>
-#include <log/log.h>
+#include <cutils/log.h>
#endif
#include <stdio.h>
diff --git a/src/Common/Debug.hpp b/src/Common/Debug.hpp
index 8d61583..9cb4952 100644
--- a/src/Common/Debug.hpp
+++ b/src/Common/Debug.hpp
@@ -12,6 +12,10 @@
#ifndef Debug_hpp
#define Debug_hpp
+#ifdef __ANDROID__
+#include <cutils/log.h>
+#endif
+
#include <assert.h>
#include <stdio.h>
@@ -26,10 +30,30 @@
#define TRACE(...) ((void)0)
#endif
-#ifndef NDEBUG
- #define UNIMPLEMENTED() {trace("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); ASSERT(false);}
+#ifdef __ANDROID__
+ // On Android Virtual Devices we heavily depend on logging, even in
+ // production builds. We do this because AVDs are components of larger
+ // systems, and may be configured in ways that are difficult to
+ // reproduce locally. For example some system run tests against
+ // third-party code that we cannot access. Aborting (cf. assert) on
+ // unimplemented functionality creates two problems. First, it produces
+ // a service failure where none is needed. Second, it puts the
+ // customer on the critical path for notifying us of a problem.
+ // The alternative, skipping unimplemented functionality silently, is
+ // arguably worse: neither the service provider nor the customer will
+ // learn that unimplemented functionality may have compromised the test
+ // results.
+ // Logging invocations of unimplemented functionality is useful to both
+ // service provider and the customer. The service provider can learn
+ // that the functionality is needed. The customer learns that the test
+ // results may be compromised.
+ #define UNIMPLEMENTED() {ALOGE("Unimplemented: %s %s:%d", __FUNCTION__, __FILE__, __LINE__); }
#else
- #define UNIMPLEMENTED() ((void)0)
+ #ifndef NDEBUG
+ #define UNIMPLEMENTED() {trace("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); ASSERT(false);}
+ #else
+ #define UNIMPLEMENTED() ((void)0)
+ #endif
#endif
#ifndef NDEBUG
diff --git a/src/LLVM/Android.mk b/src/LLVM/Android.mk
index f9203ce..77e3bff 100644
--- a/src/LLVM/Android.mk
+++ b/src/LLVM/Android.mk
@@ -401,6 +401,10 @@
LOCAL_CFLAGS += -fno-operator-names -msse2 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
LOCAL_CFLAGS += -std=c++11
+# Android's make system also uses NDEBUG, so we need to set/unset it forcefully
+# Uncomment for ON:
+LOCAL_CFLAGS += -UNDEBUG
+
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include-android \
$(LOCAL_PATH)/include \
diff --git a/src/OpenGL/common/debug.cpp b/src/OpenGL/common/debug.cpp
index d3ad217..7789f12 100644
--- a/src/OpenGL/common/debug.cpp
+++ b/src/OpenGL/common/debug.cpp
@@ -15,7 +15,7 @@
#ifdef __ANDROID__
#include <utils/String8.h>
-#include <log/log.h>
+#include <cutils/log.h>
#endif
#include <stdio.h>
diff --git a/src/OpenGL/common/debug.h b/src/OpenGL/common/debug.h
index 08ef14a..f628040 100644
--- a/src/OpenGL/common/debug.h
+++ b/src/OpenGL/common/debug.h
@@ -14,6 +14,10 @@
#ifndef COMMON_DEBUG_H_
#define COMMON_DEBUG_H_
+#ifdef __ANDROID__
+#include <cutils/log.h>
+#endif
+
#include <stdio.h>
#include <assert.h>
@@ -60,13 +64,33 @@
#endif
// A macro to indicate unimplemented functionality
-#if !defined(NDEBUG)
-#define UNIMPLEMENTED() do { \
- FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \
- assert(false); \
- } while(0)
+#ifdef __ANDROID__
+ // On Android Virtual Devices we heavily depend on logging, even in
+ // production builds. We do this because AVDs are components of larger
+ // systems, and may be configured in ways that are difficult to
+ // reproduce locally. For example some system run tests against
+ // third-party code that we cannot access. Aborting (cf. assert) on
+ // unimplemented functionality creates two problems. First, it produces
+ // a service failure where none is needed. Second, it puts the
+ // customer on the critical path for notifying us of a problem.
+ // The alternative, skipping unimplemented functionality silently, is
+ // arguably worse: neither the service provider nor the customer will
+ // learn that unimplemented functionality may have compromised the test
+ // results.
+ // Logging invocations of unimplemented functionality is useful to both
+ // service provider and the customer. The service provider can learn
+ // that the functionality is needed. The customer learns that the test
+ // results may be compromised.
+ #define UNIMPLEMENTED() {ALOGE("Unimplemented: %s %s:%d", __FUNCTION__, __FILE__, __LINE__); }
#else
- #define UNIMPLEMENTED() FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__)
+ #if !defined(NDEBUG)
+ #define UNIMPLEMENTED() do { \
+ FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \
+ assert(false); \
+ } while(0)
+ #else
+ #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
diff --git a/src/OpenGL/libEGL/Android.mk b/src/OpenGL/libEGL/Android.mk
index 42428ae..7b62afc 100644
--- a/src/OpenGL/libEGL/Android.mk
+++ b/src/OpenGL/libEGL/Android.mk
@@ -16,7 +16,13 @@
main.cpp
LOCAL_CFLAGS += -DLOG_TAG=\"libEGL_swiftshader\"
-LOCAL_CFLAGS += -DNDEBUG -DANGLE_DISABLE_TRACE
+
+# Android's make system also uses NDEBUG, so we need to set/unset it forcefully
+# Uncomment for ON:
+LOCAL_CFLAGS += -UNDEBUG
+# Uncomment for OFF:
+#LOCAL_CFLAGS += -DNDEBUG -DANGLE_DISABLE_TRACE
+
LOCAL_CFLAGS += -std=c++11
# These changes tie the build to Cloud Android. Do something else
diff --git a/src/OpenGL/libGLES_CM/Android.mk b/src/OpenGL/libGLES_CM/Android.mk
index ff4c351..267eb1e 100644
--- a/src/OpenGL/libGLES_CM/Android.mk
+++ b/src/OpenGL/libGLES_CM/Android.mk
@@ -87,11 +87,16 @@
VertexDataManager.cpp
LOCAL_CFLAGS += -DLOG_TAG=\"libGLES_CM_swiftshader\"
-LOCAL_CFLAGS += -fomit-frame-pointer -ffunction-sections -fdata-sections -DNDEBUG -DANGLE_DISABLE_TRACE
LOCAL_CFLAGS += -fno-operator-names -msse2 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
LOCAL_CFLAGS += -std=c++11
-LOCAL_SHARED_LIBRARIES += libdl liblog libcutils libhardware libui
+# Android's make system also uses NDEBUG, so we need to set/unset it forcefully
+# Uncomment for ON:
+LOCAL_CFLAGS += -UNDEBUG
+# Uncomment for OFF:
+#LOCAL_CFLAGS += -fomit-frame-pointer -ffunction-sections -fdata-sections -DNDEBUG -DANGLE_DISABLE_TRACE
+
+LOCAL_SHARED_LIBRARIES += libdl liblog libcutils libhardware libui libutils
LOCAL_STATIC_LIBRARIES += libLLVM_swiftshader
LOCAL_LDFLAGS += -Wl,--gc-sections -Wl,--version-script=$(LOCAL_PATH)/exports.map -Wl,--hash-style=sysv
diff --git a/src/OpenGL/libGLESv2/Android.mk b/src/OpenGL/libGLESv2/Android.mk
index 3ff4f68..f2ce744 100644
--- a/src/OpenGL/libGLESv2/Android.mk
+++ b/src/OpenGL/libGLESv2/Android.mk
@@ -125,11 +125,17 @@
VertexDataManager.cpp \
LOCAL_CFLAGS += -DLOG_TAG=\"libGLESv2_swiftshader\"
-LOCAL_CFLAGS += -fomit-frame-pointer -ffunction-sections -fdata-sections -DNDEBUG -DANGLE_DISABLE_TRACE
+
+# Android's make system also uses NDEBUG, so we need to set/unset it forcefully
+# Uncomment for ON:
+LOCAL_CFLAGS += -UNDEBUG
+# Uncomment for OFF:
+#LOCAL_CFLAGS += -fomit-frame-pointer -ffunction-sections -fdata-sections -DNDEBUG -DANGLE_DISABLE_TRACE
+
LOCAL_CFLAGS += -fno-operator-names -msse2 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
LOCAL_CFLAGS += -std=c++11
-LOCAL_SHARED_LIBRARIES += libdl liblog libcutils libhardware libui
+LOCAL_SHARED_LIBRARIES += libdl liblog libcutils libhardware libui libutils
LOCAL_STATIC_LIBRARIES += libLLVM_swiftshader
LOCAL_LDFLAGS += -Wl,--gc-sections -Wl,--version-script=$(LOCAL_PATH)/exports.map -Wl,--hash-style=sysv