aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/trace/SkDebugfTracer.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-07-21 15:30:14 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-21 20:57:27 +0000
commitde6e5bf33f6083842ffb0cd63c6578d1f9f23983 (patch)
tree72c35e7f426c99799499e942dc4689a2488b7bef /tools/trace/SkDebugfTracer.cpp
parentaaa3056e46ed9004097dc784db94c3a97d070569 (diff)
Tracing cleanup and bugfixes
TraceID was unused, remove it. Simplify casting logic by using the same union helper as the macros. This fixes a bug that was present in the bool handling - we were treating the union value as a pointer, so we were dereferencing random stack memory. Luckily it never crashes, we did get the wrong values for bools. Bug: skia: Change-Id: I15d44756214f34c1f6479980d9a487ac7f3d8f6c Reviewed-on: https://skia-review.googlesource.com/25801 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tools/trace/SkDebugfTracer.cpp')
-rw-r--r--tools/trace/SkDebugfTracer.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/tools/trace/SkDebugfTracer.cpp b/tools/trace/SkDebugfTracer.cpp
index fe0da30b84..d694b8ce9a 100644
--- a/tools/trace/SkDebugfTracer.cpp
+++ b/tools/trace/SkDebugfTracer.cpp
@@ -24,11 +24,11 @@ SkEventTracer::Handle SkDebugfTracer::addTraceEvent(char phase,
} else {
args.append(" ");
}
+ skia::tracing_internals::TraceValueUnion value;
+ value.as_uint = argValues[i];
switch (argTypes[i]) {
case TRACE_VALUE_TYPE_BOOL:
- args.appendf("%s=%s",
- argNames[i],
- (*reinterpret_cast<bool*>(argValues[i]) ? "true" : "false"));
+ args.appendf("%s=%s", argNames[i], value.as_bool ? "true" : "false");
break;
case TRACE_VALUE_TYPE_UINT:
args.appendf("%s=%u", argNames[i], static_cast<uint32_t>(argValues[i]));
@@ -37,16 +37,15 @@ SkEventTracer::Handle SkDebugfTracer::addTraceEvent(char phase,
args.appendf("%s=%d", argNames[i], static_cast<int32_t>(argValues[i]));
break;
case TRACE_VALUE_TYPE_DOUBLE:
- args.appendf("%s=%g", argNames[i], *SkTCast<const double*>(&argValues[i]));
+ args.appendf("%s=%g", argNames[i], value.as_double);
break;
case TRACE_VALUE_TYPE_POINTER:
- args.appendf("%s=0x%p", argNames[i], reinterpret_cast<void*>(argValues[i]));
+ args.appendf("%s=0x%p", argNames[i], value.as_pointer);
break;
case TRACE_VALUE_TYPE_STRING:
case TRACE_VALUE_TYPE_COPY_STRING: {
static constexpr size_t kMaxLen = 20;
- const char* str = reinterpret_cast<const char*>(argValues[i]);
- SkString string(str);
+ SkString string(value.as_string);
size_t truncAt = string.size();
size_t newLineAt = SkStrFind(string.c_str(), "\n");
if (newLineAt > 0) {