aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bench/ChecksumBench.cpp2
-rw-r--r--bench/nanobench.cpp2
-rw-r--r--gm/textblob.cpp2
-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
-rw-r--r--src/core/SkPath.cpp2
-rw-r--r--src/core/SkRegionPriv.h2
-rw-r--r--src/device/xps/SkXPSDevice.cpp3
-rw-r--r--src/gpu/GrAllocator.h2
-rw-r--r--src/gpu/GrTRecorder.h2
-rw-r--r--src/pathops/SkPathOpsDebug.cpp4
-rw-r--r--src/ports/SkFontHost_win.cpp2
-rw-r--r--src/ports/SkFontMgr_fontconfig.cpp2
-rw-r--r--src/ports/SkFontMgr_win_dw.cpp2
-rw-r--r--src/ports/SkMemory_malloc.cpp3
-rw-r--r--src/ports/SkMemory_mozalloc.cpp5
-rw-r--r--src/ports/SkTypeface_win_dw.cpp2
-rw-r--r--src/ports/SkTypeface_win_dw.h2
-rw-r--r--tests/CachedDataTest.cpp2
-rw-r--r--tests/PathOpsCubicLineIntersectionIdeas.cpp20
-rw-r--r--tools/Stats.h2
-rw-r--r--tools/sk_tool_utils_font.cpp2
24 files changed, 78 insertions, 51 deletions
diff --git a/bench/ChecksumBench.cpp b/bench/ChecksumBench.cpp
index bac7bddc81..92e7da662f 100644
--- a/bench/ChecksumBench.cpp
+++ b/bench/ChecksumBench.cpp
@@ -45,7 +45,7 @@ protected:
case kSHA1_ChecksumType: return "compute_sha1";
case kMurmur3_ChecksumType: return "compute_murmur3";
- default: SK_ABORT("Invalid Type"); return "";
+ default: SK_CRASH(); return "";
}
}
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index b461a63ee9..4fc4044449 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -947,7 +947,7 @@ public:
log->configOption("clip",
SkStringPrintf("%d %d %d %d", fClip.fLeft, fClip.fTop,
fClip.fRight, fClip.fBottom).c_str());
- SkASSERT_RELEASE(fCurrentScale < fScales.count()); // debugging paranoia
+ SK_ALWAYSBREAK(fCurrentScale < fScales.count()); // debugging paranoia
log->configOption("scale", SkStringPrintf("%.2g", fScales[fCurrentScale]).c_str());
if (fCurrentUseMPD > 0) {
SkASSERT(1 == fCurrentUseMPD || 2 == fCurrentUseMPD);
diff --git a/gm/textblob.cpp b/gm/textblob.cpp
index 02f3c878a3..a38215653d 100644
--- a/gm/textblob.cpp
+++ b/gm/textblob.cpp
@@ -170,7 +170,7 @@ private:
memcpy(buf.pos, pos.begin(), count * sizeof(SkScalar) * 2);
} break;
default:
- SK_ABORT("unhandled pos value");
+ SkFAIL("unhandled pos value");
}
currentGlyph += count;
diff --git a/include/config/SkUserConfig.h b/include/config/SkUserConfig.h
index a0f6258281..ff8a5f3154 100644
--- a/include/config/SkUserConfig.h
+++ b/include/config/SkUserConfig.h
@@ -58,6 +58,13 @@
//#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 68354a6156..387ea5b154 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)
+#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
/**
diff --git a/include/core/SkTArray.h b/include/core/SkTArray.h
index bd255e3868..17cbc5c05c 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_ABORT("Invalid Operation");
+ SK_CRASH();
}
// Constructs a new object as the last element of an SkTArray.
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 0d31efc6cc..c112b0364f 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_abort_no_print(void);
+SK_API extern void sk_throw(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,10 +128,8 @@ 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) SkASSERT_RELEASE(cond)
+ #define SkASSERT(cond) SK_ALWAYSBREAK(cond)
#define SkDEBUGFAIL(message) SkASSERT(false && message)
#define SkDEBUGFAILF(fmt, ...) SkASSERTF(false, fmt, ##__VA_ARGS__)
#define SkDEBUGCODE(code) code
@@ -152,9 +150,7 @@ inline void operator delete(void* p) {
#define SkAssertResult(cond) cond
#endif
-// Legacy macro names for SK_ABORT
-#define SkFAIL(message) SK_ABORT(message)
-#define sk_throw() SK_ABORT("sk_throw")
+#define SkFAIL(message) SK_ALWAYSBREAK(false && message)
// 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,
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 33b7451424..c77a25b4aa 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -275,7 +275,7 @@ bool SkPath::conservativelyContainsRect(const SkRect& rect) const {
orig.set(pts, iter.conicWeight());
SkPoint quadPts[5];
int count = orig.chopIntoQuadsPOW2(quadPts, 1);
- SkASSERT_RELEASE(2 == count);
+ SK_ALWAYSBREAK(2 == count);
if (!check_edge_against_rect(quadPts[0], quadPts[2], rect, direction)) {
return false;
diff --git a/src/core/SkRegionPriv.h b/src/core/SkRegionPriv.h
index c9633c7ad6..160c55d555 100644
--- a/src/core/SkRegionPriv.h
+++ b/src/core/SkRegionPriv.h
@@ -66,7 +66,7 @@ public:
SkASSERT(count >= SkRegion::kRectRegionRuns);
const int64_t size = sk_64_mul(count, sizeof(RunType)) + sizeof(RunHead);
- if (count < 0 || !sk_64_isS32(size)) { SK_ABORT("Invalid Size"); }
+ if (count < 0 || !sk_64_isS32(size)) { SK_CRASH(); }
RunHead* head = (RunHead*)sk_malloc_throw(size);
head->fRefCnt = 1;
diff --git a/src/device/xps/SkXPSDevice.cpp b/src/device/xps/SkXPSDevice.cpp
index e4ac2aa742..48233bb554 100644
--- a/src/device/xps/SkXPSDevice.cpp
+++ b/src/device/xps/SkXPSDevice.cpp
@@ -2044,7 +2044,7 @@ static int num_glyph_guess(SkPaint::TextEncoding encoding, const void* text, siz
case SkPaint::kGlyphID_TextEncoding:
return SkToInt(byteLength / 2);
default:
- SK_ABORT("Invalid Text Encoding");
+ SK_ALWAYSBREAK(true);
}
return 0;
}
@@ -2254,6 +2254,7 @@ SkBaseDevice* SkXPSDevice::onCreateDevice(const CreateInfo& info, const SkPaint*
#if 0
if (SkBaseDevice::kGeneral_Usage == info.fUsage) {
return nullptr;
+ SK_CRASH();
//To what stream do we write?
//SkXPSDevice* dev = new SkXPSDevice(this);
//SkSize s = SkSize::Make(width, height);
diff --git a/src/gpu/GrAllocator.h b/src/gpu/GrAllocator.h
index 3305fb00c2..c5d2dc3d38 100644
--- a/src/gpu/GrAllocator.h
+++ b/src/gpu/GrAllocator.h
@@ -389,7 +389,7 @@ template <typename T> void* operator new(size_t size, GrTAllocator<T>* allocator
// to match the op new silences warnings about missing op delete when a constructor throws an
// exception.
template <typename T> void operator delete(void*, GrTAllocator<T>*) {
- SK_ABORT("Invalid Operation");
+ SK_CRASH();
}
#define GrNEW_APPEND_TO_ALLOCATOR(allocator_ptr, type_name, args) \
diff --git a/src/gpu/GrTRecorder.h b/src/gpu/GrTRecorder.h
index c42d9e9751..a838ad2955 100644
--- a/src/gpu/GrTRecorder.h
+++ b/src/gpu/GrTRecorder.h
@@ -378,7 +378,7 @@ template <typename TBase, typename TAlign, typename TItem>
void operator delete(void*, GrTRecorder<TBase, TAlign>&, const GrTRecorderAllocWrapper<TItem>&) {
// We only provide an operator delete to work around compiler warnings that can come
// up for an unmatched operator new when compiling with exceptions.
- SK_ABORT("Invalid Operation");
+ SK_CRASH();
}
#define GrNEW_APPEND_TO_RECORDER(recorder, type_name, args) \
diff --git a/src/pathops/SkPathOpsDebug.cpp b/src/pathops/SkPathOpsDebug.cpp
index 546771e84c..6dd9edd64e 100644
--- a/src/pathops/SkPathOpsDebug.cpp
+++ b/src/pathops/SkPathOpsDebug.cpp
@@ -1094,13 +1094,13 @@ void SkOpAngle::debugValidateNext() const {
const SkOpAngle* next = first;
SkTDArray<const SkOpAngle*>(angles);
do {
-// SkASSERT_RELEASE(next->fSegment->debugContains(next));
+// SK_ALWAYSBREAK(next->fSegment->debugContains(next));
angles.push(next);
next = next->next();
if (next == first) {
break;
}
- SkASSERT_RELEASE(!angles.contains(next));
+ SK_ALWAYSBREAK(!angles.contains(next));
if (!next) {
return;
}
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index 10476ad434..2e03a44578 100644
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -2176,7 +2176,7 @@ int LogFontTypeface::onCharsToGlyphs(const void* chars, Encoding encoding,
break;
}
default:
- SK_ABORT("Invalid Text Encoding");
+ SK_CRASH();
}
if (sc) {
diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp
index bd6a5a2a2a..6a40e5080d 100644
--- a/src/ports/SkFontMgr_fontconfig.cpp
+++ b/src/ports/SkFontMgr_fontconfig.cpp
@@ -113,7 +113,7 @@ template <typename T, T* (*C)(), void (*D)(T*)> class SkAutoFc
public:
SkAutoFc() : SkAutoTCallVProc<T, FcTDestroy<T, D> >(C()) {
T* obj = this->operator T*();
- SkASSERT_RELEASE(nullptr != obj);
+ SK_ALWAYSBREAK(nullptr != obj);
}
explicit SkAutoFc(T* obj) : SkAutoTCallVProc<T, FcTDestroy<T, D> >(obj) {}
};
diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp
index ef09210e38..585d809406 100644
--- a/src/ports/SkFontMgr_win_dw.cpp
+++ b/src/ports/SkFontMgr_win_dw.cpp
@@ -273,7 +273,7 @@ public:
if (!SUCCEEDED(fFactory->QueryInterface(&fFactory2))) {
// IUnknown::QueryInterface states that if it fails, punk will be set to nullptr.
// http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx
- SkASSERT_RELEASE(nullptr == fFactory2.get());
+ SK_ALWAYSBREAK(nullptr == fFactory2.get());
}
#endif
memcpy(fLocaleName.get(), localeName, localeNameLength * sizeof(WCHAR));
diff --git a/src/ports/SkMemory_malloc.cpp b/src/ports/SkMemory_malloc.cpp
index 008352ec4a..6ad01daca0 100644
--- a/src/ports/SkMemory_malloc.cpp
+++ b/src/ports/SkMemory_malloc.cpp
@@ -26,7 +26,8 @@ static inline void* throw_on_failure(size_t size, void* p) {
return p;
}
-void sk_abort_no_print() {
+void sk_throw() {
+ SkDEBUGFAIL("sk_throw");
abort();
}
diff --git a/src/ports/SkMemory_mozalloc.cpp b/src/ports/SkMemory_mozalloc.cpp
index f8a996307e..f070085893 100644
--- a/src/ports/SkMemory_mozalloc.cpp
+++ b/src/ports/SkMemory_mozalloc.cpp
@@ -12,8 +12,9 @@
#include "mozilla/mozalloc_abort.h"
#include "mozilla/mozalloc_oom.h"
-void sk_abort_no_print() {
- mozalloc_abort("Abort from sk_abort");
+void sk_throw() {
+ SkDEBUGFAIL("sk_throw");
+ mozalloc_abort("Abort from sk_throw");
}
void sk_out_of_memory(void) {
diff --git a/src/ports/SkTypeface_win_dw.cpp b/src/ports/SkTypeface_win_dw.cpp
index 160c66ed0e..38d09e85ec 100644
--- a/src/ports/SkTypeface_win_dw.cpp
+++ b/src/ports/SkTypeface_win_dw.cpp
@@ -111,7 +111,7 @@ int DWriteFontTypeface::onCharsToGlyphs(const void* chars, Encoding encoding,
break;
}
default:
- SK_ABORT("Invalid Text Encoding");
+ SK_CRASH();
}
for (int i = 0; i < glyphCount; ++i) {
diff --git a/src/ports/SkTypeface_win_dw.h b/src/ports/SkTypeface_win_dw.h
index cdbeeaa785..3d6fce0a32 100644
--- a/src/ports/SkTypeface_win_dw.h
+++ b/src/ports/SkTypeface_win_dw.h
@@ -55,7 +55,7 @@ private:
if (!SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace1))) {
// IUnknown::QueryInterface states that if it fails, punk will be set to nullptr.
// http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx
- SkASSERT_RELEASE(nullptr == fDWriteFontFace1.get());
+ SK_ALWAYSBREAK(nullptr == fDWriteFontFace1.get());
}
#endif
}
diff --git a/tests/CachedDataTest.cpp b/tests/CachedDataTest.cpp
index 6c44161707..c3fc9a47bf 100644
--- a/tests/CachedDataTest.cpp
+++ b/tests/CachedDataTest.cpp
@@ -30,7 +30,7 @@ static SkCachedData* make_data(size_t size, SkDiscardableMemoryPool* pool) {
if (pool) {
SkDiscardableMemory* dm = pool->create(size);
// the pool "can" return null, but it shouldn't in these controlled conditions
- SkASSERT_RELEASE(dm);
+ SK_ALWAYSBREAK(dm);
return new SkCachedData(size, dm);
} else {
return new SkCachedData(sk_malloc_throw(size), size);
diff --git a/tests/PathOpsCubicLineIntersectionIdeas.cpp b/tests/PathOpsCubicLineIntersectionIdeas.cpp
index b23dd0ceaf..6aec8b148a 100644
--- a/tests/PathOpsCubicLineIntersectionIdeas.cpp
+++ b/tests/PathOpsCubicLineIntersectionIdeas.cpp
@@ -194,13 +194,13 @@ DEF_TEST(PathOpsCubicLineRoots, reporter) {
if (realRoots == 3) {
smallest = SkTMin(smallest, allRoots[2]);
}
- SkASSERT_RELEASE(smallest < 0);
- SkASSERT_RELEASE(smallest >= -1);
+ SK_ALWAYSBREAK(smallest < 0);
+ SK_ALWAYSBREAK(smallest >= -1);
largeBits = 0;
} else {
frexp(largest, &largeBits);
- SkASSERT_RELEASE(largeBits >= 0);
- SkASSERT_RELEASE(largeBits < 256);
+ SK_ALWAYSBREAK(largeBits >= 0);
+ SK_ALWAYSBREAK(largeBits < 256);
}
double step = 1e-6;
if (largeBits > 21) {
@@ -222,7 +222,7 @@ DEF_TEST(PathOpsCubicLineRoots, reporter) {
break;
}
step *= 1.5;
- SkASSERT_RELEASE(step < 1);
+ SK_ALWAYSBREAK(step < 1);
} while (true);
worstStep[largeBits] = SkTMax(worstStep[largeBits], diff);
#if 0
@@ -256,11 +256,11 @@ static double testOneFailure(const CubicLineFailures& failure) {
double allRoots[3] = {0}, validRoots[3] = {0};
int realRoots = SkDCubic::RootsReal(A, B, C, D, allRoots);
int valid = SkDQuad::AddValidTs(allRoots, realRoots, validRoots);
- SkASSERT_RELEASE(valid == 1);
- SkASSERT_RELEASE(realRoots != 1);
+ SK_ALWAYSBREAK(valid == 1);
+ SK_ALWAYSBREAK(realRoots != 1);
double t = validRoots[0];
SkDPoint calcPt = cubic.ptAtT(t);
- SkASSERT_RELEASE(!calcPt.approximatelyEqual(pt));
+ SK_ALWAYSBREAK(!calcPt.approximatelyEqual(pt));
int iters = 0;
double newT = binary_search(cubic, 0.1, pt, t, &iters);
return newT;
@@ -271,7 +271,7 @@ DEF_TEST(PathOpsCubicLineFailures, reporter) {
for (int index = 0; index < cubicLineFailuresCount; ++index) {
const CubicLineFailures& failure = cubicLineFailures[index];
double newT = testOneFailure(failure);
- SkASSERT_RELEASE(newT >= 0);
+ SK_ALWAYSBREAK(newT >= 0);
}
}
@@ -279,5 +279,5 @@ DEF_TEST(PathOpsCubicLineOneFailure, reporter) {
return; // disable for now
const CubicLineFailures& failure = cubicLineFailures[1];
double newT = testOneFailure(failure);
- SkASSERT_RELEASE(newT >= 0);
+ SK_ALWAYSBREAK(newT >= 0);
}
diff --git a/tools/Stats.h b/tools/Stats.h
index 557a2a51a2..12c1d35e1f 100644
--- a/tools/Stats.h
+++ b/tools/Stats.h
@@ -62,7 +62,7 @@ struct Stats {
s /= (max - min);
s *= (SK_ARRAY_COUNT(kBars) - 1);
const size_t bar = (size_t)(s + 0.5);
- SkASSERT_RELEASE(bar < SK_ARRAY_COUNT(kBars));
+ SK_ALWAYSBREAK(bar < SK_ARRAY_COUNT(kBars));
plot.append(kBars[bar]);
}
}
diff --git a/tools/sk_tool_utils_font.cpp b/tools/sk_tool_utils_font.cpp
index 0f8c96f617..af52b37a4e 100644
--- a/tools/sk_tool_utils_font.cpp
+++ b/tools/sk_tool_utils_font.cpp
@@ -42,7 +42,7 @@ SkTypeface* create_font(const char* name, SkTypeface::Style style) {
}
if (!fontData) {
// Once all legacy callers to portable fonts are converted, replace this with
- // SK_ABORT();
+ // SK_CRASH();
SkDebugf("missing %s %d\n", name, style);
// If we called SkTypeface::CreateFromName() here we'd recurse infinitely,
// so we reimplement its core logic here inline without the recursive aspect.