Revert "Allow printf-style formatting to be used in SK_ABORT."
This reverts commit 67e50a6b5c
.
Reason for revert: roller complains about LICENSE issue. cl/314177415
Original change's description:
> Allow printf-style formatting to be used in SK_ABORT.
>
> SK_ABORT was already using SkDebugf to print the error message to the
> console, so all the moving parts were there. This CL just adds a
> mechanism for the calling code to pass in arguments.
>
> Added a use case to demonstrate usage--when an allocation fails, the
> requested size is now shown in the error message.
>
> Change-Id: I42f141151fb57a399c086926249816833f349ddb
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293272
> Reviewed-by: Ben Wagner <bungeman@google.com>
> Reviewed-by: Herb Derby <herb@google.com>
> Commit-Queue: Ben Wagner <bungeman@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>
> Commit-Queue: Herb Derby <herb@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
TBR=djsollen@google.com,bungeman@google.com,herb@google.com,johnstiles@google.com
Change-Id: I7a2e98bcda82bbe6edfa3d00057586754df0ee71
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293342
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
67e50a6b5c
commit
7a8e394496
@ -61,8 +61,9 @@ public:
|
||||
void* makeVertexSpace(size_t vertexSize, int vertexCount, sk_sp<const GrBuffer>*,
|
||||
int* startVertex) override {
|
||||
if (vertexSize * vertexCount > sizeof(fStaticVertexData)) {
|
||||
SK_ABORT("FATAL: wanted %zu bytes of static vertex data; only have %zu.\n",
|
||||
vertexSize * vertexCount, SK_ARRAY_COUNT(fStaticVertexData));
|
||||
SK_ABORT(SkStringPrintf(
|
||||
"FATAL: wanted %zu bytes of static vertex data; only have %zu.\n",
|
||||
vertexSize * vertexCount, SK_ARRAY_COUNT(fStaticVertexData)).c_str());
|
||||
}
|
||||
*startVertex = 0;
|
||||
return fStaticVertexData;
|
||||
@ -72,8 +73,9 @@ public:
|
||||
int drawCount, sk_sp<const GrBuffer>* buffer, size_t* offsetInBytes) override {
|
||||
int staticBufferCount = (int)SK_ARRAY_COUNT(fStaticDrawIndexedIndirectData);
|
||||
if (drawCount > staticBufferCount) {
|
||||
SK_ABORT("FATAL: wanted %i static drawIndexedIndirect elements; only have %i.\n",
|
||||
drawCount, staticBufferCount);
|
||||
SK_ABORT(SkStringPrintf(
|
||||
"FATAL: wanted %i static drawIndexedIndirect elements; only have %i.\n",
|
||||
drawCount, staticBufferCount).c_str());
|
||||
}
|
||||
return fStaticDrawIndexedIndirectData;
|
||||
}
|
||||
|
@ -285,20 +285,22 @@
|
||||
# define SK_DUMP_GOOGLE3_STACK()
|
||||
#endif
|
||||
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
// Lets visual studio follow error back to source
|
||||
#define SK_DUMP_LINE_FORMAT(message) \
|
||||
SkDebugf("%s(%d): fatal error: \"%s\"\n", __FILE__, __LINE__, message)
|
||||
#else
|
||||
#define SK_DUMP_LINE_FORMAT(message) \
|
||||
SkDebugf("%s:%d: fatal error: \"%s\"\n", __FILE__, __LINE__, message)
|
||||
#endif
|
||||
|
||||
#ifndef SK_ABORT
|
||||
# ifdef SK_BUILD_FOR_WIN
|
||||
// This style lets Visual Studio follow errors back to the source file.
|
||||
# define SK_DUMP_LINE_FORMAT "%s(%d)"
|
||||
# else
|
||||
# define SK_DUMP_LINE_FORMAT "%s:%d"
|
||||
# endif
|
||||
# define SK_ABORT(message, ...) \
|
||||
# define SK_ABORT(message) \
|
||||
do { \
|
||||
SkDebugf(SK_DUMP_LINE_FORMAT ": fatal error: \"" message "\"\n", \
|
||||
__FILE__, __LINE__, ##__VA_ARGS__); \
|
||||
SK_DUMP_GOOGLE3_STACK(); \
|
||||
sk_abort_no_print(); \
|
||||
SkUNREACHABLE; \
|
||||
SK_DUMP_LINE_FORMAT(message); \
|
||||
SK_DUMP_GOOGLE3_STACK(); \
|
||||
sk_abort_no_print(); \
|
||||
SkUNREACHABLE; \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
@ -463,7 +465,7 @@ SK_API extern void sk_abort_no_print(void);
|
||||
SK_ABORT("assert(" #cond ")"); \
|
||||
}() )
|
||||
#define SkDEBUGFAIL(message) SK_ABORT(message)
|
||||
#define SkDEBUGFAILF(fmt, ...) SK_ABORT(fmt, ##__VA_ARGS__)
|
||||
#define SkDEBUGFAILF(fmt, ...) SkASSERTF(false, fmt, ##__VA_ARGS__)
|
||||
#define SkDEBUGCODE(...) __VA_ARGS__
|
||||
#define SkDEBUGF(...) SkDebugf(__VA_ARGS__)
|
||||
#define SkAssertResult(cond) SkASSERT(cond)
|
||||
|
@ -37,7 +37,9 @@ static jmethodID gInputStream_skipMethodID;
|
||||
static JNIEnv* get_env_or_die(JavaVM* jvm) {
|
||||
JNIEnv* env;
|
||||
if (jvm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
||||
SK_ABORT("Failed to get JNIEnv for JavaVM: %p", jvm);
|
||||
char errorMessage[256];
|
||||
sprintf(errorMessage, "Failed to get JNIEnv for JavaVM: %p", jvm);
|
||||
SK_ABORT(errorMessage);
|
||||
}
|
||||
return env;
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ GrBlockAllocator::ByteRange GrBlockAllocator::allocate(size_t size) {
|
||||
<= std::numeric_limits<int32_t>::max());
|
||||
|
||||
if (size > kMaxAllocationSize) {
|
||||
SK_ABORT("Allocation too large (%zu bytes requested)", size);
|
||||
SK_ABORT("Allocation too large");
|
||||
}
|
||||
|
||||
int iSize = (int) size;
|
||||
|
@ -60,7 +60,7 @@ static GpuPathRenderers get_named_pathrenderers_flags(const char* name) {
|
||||
} else if (!strcmp(name, "default")) {
|
||||
return GpuPathRenderers::kDefault;
|
||||
}
|
||||
SK_ABORT("error: unknown named path renderer \"%s\"\n", name);
|
||||
SK_ABORT(SkStringPrintf("error: unknown named path renderer \"%s\"\n", name).c_str());
|
||||
}
|
||||
|
||||
static GpuPathRenderers collect_gpu_path_renderers_from_flags() {
|
||||
|
@ -573,7 +573,7 @@ int main(int argc, char** argv) {
|
||||
case Result::Ok: break;
|
||||
case Result::Skip: return false;
|
||||
case Result::Fail:
|
||||
SK_ABORT("%s", result.failure.c_str());
|
||||
SK_ABORT(result.failure.c_str());
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user