From 90bdeea89061321b868b5a75e0d6f11232f940a6 Mon Sep 17 00:00:00 2001 From: "Thinker K.F. Li" Date: Thu, 10 Nov 2016 07:58:00 +0100 Subject: [PATCH] Bug 1287392 - Part 2: Ignore obsolete TaskTracer data and fix vptr. r=cyu --- tools/profiler/tasktracer/GeckoTaskTracer.cpp | 27 +++++++++++++------ .../profiler/tasktracer/TracedTaskCommon.cpp | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/tools/profiler/tasktracer/GeckoTaskTracer.cpp b/tools/profiler/tasktracer/GeckoTaskTracer.cpp index 202aab72580c..e5f8b4cb6cb4 100644 --- a/tools/profiler/tasktracer/GeckoTaskTracer.cpp +++ b/tools/profiler/tasktracer/GeckoTaskTracer.cpp @@ -39,6 +39,11 @@ namespace mozilla { namespace tasktracer { +#define SOURCE_EVENT_NAME(type) \ + const char* CreateSourceEvent##type () { return "SourceEvent" #type; } +#include "SourceEventTypeMap.h" +#undef SOURCE_EVENT_NAME + static MOZ_THREAD_LOCAL(TraceInfo*) sTraceInfoTLS; static mozilla::StaticMutex sMutex; @@ -105,12 +110,11 @@ CreateSourceEvent(SourceEventType aType) info->mCurTraceSourceType = aType; info->mCurTaskId = newId; - uintptr_t* namePtr; + uintptr_t namePtr; #define SOURCE_EVENT_NAME(type) \ case SourceEventType::type: \ { \ - static int CreateSourceEvent##type; \ - namePtr = (uintptr_t*)&CreateSourceEvent##type; \ + namePtr = (uintptr_t)&CreateSourceEvent##type; \ break; \ } @@ -119,11 +123,11 @@ CreateSourceEvent(SourceEventType aType) default: MOZ_CRASH("Unknown SourceEvent."); } -#undef CREATE_SOURCE_EVENT_NAME +#undef SOURCE_EVENT_NAME // Log a fake dispatch and start for this source event. LogDispatch(newId, newId, newId, aType); - LogVirtualTablePtr(newId, newId, namePtr); + LogVirtualTablePtr(newId, newId, &namePtr); LogBegin(newId, newId); } @@ -224,7 +228,9 @@ FreeTraceInfo(TraceInfo* aTraceInfo) StaticMutexAutoLock lock(sMutex); if (aTraceInfo) { UniquePtr traceinfo(aTraceInfo); - sTraceInfos->RemoveElement(traceinfo); + mozilla::DebugOnly removed = + sTraceInfos->RemoveElement(traceinfo); + MOZ_ASSERT(removed); Unused << traceinfo.release(); // A dirty hack to prevent double free. } } @@ -368,7 +374,10 @@ LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, uintptr_t* aVptr) // [4 taskId address] nsCString* log = info->AppendLog(); if (log) { - log->AppendPrintf("%d %lld %p", ACTION_GET_VTABLE, aTaskId, aVptr); + // Since addr2line used by SPS addon can not solve non-function + // addresses, we use the first entry of vtable as the symbol to + // solve. We should find a better solution later. + log->AppendPrintf("%d %lld %p", ACTION_GET_VTABLE, aTaskId, *aVptr); } } @@ -426,7 +435,9 @@ GetLoggedData(TimeStamp aTimeStamp) StaticMutexAutoLock lock(sMutex); for (uint32_t i = 0; i < sTraceInfos->Length(); ++i) { - (*sTraceInfos)[i]->MoveLogsInto(*result); + if (!(*sTraceInfos)[i]->mObsolete) { + (*sTraceInfos)[i]->MoveLogsInto(*result); + } } return result; diff --git a/tools/profiler/tasktracer/TracedTaskCommon.cpp b/tools/profiler/tasktracer/TracedTaskCommon.cpp index c94183e00e41..fc2349b995ea 100644 --- a/tools/profiler/tasktracer/TracedTaskCommon.cpp +++ b/tools/profiler/tasktracer/TracedTaskCommon.cpp @@ -95,7 +95,7 @@ TracedRunnable::TracedRunnable(already_AddRefed&& aOriginalObj) , mOriginalObj(Move(aOriginalObj)) { Init(); - LogVirtualTablePtr(mTaskId, mSourceEventId, reinterpret_cast(mOriginalObj.get())); + LogVirtualTablePtr(mTaskId, mSourceEventId, *reinterpret_cast(mOriginalObj.get())); } TracedRunnable::~TracedRunnable()