Bug 1287392 - Part 2: Ignore obsolete TaskTracer data and fix vptr. r=cyu

--HG--
extra : rebase_source : fb2b5db63207e4afda3751e10797bdd07d791abf
This commit is contained in:
Thinker K.F. Li 2016-11-10 07:58:00 -05:00
parent 9f1f17b5dc
commit 6690ec87fe
2 changed files with 20 additions and 9 deletions

View File

@ -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> traceinfo(aTraceInfo);
sTraceInfos->RemoveElement(traceinfo);
mozilla::DebugOnly<bool> 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;

View File

@ -95,7 +95,7 @@ TracedRunnable::TracedRunnable(already_AddRefed<nsIRunnable>&& aOriginalObj)
, mOriginalObj(Move(aOriginalObj))
{
Init();
LogVirtualTablePtr(mTaskId, mSourceEventId, reinterpret_cast<uintptr_t*>(mOriginalObj.get()));
LogVirtualTablePtr(mTaskId, mSourceEventId, *reinterpret_cast<uintptr_t**>(mOriginalObj.get()));
}
TracedRunnable::~TracedRunnable()