297aaf97a3
Use the form SkDebugf("%s", arbitraryString) instead of SkDebugf(arbitraryString). Fixes the case where SkString::appendf-ing a string with "%%" and then printing the string with SkDebugf would cause uninitialized read and corrupted debug print. ninja -C out/Debug tools && valgrind --leak-check=full ./out/Debug/render_pictures --config gpu -w q -r ... ... ==7307== Conditional jump or move depends on uninitialised value(s) ==7307== at 0x6908475: __printf_fp (printf_fp.c:1180) ==7307== by 0x6904267: vfprintf (vfprintf.c:1629) ==7307== by 0x6906E53: buffered_vfprintf (vfprintf.c:2313) ==7307== by 0x690188D: vfprintf (vfprintf.c:1316) ==7307== by 0x67E8F5: SkDebugf(char const*, ...) (SkDebug_stdio.cpp:18) ==7307== by 0x7983F1: GrContext::printCacheStats() const (GrTest.cpp:54) ==7307== by 0x408ECF: tool_main(int, char**) (render_pictures_main.cpp:480) ==7307== by 0x40913E: main (render_pictures_main.cpp:511) ==7307== Budget: 2048 items 100663296 bytes Entry Count: current 652 (651 budgeted, 0 wrapped, 297 locked, 638 scratch 32 0.000000ull), high 652 Entry Bytes: current 51087658 (budgeted 49826658, 49 0.000000ull, 1261000 unbudgeted) high 51087658 (observe "ull" instead of "% full") (from mtklein) This CL is not editing public API. TBR=reed@google.com Review URL: https://codereview.chromium.org/943453002
95 lines
2.1 KiB
C++
95 lines
2.1 KiB
C++
|
|
/*
|
|
* Copyright 2013 Google, Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
|
|
#ifndef SkDebugUtils_DEFINED
|
|
#define SkDebugUtils_DEFINED
|
|
|
|
#include "SkTypes.h"
|
|
|
|
// These functions dump 0, 1, and 2d arrays of data in a format that's
|
|
// compatible with Mathematica for quick visualization
|
|
|
|
|
|
template<class T>
|
|
inline void SkDebugDumpMathematica( const T val ) {
|
|
SkDEBUGFAIL("Need to specialize SkDebugDumpMathematica for your type, sorry.");
|
|
}
|
|
|
|
template<class T>
|
|
inline void SkDebugDumpMathematica(const char *name, const T *array, int size) {
|
|
SkDebugf("%s", name);
|
|
SkDebugf(" = {");
|
|
for (int i=0 ; i < size ; i++) {
|
|
SkDebugDumpMathematica<T>(array[i]);
|
|
if (i != size-1) SkDebugf(", ");
|
|
}
|
|
SkDebugf("};\n");
|
|
}
|
|
|
|
template<class T>
|
|
inline void SkDebugDumpMathematica(const char *name, const T *array, int width, int height) {
|
|
SkDebugf("%s", name);
|
|
SkDebugf(" = {\n");
|
|
for (int i=0 ; i < height ; i++) {
|
|
SkDebugf(" {");
|
|
for (int j = 0 ; j < width ; j++) {
|
|
SkDebugDumpMathematica<T>(array[i*width + j]);
|
|
if (j != width-1) {
|
|
SkDebugf(", ");
|
|
}
|
|
}
|
|
SkDebugf("}");
|
|
if (i != height-1) {
|
|
SkDebugf(", \n");
|
|
}
|
|
}
|
|
SkDebugf("\n};\n");
|
|
}
|
|
|
|
template<class T>
|
|
inline void SkDebugDumpMathematica( const char *name, const T val ) {
|
|
SkDebugf("%s", name);
|
|
SkDebugf(" = ");
|
|
SkDebugDumpMathematica<T>(val);
|
|
SkDebugf(";\n");
|
|
}
|
|
|
|
template<>
|
|
inline void SkDebugDumpMathematica<uint8_t>( const uint8_t val ) {
|
|
SkDebugf("%u", val);
|
|
}
|
|
|
|
template<>
|
|
inline void SkDebugDumpMathematica<unsigned int>( const unsigned int val ) {
|
|
SkDebugf("%u", val);
|
|
}
|
|
|
|
template<>
|
|
inline void SkDebugDumpMathematica<int>( const int val ) {
|
|
SkDebugf("%d", val);
|
|
}
|
|
|
|
template<>
|
|
inline void SkDebugDumpMathematica<size_t>( const size_t val ) {
|
|
SkDebugf("%u", val);
|
|
}
|
|
|
|
template<>
|
|
void SkDebugDumpMathematica<const char *>( const char * val ) {
|
|
SkDebugf("%s", val);
|
|
}
|
|
|
|
template<>
|
|
inline void SkDebugDumpMathematica<float>( float val ) {
|
|
SkDebugf("%f", val);
|
|
}
|
|
|
|
|
|
#endif
|