Bug 1221846 - Get Task Tracer building on desktop r=cyu.
--- a/configure.in
+++ b/configure.in
@@ -7381,17 +7381,17 @@ MOZ_ARG_HEADER(Profiling and Instrumenti
dnl ========================================================
dnl = Enable TaskTracer
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(tasktracer,
[ --enable-tasktracer Set compile flags necessary for using TaskTracer],
MOZ_TASK_TRACER=1,
MOZ_TASK_TRACER= )
-if test "$MOZ_WIDGET_TOOLKIT" = "gonk" -a -n "$MOZ_TASK_TRACER"; then
+if test -n "$MOZ_TASK_TRACER"; then
AC_DEFINE(MOZ_TASK_TRACER)
AC_SUBST(MOZ_TASK_TRACER)
fi
dnl ========================================================
dnl Turn on reflow counting
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(reflow-perf,
--- a/toolkit/toolkit.mozbuild
+++ b/toolkit/toolkit.mozbuild
@@ -175,14 +175,14 @@ if CONFIG['ENABLE_TESTS']:
'/testing/tools/screenshot',
'/testing/profiles',
'/testing/mozbase',
'/testing/modules',
'/testing/runtimes',
'/testing/web-platform',
]
- if CONFIG['MOZ_WEBRTC'] and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
+ if CONFIG['MOZ_WEBRTC'] and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk' and not CONFIG['MOZ_TASK_TRACER']:
DIRS += [
'/media/webrtc/signaling/test',
'/media/webrtc/signaling/test/standalone',
'/media/mtransport/test',
]
--- a/tools/profiler/moz.build
+++ b/tools/profiler/moz.build
@@ -116,18 +116,18 @@ IPDL_SOURCES += [
include('/ipc/chromium/chromium-config.mozbuild')
EXPORTS += [
'public/GeckoProfiler.h',
]
if CONFIG['MOZ_TASK_TRACER']:
EXPORTS += [
- 'public/GeckoTaskTracer.h',
- 'public/GeckoTaskTracerImpl.h',
- 'public/TracedTaskCommon.h',
+ 'tasktracer/GeckoTaskTracer.h',
+ 'tasktracer/GeckoTaskTracerImpl.h',
+ 'tasktracer/TracedTaskCommon.h',
]
UNIFIED_SOURCES += [
'tasktracer/GeckoTaskTracer.cpp',
'tasktracer/TracedTaskCommon.cpp',
]
XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell.ini']
--- a/tools/profiler/tasktracer/GeckoTaskTracer.cpp
+++ b/tools/profiler/tasktracer/GeckoTaskTracer.cpp
@@ -14,23 +14,35 @@
#include "mozilla/unused.h"
#include "nsString.h"
#include "nsThreadUtils.h"
#include "prtime.h"
#include <stdarg.h>
+// We need a definition of gettid(), but glibc doesn't provide a
+// wrapper for it.
#if defined(__GLIBC__)
-// glibc doesn't implement gettid(2).
+#include <unistd.h>
#include <sys/syscall.h>
-static pid_t gettid()
+static inline pid_t gettid()
{
return (pid_t) syscall(SYS_gettid);
}
+#elif defined(XP_MACOSX)
+#include <unistd.h>
+#include <sys/syscall.h>
+static inline pid_t gettid()
+{
+ return (pid_t) syscall(SYS_thread_selfid);
+}
+#elif defined(LINUX)
+#include <sys/types.h>
+pid_t gettid();
#endif
// NS_ENSURE_TRUE_VOID() without the warning on the debug build.
#define ENSURE_TRUE_VOID(x) \
do { \
if (MOZ_UNLIKELY(!(x))) { \
return; \
} \
@@ -109,22 +121,22 @@ CreateSourceEvent(SourceEventType aType)
uint64_t newId = GenNewUniqueTaskId();
TraceInfo* info = GetOrCreateTraceInfo();
ENSURE_TRUE_VOID(info);
info->mCurTraceSourceId = newId;
info->mCurTraceSourceType = aType;
info->mCurTaskId = newId;
- int* namePtr;
+ uintptr_t* namePtr;
#define SOURCE_EVENT_NAME(type) \
case SourceEventType::type: \
{ \
static int CreateSourceEvent##type; \
- namePtr = &CreateSourceEvent##type; \
+ namePtr = (uintptr_t*)&CreateSourceEvent##type; \
break; \
}
switch (aType) {
#include "SourceEventTypeMap.h"
default:
MOZ_CRASH("Unknown SourceEvent.");
};
@@ -363,17 +375,17 @@ LogEnd(uint64_t aTaskId, uint64_t aSourc
// [2 taskId endTime]
nsCString* log = info->AppendLog();
if (log) {
log->AppendPrintf("%d %lld %lld", ACTION_END, aTaskId, GetTimestamp());
}
}
void
-LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, int* aVptr)
+LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, uintptr_t* aVptr)
{
TraceInfo* info = GetOrCreateTraceInfo();
ENSURE_TRUE_VOID(info);
// Log format:
// [4 taskId address]
nsCString* log = info->AppendLog();
if (log) {
--- a/tools/profiler/tasktracer/GeckoTaskTracerImpl.h
+++ b/tools/profiler/tasktracer/GeckoTaskTracerImpl.h
@@ -89,14 +89,14 @@ void LogDispatch(uint64_t aTaskId, uint6
void LogDispatch(uint64_t aTaskId, uint64_t aParentTaskId,
uint64_t aSourceEventId, SourceEventType aSourceEventType,
int aDelayTimeMs);
void LogBegin(uint64_t aTaskId, uint64_t aSourceEventId);
void LogEnd(uint64_t aTaskId, uint64_t aSourceEventId);
-void LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, int* aVptr);
+void LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, uintptr_t* aVptr);
} // namespace mozilla
} // namespace tasktracer
#endif
--- a/tools/profiler/tasktracer/TracedTaskCommon.cpp
+++ b/tools/profiler/tasktracer/TracedTaskCommon.cpp
@@ -90,17 +90,17 @@ TracedTaskCommon::ClearTLSTraceInfo()
/**
* Implementation of class TracedRunnable.
*/
TracedRunnable::TracedRunnable(already_AddRefed<nsIRunnable>&& aOriginalObj)
: TracedTaskCommon()
, mOriginalObj(Move(aOriginalObj))
{
Init();
- LogVirtualTablePtr(mTaskId, mSourceEventId, *(int**)(aOriginalObj));
+ LogVirtualTablePtr(mTaskId, mSourceEventId, reinterpret_cast<uintptr_t*>(mOriginalObj.get()));
}
TracedRunnable::~TracedRunnable()
{
}
NS_IMETHODIMP
TracedRunnable::Run()
@@ -117,17 +117,17 @@ TracedRunnable::Run()
/**
* Implementation of class TracedTask.
*/
TracedTask::TracedTask(Task* aOriginalObj)
: TracedTaskCommon()
, mOriginalObj(aOriginalObj)
{
Init();
- LogVirtualTablePtr(mTaskId, mSourceEventId, *(int**)(aOriginalObj));
+ LogVirtualTablePtr(mTaskId, mSourceEventId, reinterpret_cast<uintptr_t*>(aOriginalObj));
}
TracedTask::~TracedTask()
{
if (mOriginalObj) {
delete mOriginalObj;
mOriginalObj = nullptr;
}
--- a/xpcom/threads/TimerThread.cpp
+++ b/xpcom/threads/TimerThread.cpp
@@ -16,16 +16,20 @@
#include "mozilla/Services.h"
#include "mozilla/ChaosMode.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/BinarySearch.h"
#include <math.h>
using namespace mozilla;
+#ifdef MOZ_TASK_TRACER
+#include "GeckoTaskTracerImpl.h"
+using namespace mozilla::tasktracer;
+#endif
NS_IMPL_ISUPPORTS(TimerThread, nsIRunnable, nsIObserver)
TimerThread::TimerThread() :
mInitInProgress(false),
mInitialized(false),
mMonitor("TimerThread.mMonitor"),
mShutdown(false),