2014-03-27 08:44:30 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "GeckoTaskTracer.h"
|
|
|
|
#include "GeckoTaskTracerImpl.h"
|
|
|
|
|
2014-12-22 06:57:12 +00:00
|
|
|
#include "mozilla/MathAlgorithms.h"
|
2014-03-27 08:44:30 +00:00
|
|
|
#include "mozilla/StaticMutex.h"
|
|
|
|
#include "mozilla/ThreadLocal.h"
|
2014-11-28 09:27:09 +00:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2014-03-27 08:44:30 +00:00
|
|
|
#include "mozilla/unused.h"
|
|
|
|
|
2014-10-14 02:47:59 +00:00
|
|
|
#include "nsString.h"
|
2014-03-27 08:44:30 +00:00
|
|
|
#include "nsThreadUtils.h"
|
2014-10-14 02:47:59 +00:00
|
|
|
#include "prtime.h"
|
2014-03-27 08:44:30 +00:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#if defined(__GLIBC__)
|
|
|
|
// glibc doesn't implement gettid(2).
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
static pid_t gettid()
|
|
|
|
{
|
|
|
|
return (pid_t) syscall(SYS_gettid);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-12-22 06:57:12 +00:00
|
|
|
// NS_ENSURE_TRUE_VOID() without the warning on the debug build.
|
|
|
|
#define ENSURE_TRUE_VOID(x) \
|
|
|
|
do { \
|
|
|
|
if (MOZ_UNLIKELY(!(x))) { \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
// NS_ENSURE_TRUE() without the warning on the debug build.
|
|
|
|
#define ENSURE_TRUE(x, ret) \
|
|
|
|
do { \
|
|
|
|
if (MOZ_UNLIKELY(!(x))) { \
|
|
|
|
return ret; \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
2014-03-27 08:44:30 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace tasktracer {
|
|
|
|
|
2014-12-22 06:57:12 +00:00
|
|
|
static mozilla::ThreadLocal<TraceInfo*> sTraceInfoTLS;
|
2014-10-14 02:47:59 +00:00
|
|
|
static mozilla::StaticMutex sMutex;
|
2014-12-22 06:57:12 +00:00
|
|
|
|
|
|
|
// The generation of TraceInfo. It will be > 0 if the Task Tracer is started and
|
|
|
|
// <= 0 if stopped.
|
|
|
|
static mozilla::Atomic<bool> sStarted;
|
2014-10-14 02:47:59 +00:00
|
|
|
static nsTArray<nsAutoPtr<TraceInfo>>* sTraceInfos = nullptr;
|
2014-11-28 09:27:09 +00:00
|
|
|
static PRTime sStartTime;
|
2014-03-27 08:44:30 +00:00
|
|
|
|
2014-11-20 02:57:27 +00:00
|
|
|
static const char sJSLabelPrefix[] = "#tt#";
|
2014-10-17 09:33:03 +00:00
|
|
|
|
2014-03-27 08:44:30 +00:00
|
|
|
namespace {
|
|
|
|
|
2014-11-28 09:27:09 +00:00
|
|
|
static PRTime
|
|
|
|
GetTimestamp()
|
|
|
|
{
|
|
|
|
return PR_Now() / 1000;
|
|
|
|
}
|
|
|
|
|
2014-03-27 08:44:30 +00:00
|
|
|
static TraceInfo*
|
|
|
|
AllocTraceInfo(int aTid)
|
|
|
|
{
|
|
|
|
StaticMutexAutoLock lock(sMutex);
|
|
|
|
|
2014-10-14 02:47:59 +00:00
|
|
|
nsAutoPtr<TraceInfo>* info = sTraceInfos->AppendElement(
|
2014-12-22 06:57:12 +00:00
|
|
|
new TraceInfo(aTid));
|
2014-03-27 08:44:30 +00:00
|
|
|
|
2014-10-14 02:47:59 +00:00
|
|
|
return info->get();
|
2014-03-27 08:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
SaveCurTraceInfo()
|
|
|
|
{
|
|
|
|
TraceInfo* info = GetOrCreateTraceInfo();
|
2014-12-22 06:57:12 +00:00
|
|
|
ENSURE_TRUE_VOID(info);
|
2014-03-27 08:44:30 +00:00
|
|
|
|
|
|
|
info->mSavedCurTraceSourceId = info->mCurTraceSourceId;
|
|
|
|
info->mSavedCurTraceSourceType = info->mCurTraceSourceType;
|
|
|
|
info->mSavedCurTaskId = info->mCurTaskId;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
RestoreCurTraceInfo()
|
|
|
|
{
|
|
|
|
TraceInfo* info = GetOrCreateTraceInfo();
|
2014-12-22 06:57:12 +00:00
|
|
|
ENSURE_TRUE_VOID(info);
|
2014-03-27 08:44:30 +00:00
|
|
|
|
|
|
|
info->mCurTraceSourceId = info->mSavedCurTraceSourceId;
|
|
|
|
info->mCurTraceSourceType = info->mSavedCurTraceSourceType;
|
|
|
|
info->mCurTaskId = info->mSavedCurTaskId;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CreateSourceEvent(SourceEventType aType)
|
|
|
|
{
|
|
|
|
// Save the currently traced source event info.
|
|
|
|
SaveCurTraceInfo();
|
|
|
|
|
|
|
|
// Create a new unique task id.
|
|
|
|
uint64_t newId = GenNewUniqueTaskId();
|
|
|
|
TraceInfo* info = GetOrCreateTraceInfo();
|
2014-12-22 06:57:12 +00:00
|
|
|
ENSURE_TRUE_VOID(info);
|
|
|
|
|
2014-03-27 08:44:30 +00:00
|
|
|
info->mCurTraceSourceId = newId;
|
|
|
|
info->mCurTraceSourceType = aType;
|
|
|
|
info->mCurTaskId = newId;
|
|
|
|
|
2014-11-24 01:47:13 +00:00
|
|
|
int* namePtr;
|
|
|
|
#define SOURCE_EVENT_NAME(type) \
|
|
|
|
case SourceEventType::type: \
|
|
|
|
{ \
|
|
|
|
static int CreateSourceEvent##type; \
|
|
|
|
namePtr = &CreateSourceEvent##type; \
|
|
|
|
break; \
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aType) {
|
|
|
|
#include "SourceEventTypeMap.h"
|
|
|
|
default:
|
2014-12-22 02:04:44 +00:00
|
|
|
MOZ_CRASH("Unknown SourceEvent.");
|
2014-11-24 01:47:13 +00:00
|
|
|
};
|
|
|
|
#undef CREATE_SOURCE_EVENT_NAME
|
|
|
|
|
2014-03-27 08:44:30 +00:00
|
|
|
// Log a fake dispatch and start for this source event.
|
2014-11-24 01:47:13 +00:00
|
|
|
LogDispatch(newId, newId, newId, aType);
|
|
|
|
LogVirtualTablePtr(newId, newId, namePtr);
|
2014-03-27 08:44:30 +00:00
|
|
|
LogBegin(newId, newId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
DestroySourceEvent()
|
|
|
|
{
|
|
|
|
// Log a fake end for this source event.
|
|
|
|
TraceInfo* info = GetOrCreateTraceInfo();
|
2014-12-22 06:57:12 +00:00
|
|
|
ENSURE_TRUE_VOID(info);
|
|
|
|
|
2014-03-27 08:44:30 +00:00
|
|
|
LogEnd(info->mCurTraceSourceId, info->mCurTraceSourceId);
|
|
|
|
|
|
|
|
// Restore the previously saved source event info.
|
|
|
|
RestoreCurTraceInfo();
|
|
|
|
}
|
|
|
|
|
2014-12-22 06:57:12 +00:00
|
|
|
inline static bool
|
|
|
|
IsStartLogging()
|
2014-10-14 02:47:59 +00:00
|
|
|
{
|
2014-12-22 06:57:12 +00:00
|
|
|
return sStarted;
|
|
|
|
}
|
2014-10-14 02:47:59 +00:00
|
|
|
|
2014-12-22 06:57:12 +00:00
|
|
|
static void
|
|
|
|
SetLogStarted(bool aIsStartLogging)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aIsStartLogging != IsStartLogging());
|
|
|
|
sStarted = aIsStartLogging;
|
2014-10-14 02:47:59 +00:00
|
|
|
|
2014-12-22 06:57:12 +00:00
|
|
|
StaticMutexAutoLock lock(sMutex);
|
|
|
|
if (!aIsStartLogging) {
|
|
|
|
for (uint32_t i = 0; i < sTraceInfos->Length(); ++i) {
|
|
|
|
(*sTraceInfos)[i]->mObsolete = true;
|
|
|
|
}
|
2014-10-14 02:47:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-12-22 06:57:12 +00:00
|
|
|
CleanUp()
|
2014-10-14 02:47:59 +00:00
|
|
|
{
|
2014-12-22 06:57:12 +00:00
|
|
|
SetLogStarted(false);
|
2014-10-14 02:47:59 +00:00
|
|
|
StaticMutexAutoLock lock(sMutex);
|
|
|
|
|
2014-12-22 06:57:12 +00:00
|
|
|
if (sTraceInfos) {
|
|
|
|
delete sTraceInfos;
|
|
|
|
sTraceInfos = nullptr;
|
2014-10-14 02:47:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-22 06:57:12 +00:00
|
|
|
inline static void
|
|
|
|
ObsoleteCurrentTraceInfos()
|
2014-10-14 02:47:59 +00:00
|
|
|
{
|
2014-12-22 06:57:12 +00:00
|
|
|
// Note that we can't and don't need to acquire sMutex here because this
|
|
|
|
// function is called before the other threads are recreated.
|
|
|
|
for (uint32_t i = 0; i < sTraceInfos->Length(); ++i) {
|
|
|
|
(*sTraceInfos)[i]->mObsolete = true;
|
|
|
|
}
|
2014-10-14 02:47:59 +00:00
|
|
|
}
|
2014-03-27 08:44:30 +00:00
|
|
|
} // namespace anonymous
|
|
|
|
|
2014-10-14 02:47:59 +00:00
|
|
|
nsCString*
|
|
|
|
TraceInfo::AppendLog()
|
|
|
|
{
|
|
|
|
MutexAutoLock lock(mLogsMutex);
|
|
|
|
return mLogs.AppendElement();
|
|
|
|
}
|
|
|
|
|
2014-03-27 08:44:30 +00:00
|
|
|
void
|
2014-10-14 02:47:59 +00:00
|
|
|
TraceInfo::MoveLogsInto(TraceInfoLogsType& aResult)
|
2014-03-27 08:44:30 +00:00
|
|
|
{
|
2014-10-14 02:47:59 +00:00
|
|
|
MutexAutoLock lock(mLogsMutex);
|
|
|
|
aResult.MoveElementsFrom(mLogs);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
InitTaskTracer(uint32_t aFlags)
|
|
|
|
{
|
|
|
|
if (aFlags & FORKED_AFTER_NUWA) {
|
2014-12-22 06:57:12 +00:00
|
|
|
ObsoleteCurrentTraceInfos();
|
|
|
|
return;
|
2014-10-14 02:47:59 +00:00
|
|
|
}
|
2014-03-27 08:44:30 +00:00
|
|
|
|
2014-10-14 02:47:59 +00:00
|
|
|
MOZ_ASSERT(!sTraceInfos);
|
|
|
|
sTraceInfos = new nsTArray<nsAutoPtr<TraceInfo>>();
|
|
|
|
|
2014-12-22 06:57:12 +00:00
|
|
|
if (!sTraceInfoTLS.initialized()) {
|
|
|
|
unused << sTraceInfoTLS.init();
|
2014-03-27 08:44:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShutdownTaskTracer()
|
|
|
|
{
|
2014-10-14 02:47:59 +00:00
|
|
|
CleanUp();
|
2014-03-27 08:44:30 +00:00
|
|
|
}
|
|
|
|
|
2014-12-22 06:57:12 +00:00
|
|
|
static void
|
|
|
|
FreeTraceInfo(TraceInfo* aTraceInfo)
|
|
|
|
{
|
|
|
|
StaticMutexAutoLock lock(sMutex);
|
|
|
|
if (aTraceInfo) {
|
|
|
|
sTraceInfos->RemoveElement(aTraceInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeTraceInfo()
|
|
|
|
{
|
|
|
|
FreeTraceInfo(sTraceInfoTLS.get());
|
|
|
|
}
|
|
|
|
|
2014-03-27 08:44:30 +00:00
|
|
|
TraceInfo*
|
|
|
|
GetOrCreateTraceInfo()
|
|
|
|
{
|
2014-12-22 06:57:12 +00:00
|
|
|
ENSURE_TRUE(sTraceInfoTLS.initialized(), nullptr);
|
|
|
|
ENSURE_TRUE(IsStartLogging(), nullptr);
|
|
|
|
|
|
|
|
TraceInfo* info = sTraceInfoTLS.get();
|
|
|
|
if (info && info->mObsolete) {
|
|
|
|
// TraceInfo is obsolete: remove it.
|
|
|
|
FreeTraceInfo(info);
|
|
|
|
info = nullptr;
|
|
|
|
}
|
2014-03-27 08:44:30 +00:00
|
|
|
|
|
|
|
if (!info) {
|
|
|
|
info = AllocTraceInfo(gettid());
|
2014-12-22 06:57:12 +00:00
|
|
|
sTraceInfoTLS.set(info);
|
2014-03-27 08:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
GenNewUniqueTaskId()
|
|
|
|
{
|
|
|
|
TraceInfo* info = GetOrCreateTraceInfo();
|
2014-12-22 06:57:12 +00:00
|
|
|
ENSURE_TRUE(info, 0);
|
2014-03-27 08:44:30 +00:00
|
|
|
|
|
|
|
pid_t tid = gettid();
|
|
|
|
uint64_t taskid = ((uint64_t)tid << 32) | ++info->mLastUniqueTaskId;
|
|
|
|
return taskid;
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoSaveCurTraceInfo::AutoSaveCurTraceInfo()
|
|
|
|
{
|
|
|
|
SaveCurTraceInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoSaveCurTraceInfo::~AutoSaveCurTraceInfo()
|
|
|
|
{
|
|
|
|
RestoreCurTraceInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SetCurTraceInfo(uint64_t aSourceEventId, uint64_t aParentTaskId,
|
|
|
|
SourceEventType aSourceEventType)
|
|
|
|
{
|
|
|
|
TraceInfo* info = GetOrCreateTraceInfo();
|
2014-12-22 06:57:12 +00:00
|
|
|
ENSURE_TRUE_VOID(info);
|
2014-03-27 08:44:30 +00:00
|
|
|
|
|
|
|
info->mCurTraceSourceId = aSourceEventId;
|
|
|
|
info->mCurTaskId = aParentTaskId;
|
|
|
|
info->mCurTraceSourceType = aSourceEventType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetCurTraceInfo(uint64_t* aOutSourceEventId, uint64_t* aOutParentTaskId,
|
|
|
|
SourceEventType* aOutSourceEventType)
|
|
|
|
{
|
|
|
|
TraceInfo* info = GetOrCreateTraceInfo();
|
2014-12-22 06:57:12 +00:00
|
|
|
ENSURE_TRUE_VOID(info);
|
2014-03-27 08:44:30 +00:00
|
|
|
|
|
|
|
*aOutSourceEventId = info->mCurTraceSourceId;
|
|
|
|
*aOutParentTaskId = info->mCurTaskId;
|
|
|
|
*aOutSourceEventType = info->mCurTraceSourceType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LogDispatch(uint64_t aTaskId, uint64_t aParentTaskId, uint64_t aSourceEventId,
|
|
|
|
SourceEventType aSourceEventType)
|
2015-06-16 02:57:19 +00:00
|
|
|
{
|
|
|
|
LogDispatch(aTaskId, aParentTaskId, aSourceEventId, aSourceEventType, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LogDispatch(uint64_t aTaskId, uint64_t aParentTaskId, uint64_t aSourceEventId,
|
|
|
|
SourceEventType aSourceEventType, int aDelayTimeMs)
|
2014-03-27 08:44:30 +00:00
|
|
|
{
|
2014-10-14 02:47:59 +00:00
|
|
|
TraceInfo* info = GetOrCreateTraceInfo();
|
2014-12-22 06:57:12 +00:00
|
|
|
ENSURE_TRUE_VOID(info);
|
2014-03-27 08:44:30 +00:00
|
|
|
|
2015-06-16 02:57:19 +00:00
|
|
|
// aDelayTimeMs is the expected delay time in milliseconds, thus the dispatch
|
|
|
|
// time calculated of it might be slightly off in the real world.
|
|
|
|
uint64_t time = (aDelayTimeMs <= 0) ? GetTimestamp() :
|
|
|
|
GetTimestamp() + aDelayTimeMs;
|
|
|
|
|
2014-03-27 08:44:30 +00:00
|
|
|
// Log format:
|
|
|
|
// [0 taskId dispatchTime sourceEventId sourceEventType parentTaskId]
|
2014-10-14 02:47:59 +00:00
|
|
|
nsCString* log = info->AppendLog();
|
|
|
|
if (log) {
|
|
|
|
log->AppendPrintf("%d %lld %lld %lld %d %lld",
|
2015-06-16 02:57:19 +00:00
|
|
|
ACTION_DISPATCH, aTaskId, time, aSourceEventId,
|
2014-11-28 09:27:09 +00:00
|
|
|
aSourceEventType, aParentTaskId);
|
2014-10-14 02:47:59 +00:00
|
|
|
}
|
2014-03-27 08:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LogBegin(uint64_t aTaskId, uint64_t aSourceEventId)
|
|
|
|
{
|
2014-10-14 02:47:59 +00:00
|
|
|
TraceInfo* info = GetOrCreateTraceInfo();
|
2014-12-22 06:57:12 +00:00
|
|
|
ENSURE_TRUE_VOID(info);
|
2014-03-27 08:44:30 +00:00
|
|
|
|
|
|
|
// Log format:
|
|
|
|
// [1 taskId beginTime processId threadId]
|
2014-10-14 02:47:59 +00:00
|
|
|
nsCString* log = info->AppendLog();
|
|
|
|
if (log) {
|
|
|
|
log->AppendPrintf("%d %lld %lld %d %d",
|
2014-11-28 09:27:09 +00:00
|
|
|
ACTION_BEGIN, aTaskId, GetTimestamp(), getpid(), gettid());
|
2014-10-14 02:47:59 +00:00
|
|
|
}
|
2014-03-27 08:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LogEnd(uint64_t aTaskId, uint64_t aSourceEventId)
|
|
|
|
{
|
2014-10-14 02:47:59 +00:00
|
|
|
TraceInfo* info = GetOrCreateTraceInfo();
|
2014-12-22 06:57:12 +00:00
|
|
|
ENSURE_TRUE_VOID(info);
|
2014-03-27 08:44:30 +00:00
|
|
|
|
|
|
|
// Log format:
|
|
|
|
// [2 taskId endTime]
|
2014-10-14 02:47:59 +00:00
|
|
|
nsCString* log = info->AppendLog();
|
|
|
|
if (log) {
|
2014-11-28 09:27:09 +00:00
|
|
|
log->AppendPrintf("%d %lld %lld", ACTION_END, aTaskId, GetTimestamp());
|
2014-10-14 02:47:59 +00:00
|
|
|
}
|
2014-03-27 08:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, int* aVptr)
|
|
|
|
{
|
2014-10-14 02:47:59 +00:00
|
|
|
TraceInfo* info = GetOrCreateTraceInfo();
|
2014-12-22 06:57:12 +00:00
|
|
|
ENSURE_TRUE_VOID(info);
|
2014-03-27 08:44:30 +00:00
|
|
|
|
|
|
|
// Log format:
|
|
|
|
// [4 taskId address]
|
2014-10-14 02:47:59 +00:00
|
|
|
nsCString* log = info->AppendLog();
|
|
|
|
if (log) {
|
|
|
|
log->AppendPrintf("%d %lld %p", ACTION_GET_VTABLE, aTaskId, aVptr);
|
|
|
|
}
|
2014-03-27 08:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AutoSourceEvent::AutoSourceEvent(SourceEventType aType)
|
|
|
|
{
|
|
|
|
CreateSourceEvent(aType);
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoSourceEvent::~AutoSourceEvent()
|
|
|
|
{
|
|
|
|
DestroySourceEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddLabel(const char* aFormat, ...)
|
|
|
|
{
|
2014-10-14 02:47:59 +00:00
|
|
|
TraceInfo* info = GetOrCreateTraceInfo();
|
2014-12-22 06:57:12 +00:00
|
|
|
ENSURE_TRUE_VOID(info);
|
2014-03-27 08:44:30 +00:00
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start(args, aFormat);
|
2014-10-14 02:47:59 +00:00
|
|
|
nsAutoCString buffer;
|
|
|
|
buffer.AppendPrintf(aFormat, args);
|
2014-03-27 08:44:30 +00:00
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
// Log format:
|
|
|
|
// [3 taskId "label"]
|
2014-10-14 02:47:59 +00:00
|
|
|
nsCString* log = info->AppendLog();
|
|
|
|
if (log) {
|
|
|
|
log->AppendPrintf("%d %lld %lld \"%s\"", ACTION_ADD_LABEL, info->mCurTaskId,
|
2014-11-28 09:27:09 +00:00
|
|
|
GetTimestamp(), buffer.get());
|
2014-10-14 02:47:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Functions used by GeckoProfiler.
|
|
|
|
|
|
|
|
void
|
2014-11-28 09:27:09 +00:00
|
|
|
StartLogging()
|
2014-10-14 02:47:59 +00:00
|
|
|
{
|
2014-11-28 09:27:09 +00:00
|
|
|
sStartTime = GetTimestamp();
|
2014-10-14 02:47:59 +00:00
|
|
|
SetLogStarted(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StopLogging()
|
|
|
|
{
|
|
|
|
SetLogStarted(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
TraceInfoLogsType*
|
2014-12-22 06:57:12 +00:00
|
|
|
GetLoggedData(TimeStamp aTimeStamp)
|
2014-10-14 02:47:59 +00:00
|
|
|
{
|
|
|
|
TraceInfoLogsType* result = new TraceInfoLogsType();
|
|
|
|
|
|
|
|
// TODO: This is called from a signal handler. Use semaphore instead.
|
|
|
|
StaticMutexAutoLock lock(sMutex);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < sTraceInfos->Length(); ++i) {
|
|
|
|
(*sTraceInfos)[i]->MoveLogsInto(*result);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2014-03-27 08:44:30 +00:00
|
|
|
}
|
|
|
|
|
2014-11-28 09:27:09 +00:00
|
|
|
const PRTime
|
|
|
|
GetStartTime()
|
|
|
|
{
|
|
|
|
return sStartTime;
|
|
|
|
}
|
|
|
|
|
2014-11-20 02:57:27 +00:00
|
|
|
const char*
|
|
|
|
GetJSLabelPrefix()
|
|
|
|
{
|
|
|
|
return sJSLabelPrefix;
|
|
|
|
}
|
|
|
|
|
2014-12-22 06:57:12 +00:00
|
|
|
#undef ENSURE_TRUE_VOID
|
|
|
|
#undef ENSURE_TRUE
|
|
|
|
|
2014-03-27 08:44:30 +00:00
|
|
|
} // namespace tasktracer
|
|
|
|
} // namespace mozilla
|