Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Unified Diff: include/core/SkPostConfig.h

Issue 1620333002: Revert of Consolidate SK_CRASH and sk_throw into SK_ABORT (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/config/SkUserConfig.h ('k') | include/core/SkTArray.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
/**
« no previous file with comments | « include/config/SkUserConfig.h ('k') | include/core/SkTArray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698