aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/config/SkUserConfig.h7
-rw-r--r--include/core/SkPostConfig.h45
-rw-r--r--include/core/SkTArray.h2
-rw-r--r--include/core/SkTypes.h10
4 files changed, 20 insertions, 44 deletions
diff --git a/include/config/SkUserConfig.h b/include/config/SkUserConfig.h
index ff8a5f3154..a0f6258281 100644
--- a/include/config/SkUserConfig.h
+++ b/include/config/SkUserConfig.h
@@ -58,13 +58,6 @@
//#define SK_DEBUG_GLYPH_CACHE
//#define SK_DEBUG_PATH
-/* If, in debugging mode, Skia needs to stop (presumably to invoke a debugger)
- it will call SK_CRASH(). If this is not defined it, it is defined in
- SkPostConfig.h to write to an illegal address
- */
-//#define SK_CRASH() *(int *)(uintptr_t)0 = 0
-
-
/* preconfig will have attempted to determine the endianness of the system,
but you can change these mutually exclusive flags here.
*/
diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h
index 387ea5b154..68354a6156 100644
--- a/include/core/SkPostConfig.h
+++ b/include/core/SkPostConfig.h
@@ -103,17 +103,6 @@
// TODO(mdempsky): Move elsewhere as appropriate.
#include <new>
-#ifndef SK_CRASH
-# ifdef SK_BUILD_FOR_WIN
-# define SK_CRASH() __debugbreak()
-# else
-# if 1 // set to 0 for infinite loop, which can help connecting gdb
-# define SK_CRASH() do { SkNO_RETURN_HINT(); *(int *)(uintptr_t)0xbbadbeef = 0; } while (false)
-# else
-# define SK_CRASH() do { SkNO_RETURN_HINT(); } while (true)
-# endif
-# endif
-#endif
///////////////////////////////////////////////////////////////////////////////
@@ -148,31 +137,21 @@
#endif
#if defined(GOOGLE3)
- // Used as argument to DumpStackTrace in SK_ALWAYSBREAK.
void SkDebugfForDumpStackTrace(const char* data, void* unused);
+ void DumpStackTrace(int skip_count, void w(const char*, void*), void* arg);
+# define SK_DUMP_GOOGLE3_STACK() DumpStackTrace(0, SkDebugfForDumpStackTrace, nullptr)
+#else
+# define SK_DUMP_GOOGLE3_STACK()
#endif
-#ifndef SK_ALWAYSBREAK
-# if defined(GOOGLE3)
- void DumpStackTrace(int skip_count, void w(const char*, void*),
- void* arg);
-# define SK_ALWAYSBREAK(cond) do { \
- if (cond) break; \
- SkNO_RETURN_HINT(); \
- SkDebugf("%s:%d: failed assertion \"%s\"\n", __FILE__, __LINE__, #cond); \
- DumpStackTrace(0, SkDebugfForDumpStackTrace, nullptr); \
- SK_CRASH(); \
- } while (false)
-# elif defined(SK_DEBUG)
-# define SK_ALWAYSBREAK(cond) do { \
- if (cond) break; \
- SkNO_RETURN_HINT(); \
- SkDebugf("%s:%d: failed assertion \"%s\"\n", __FILE__, __LINE__, #cond); \
- SK_CRASH(); \
- } while (false)
-# else
-# define SK_ALWAYSBREAK(cond) do { if (cond) break; SK_CRASH(); } while (false)
-# endif
+#ifndef SK_ABORT
+# define SK_ABORT(msg) \
+ do { \
+ SkNO_RETURN_HINT(); \
+ SkDebugf("%s:%d: fatal error: \"%s\"\n", __FILE__, __LINE__, #msg); \
+ SK_DUMP_GOOGLE3_STACK(); \
+ sk_abort_no_print(); \
+ } while (false)
#endif
/**
diff --git a/include/core/SkTArray.h b/include/core/SkTArray.h
index 17cbc5c05c..bd255e3868 100644
--- a/include/core/SkTArray.h
+++ b/include/core/SkTArray.h
@@ -507,7 +507,7 @@ void* operator new(size_t, SkTArray<T, MEM_COPY>* array, int SkDEBUGCODE(atIndex
// exception.
template <typename T, bool MEM_COPY>
void operator delete(void*, SkTArray<T, MEM_COPY>* /*array*/, int /*atIndex*/) {
- SK_CRASH();
+ SK_ABORT("Invalid Operation");
}
// Constructs a new object as the last element of an SkTArray.
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index c112b0364f..0d31efc6cc 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -67,7 +67,7 @@ SK_API extern void sk_out_of_memory(void);
The platform implementation must not return, but should either throw
an exception or otherwise exit.
*/
-SK_API extern void sk_throw(void);
+SK_API extern void sk_abort_no_print(void);
enum {
SK_MALLOC_TEMP = 0x01, //!< hint to sk_malloc that the requested memory will be freed in the scope of the stack frame
@@ -128,8 +128,10 @@ inline void operator delete(void* p) {
SK_API void SkDebugf(const char format[], ...);
#endif
+#define SkASSERT_RELEASE(cond) if(!(cond)) { SK_ABORT(#cond); }
+
#ifdef SK_DEBUG
- #define SkASSERT(cond) SK_ALWAYSBREAK(cond)
+ #define SkASSERT(cond) SkASSERT_RELEASE(cond)
#define SkDEBUGFAIL(message) SkASSERT(false && message)
#define SkDEBUGFAILF(fmt, ...) SkASSERTF(false, fmt, ##__VA_ARGS__)
#define SkDEBUGCODE(code) code
@@ -150,7 +152,9 @@ inline void operator delete(void* p) {
#define SkAssertResult(cond) cond
#endif
-#define SkFAIL(message) SK_ALWAYSBREAK(false && message)
+// Legacy macro names for SK_ABORT
+#define SkFAIL(message) SK_ABORT(message)
+#define sk_throw() SK_ABORT("sk_throw")
// We want to evaluate cond only once, and inside the SkASSERT somewhere so we see its string form.
// So we use the comma operator to make an SkDebugf that always returns false: we'll evaluate cond,