Index: include/core/SkPostConfig.h |
diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h |
index 68354a6156f974470d0dad645de8484fbc802205..387ea5b15479203e3f17ae2f124a0b3b399331d1 100644 |
--- a/include/core/SkPostConfig.h |
+++ b/include/core/SkPostConfig.h |
@@ -103,6 +103,17 @@ |
// 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 |
/////////////////////////////////////////////////////////////////////////////// |
@@ -137,21 +148,31 @@ |
#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_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 |
+ |
+#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 |
#endif |
/** |