mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-04 07:40:42 +00:00
Bug 1287392 - Part 1: Fix TaskTracer bugs caused by the changes of IPC. r=khuey, r=bgirard
--HG-- extra : rebase_source : d7c6771ada2f19b028760456bd976bf578e58cf6
This commit is contained in:
parent
f08897dbcb
commit
9f1f17b5dc
@ -38,9 +38,9 @@ Message::Message()
|
||||
header()->num_fds = 0;
|
||||
#endif
|
||||
#ifdef MOZ_TASK_TRACER
|
||||
header()->source_event_id = 0;
|
||||
header()->parent_task_id = 0;
|
||||
header()->source_event_type = SourceEventType::Unknown;
|
||||
GetCurTraceInfo(&header()->source_event_id,
|
||||
&header()->parent_task_id,
|
||||
&header()->source_event_type);
|
||||
#endif
|
||||
InitLoggingVariables();
|
||||
}
|
||||
@ -68,9 +68,9 @@ Message::Message(int32_t routing_id, msgid_t type, NestedLevel nestedLevel, Prio
|
||||
header()->cookie = 0;
|
||||
#endif
|
||||
#ifdef MOZ_TASK_TRACER
|
||||
header()->source_event_id = 0;
|
||||
header()->parent_task_id = 0;
|
||||
header()->source_event_type = SourceEventType::Unknown;
|
||||
GetCurTraceInfo(&header()->source_event_id,
|
||||
&header()->parent_task_id,
|
||||
&header()->source_event_type);
|
||||
#endif
|
||||
InitLoggingVariables(aName);
|
||||
}
|
||||
@ -88,11 +88,6 @@ Message::Message(Message&& other) : Pickle(mozilla::Move(other)) {
|
||||
#if defined(OS_POSIX)
|
||||
file_descriptor_set_ = other.file_descriptor_set_.forget();
|
||||
#endif
|
||||
#ifdef MOZ_TASK_TRACER
|
||||
header()->source_event_id = other.header()->source_event_id;
|
||||
header()->parent_task_id = other.header()->parent_task_id;
|
||||
header()->source_event_type = other.header()->source_event_type;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Message::InitLoggingVariables(const char* const aName) {
|
||||
@ -104,11 +99,6 @@ Message& Message::operator=(Message&& other) {
|
||||
InitLoggingVariables(other.name_);
|
||||
#if defined(OS_POSIX)
|
||||
file_descriptor_set_.swap(other.file_descriptor_set_);
|
||||
#endif
|
||||
#ifdef MOZ_TASK_TRACER
|
||||
std::swap(header()->source_event_id, other.header()->source_event_id);
|
||||
std::swap(header()->parent_task_id, other.header()->parent_task_id);
|
||||
std::swap(header()->source_event_type, other.header()->source_event_type);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
@ -65,11 +65,6 @@ typedef CONTEXT tickcontext_t;
|
||||
typedef ucontext_t tickcontext_t;
|
||||
#endif
|
||||
|
||||
#if defined(LINUX) || defined(XP_MACOSX)
|
||||
#include <sys/types.h>
|
||||
pid_t gettid();
|
||||
#endif
|
||||
|
||||
#if defined(__arm__) && defined(ANDROID)
|
||||
// Should also work on ARM Linux, but not tested there yet.
|
||||
#define USE_EHABI_STACKWALK
|
||||
@ -291,6 +286,12 @@ GeckoSampler::~GeckoSampler()
|
||||
// Cancel any in-flight async profile gatherering
|
||||
// requests
|
||||
mGatherer->Cancel();
|
||||
|
||||
#ifdef MOZ_TASK_TRACER
|
||||
if (mTaskTracer) {
|
||||
mozilla::tasktracer::StopLogging();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void GeckoSampler::HandleSaveRequest()
|
||||
|
@ -83,11 +83,6 @@ class GeckoSampler: public Sampler {
|
||||
virtual void RequestSave() override
|
||||
{
|
||||
mSaveRequested = true;
|
||||
#ifdef MOZ_TASK_TRACER
|
||||
if (mTaskTracer) {
|
||||
mozilla::tasktracer::StopLogging();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual void HandleSaveRequest() override;
|
||||
|
@ -59,17 +59,25 @@
|
||||
#include <vector>
|
||||
#include "StackTop.h"
|
||||
|
||||
// We need a definition of gettid(), but Linux libc implementations don't
|
||||
// provide a wrapper for it (except for Bionic)
|
||||
#if defined(__linux__)
|
||||
// We need a definition of gettid(), but glibc doesn't provide a
|
||||
// wrapper for it.
|
||||
#if defined(__GLIBC__)
|
||||
#include <unistd.h>
|
||||
#if !defined(__BIONIC__)
|
||||
#include <sys/syscall.h>
|
||||
static inline pid_t gettid()
|
||||
{
|
||||
return (pid_t) syscall(SYS_gettid);
|
||||
}
|
||||
#endif
|
||||
#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
|
||||
|
||||
#ifdef XP_WIN
|
||||
|
@ -20,27 +20,6 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
// We need a definition of gettid(), but glibc doesn't provide a
|
||||
// wrapper for it.
|
||||
#if defined(__GLIBC__)
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
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 { \
|
||||
@ -184,7 +163,7 @@ SetLogStarted(bool aIsStartLogging)
|
||||
static void
|
||||
CleanUp()
|
||||
{
|
||||
SetLogStarted(false);
|
||||
MOZ_ASSERT(!IsStartLogging());
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
|
||||
if (sTraceInfos) {
|
||||
@ -230,9 +209,7 @@ InitTaskTracer(uint32_t aFlags)
|
||||
MOZ_ASSERT(!sTraceInfos);
|
||||
sTraceInfos = new nsTArray<UniquePtr<TraceInfo>>();
|
||||
|
||||
if (!sTraceInfoTLS.initialized()) {
|
||||
Unused << sTraceInfoTLS.init();
|
||||
}
|
||||
sTraceInfoTLS.init();
|
||||
}
|
||||
|
||||
void
|
||||
@ -246,7 +223,9 @@ FreeTraceInfo(TraceInfo* aTraceInfo)
|
||||
{
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
if (aTraceInfo) {
|
||||
sTraceInfos->RemoveElement(aTraceInfo);
|
||||
UniquePtr<TraceInfo> traceinfo(aTraceInfo);
|
||||
sTraceInfos->RemoveElement(traceinfo);
|
||||
Unused << traceinfo.release(); // A dirty hack to prevent double free.
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,7 +237,7 @@ void FreeTraceInfo()
|
||||
TraceInfo*
|
||||
GetOrCreateTraceInfo()
|
||||
{
|
||||
ENSURE_TRUE(sTraceInfoTLS.initialized(), nullptr);
|
||||
ENSURE_TRUE(sTraceInfoTLS.init(), nullptr);
|
||||
ENSURE_TRUE(IsStartLogging(), nullptr);
|
||||
|
||||
TraceInfo* info = sTraceInfoTLS.get();
|
||||
|
@ -25,7 +25,6 @@
|
||||
* original source event.
|
||||
*/
|
||||
|
||||
class Task;
|
||||
class nsIRunnable;
|
||||
class nsCString;
|
||||
|
||||
@ -74,8 +73,6 @@ const PRTime GetStartTime();
|
||||
* Internal functions.
|
||||
*/
|
||||
|
||||
Task* CreateTracedTask(Task* aTask);
|
||||
|
||||
already_AddRefed<nsIRunnable>
|
||||
CreateTracedRunnable(already_AddRefed<nsIRunnable>&& aRunnable);
|
||||
|
||||
|
@ -114,35 +114,6 @@ TracedRunnable::Run()
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of class TracedTask.
|
||||
*/
|
||||
TracedTask::TracedTask(Task* aOriginalObj)
|
||||
: TracedTaskCommon()
|
||||
, mOriginalObj(aOriginalObj)
|
||||
{
|
||||
Init();
|
||||
LogVirtualTablePtr(mTaskId, mSourceEventId, reinterpret_cast<uintptr_t*>(aOriginalObj));
|
||||
}
|
||||
|
||||
TracedTask::~TracedTask()
|
||||
{
|
||||
if (mOriginalObj) {
|
||||
delete mOriginalObj;
|
||||
mOriginalObj = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TracedTask::Run()
|
||||
{
|
||||
SetTLSTraceInfo();
|
||||
LogBegin(mTaskId, mSourceEventId);
|
||||
mOriginalObj->Run();
|
||||
LogEnd(mTaskId, mSourceEventId);
|
||||
ClearTLSTraceInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateTracedRunnable() returns a TracedRunnable wrapping the original
|
||||
* nsIRunnable object, aRunnable.
|
||||
@ -154,16 +125,5 @@ CreateTracedRunnable(already_AddRefed<nsIRunnable>&& aRunnable)
|
||||
return runnable.forget();
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateTracedTask() returns a TracedTask wrapping the original Task object,
|
||||
* aTask.
|
||||
*/
|
||||
Task*
|
||||
CreateTracedTask(Task* aTask)
|
||||
{
|
||||
Task* task = new TracedTask(aTask);
|
||||
return task;
|
||||
}
|
||||
|
||||
} // namespace tasktracer
|
||||
} // namespace mozilla
|
||||
|
@ -41,7 +41,7 @@ protected:
|
||||
};
|
||||
|
||||
class TracedRunnable : public TracedTaskCommon
|
||||
, public nsRunnable
|
||||
, public Runnable
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSIRUNNABLE
|
||||
@ -54,19 +54,6 @@ private:
|
||||
nsCOMPtr<nsIRunnable> mOriginalObj;
|
||||
};
|
||||
|
||||
class TracedTask : public TracedTaskCommon
|
||||
, public Task
|
||||
{
|
||||
public:
|
||||
TracedTask(Task* aOriginalObj);
|
||||
~TracedTask();
|
||||
|
||||
virtual void Run();
|
||||
|
||||
private:
|
||||
Task* mOriginalObj;
|
||||
};
|
||||
|
||||
} // namespace tasktracer
|
||||
} // namespace mozilla
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user