diff --git a/configure.in b/configure.in index 4c9835597eed..5f8fab54a8b6 100644 --- a/configure.in +++ b/configure.in @@ -7386,7 +7386,7 @@ 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 diff --git a/toolkit/toolkit.mozbuild b/toolkit/toolkit.mozbuild index b0872e26f994..a40132283923 100644 --- a/toolkit/toolkit.mozbuild +++ b/toolkit/toolkit.mozbuild @@ -180,7 +180,7 @@ if CONFIG['ENABLE_TESTS']: '/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', diff --git a/tools/profiler/moz.build b/tools/profiler/moz.build index 9e0302392ec6..99d2bf690ce9 100644 --- a/tools/profiler/moz.build +++ b/tools/profiler/moz.build @@ -121,9 +121,9 @@ EXPORTS += [ 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', diff --git a/tools/profiler/tasktracer/GeckoTaskTracer.cpp b/tools/profiler/tasktracer/GeckoTaskTracer.cpp index 154910d1a00e..e1a855c1827f 100644 --- a/tools/profiler/tasktracer/GeckoTaskTracer.cpp +++ b/tools/profiler/tasktracer/GeckoTaskTracer.cpp @@ -19,13 +19,25 @@ #include +// 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 #include -static pid_t gettid() +static inline pid_t gettid() { return (pid_t) syscall(SYS_gettid); } +#elif defined(XP_MACOSX) +#include +#include +static inline pid_t gettid() +{ + return (pid_t) syscall(SYS_thread_selfid); +} +#elif defined(LINUX) +#include +pid_t gettid(); #endif // NS_ENSURE_TRUE_VOID() without the warning on the debug build. @@ -114,12 +126,12 @@ CreateSourceEvent(SourceEventType aType) 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; \ } @@ -368,7 +380,7 @@ LogEnd(uint64_t aTaskId, uint64_t aSourceEventId) } 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); diff --git a/tools/profiler/tasktracer/GeckoTaskTracerImpl.h b/tools/profiler/tasktracer/GeckoTaskTracerImpl.h index 00e54b976917..5b748fb96b6c 100644 --- a/tools/profiler/tasktracer/GeckoTaskTracerImpl.h +++ b/tools/profiler/tasktracer/GeckoTaskTracerImpl.h @@ -94,7 +94,7 @@ 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 diff --git a/tools/profiler/tasktracer/TracedTaskCommon.cpp b/tools/profiler/tasktracer/TracedTaskCommon.cpp index 9fc2f559a50d..770eb202c9ed 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, *(int**)(aOriginalObj)); + LogVirtualTablePtr(mTaskId, mSourceEventId, reinterpret_cast(mOriginalObj.get())); } TracedRunnable::~TracedRunnable() @@ -122,7 +122,7 @@ TracedTask::TracedTask(Task* aOriginalObj) , mOriginalObj(aOriginalObj) { Init(); - LogVirtualTablePtr(mTaskId, mSourceEventId, *(int**)(aOriginalObj)); + LogVirtualTablePtr(mTaskId, mSourceEventId, reinterpret_cast(aOriginalObj)); } TracedTask::~TracedTask() diff --git a/xpcom/threads/TimerThread.cpp b/xpcom/threads/TimerThread.cpp index 7e032607e7ca..7714262f6177 100644 --- a/xpcom/threads/TimerThread.cpp +++ b/xpcom/threads/TimerThread.cpp @@ -21,6 +21,10 @@ #include using namespace mozilla; +#ifdef MOZ_TASK_TRACER +#include "GeckoTaskTracerImpl.h" +using namespace mozilla::tasktracer; +#endif NS_IMPL_ISUPPORTS(TimerThread, nsIRunnable, nsIObserver)