Commit ef1ac39e by Greg Hartman

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/2691Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarGreg Hartman <ghartman@google.com>
parent a5fc5191
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#ifdef __ANDROID__ #ifdef __ANDROID__
#include <utils/String8.h> #include <utils/String8.h>
#include <log/log.h> #include <cutils/log.h>
#endif #endif
#include <stdio.h> #include <stdio.h>
......
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
#ifndef Debug_hpp #ifndef Debug_hpp
#define Debug_hpp #define Debug_hpp
#ifdef __ANDROID__
#include <cutils/log.h>
#endif
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
...@@ -26,10 +30,30 @@ void trace(const char *format, ...); ...@@ -26,10 +30,30 @@ void trace(const char *format, ...);
#define TRACE(...) ((void)0) #define TRACE(...) ((void)0)
#endif #endif
#ifndef NDEBUG #ifdef __ANDROID__
#define UNIMPLEMENTED() {trace("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); ASSERT(false);} // 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 #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 #endif
#ifndef NDEBUG #ifndef NDEBUG
......
...@@ -401,6 +401,10 @@ LOCAL_CFLAGS += -fomit-frame-pointer -Os -ffunction-sections -fdata-sections ...@@ -401,6 +401,10 @@ LOCAL_CFLAGS += -fomit-frame-pointer -Os -ffunction-sections -fdata-sections
LOCAL_CFLAGS += -fno-operator-names -msse2 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS LOCAL_CFLAGS += -fno-operator-names -msse2 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
LOCAL_CFLAGS += -std=c++11 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_C_INCLUDES += \
$(LOCAL_PATH)/include-android \ $(LOCAL_PATH)/include-android \
$(LOCAL_PATH)/include \ $(LOCAL_PATH)/include \
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#ifdef __ANDROID__ #ifdef __ANDROID__
#include <utils/String8.h> #include <utils/String8.h>
#include <log/log.h> #include <cutils/log.h>
#endif #endif
#include <stdio.h> #include <stdio.h>
......
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
#ifndef COMMON_DEBUG_H_ #ifndef COMMON_DEBUG_H_
#define COMMON_DEBUG_H_ #define COMMON_DEBUG_H_
#ifdef __ANDROID__
#include <cutils/log.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
...@@ -60,13 +64,33 @@ namespace es ...@@ -60,13 +64,33 @@ namespace es
#endif #endif
// A macro to indicate unimplemented functionality // A macro to indicate unimplemented functionality
#if !defined(NDEBUG) #ifdef __ANDROID__
#define UNIMPLEMENTED() do { \ // On Android Virtual Devices we heavily depend on logging, even in
FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \ // production builds. We do this because AVDs are components of larger
assert(false); \ // systems, and may be configured in ways that are difficult to
} while(0) // 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 #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 #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
......
...@@ -16,7 +16,13 @@ LOCAL_SRC_FILES += \ ...@@ -16,7 +16,13 @@ LOCAL_SRC_FILES += \
main.cpp main.cpp
LOCAL_CFLAGS += -DLOG_TAG=\"libEGL_swiftshader\" 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 LOCAL_CFLAGS += -std=c++11
# These changes tie the build to Cloud Android. Do something else # These changes tie the build to Cloud Android. Do something else
......
...@@ -87,11 +87,16 @@ LOCAL_SRC_FILES += \ ...@@ -87,11 +87,16 @@ LOCAL_SRC_FILES += \
VertexDataManager.cpp VertexDataManager.cpp
LOCAL_CFLAGS += -DLOG_TAG=\"libGLES_CM_swiftshader\" 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 += -fno-operator-names -msse2 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
LOCAL_CFLAGS += -std=c++11 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_STATIC_LIBRARIES += libLLVM_swiftshader
LOCAL_LDFLAGS += -Wl,--gc-sections -Wl,--version-script=$(LOCAL_PATH)/exports.map -Wl,--hash-style=sysv LOCAL_LDFLAGS += -Wl,--gc-sections -Wl,--version-script=$(LOCAL_PATH)/exports.map -Wl,--hash-style=sysv
......
...@@ -125,11 +125,17 @@ LOCAL_SRC_FILES += \ ...@@ -125,11 +125,17 @@ LOCAL_SRC_FILES += \
VertexDataManager.cpp \ VertexDataManager.cpp \
LOCAL_CFLAGS += -DLOG_TAG=\"libGLESv2_swiftshader\" 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 += -fno-operator-names -msse2 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
LOCAL_CFLAGS += -std=c++11 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_STATIC_LIBRARIES += libLLVM_swiftshader
LOCAL_LDFLAGS += -Wl,--gc-sections -Wl,--version-script=$(LOCAL_PATH)/exports.map -Wl,--hash-style=sysv LOCAL_LDFLAGS += -Wl,--gc-sections -Wl,--version-script=$(LOCAL_PATH)/exports.map -Wl,--hash-style=sysv
......
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