michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GECKO_TASK_TRACER_IMPL_H michael@0: #define GECKO_TASK_TRACER_IMPL_H michael@0: michael@0: #include "GeckoTaskTracer.h" michael@0: michael@0: namespace mozilla { michael@0: namespace tasktracer { michael@0: michael@0: struct TraceInfo michael@0: { michael@0: TraceInfo(uint32_t aThreadId) : mCurTraceSourceId(0) michael@0: , mCurTaskId(0) michael@0: , mSavedCurTraceSourceId(0) michael@0: , mSavedCurTaskId(0) michael@0: , mCurTraceSourceType(UNKNOWN) michael@0: , mSavedCurTraceSourceType(UNKNOWN) michael@0: , mThreadId(aThreadId) michael@0: , mLastUniqueTaskId(0) michael@0: { michael@0: MOZ_COUNT_CTOR(TraceInfo); michael@0: } michael@0: michael@0: ~TraceInfo() { MOZ_COUNT_DTOR(TraceInfo); } michael@0: michael@0: uint64_t mCurTraceSourceId; michael@0: uint64_t mCurTaskId; michael@0: uint64_t mSavedCurTraceSourceId; michael@0: uint64_t mSavedCurTaskId; michael@0: SourceEventType mCurTraceSourceType; michael@0: SourceEventType mSavedCurTraceSourceType; michael@0: uint32_t mThreadId; michael@0: uint32_t mLastUniqueTaskId; michael@0: }; michael@0: michael@0: void InitTaskTracer(); michael@0: void ShutdownTaskTracer(); michael@0: michael@0: // Return the TraceInfo of current thread, allocate a new one if not exit. michael@0: TraceInfo* GetOrCreateTraceInfo(); michael@0: michael@0: uint64_t GenNewUniqueTaskId(); michael@0: michael@0: class AutoSaveCurTraceInfo michael@0: { michael@0: public: michael@0: AutoSaveCurTraceInfo(); michael@0: ~AutoSaveCurTraceInfo(); michael@0: }; michael@0: michael@0: void SetCurTraceInfo(uint64_t aSourceEventId, uint64_t aParentTaskId, michael@0: SourceEventType aSourceEventType); michael@0: michael@0: void GetCurTraceInfo(uint64_t* aOutSourceEventId, uint64_t* aOutParentTaskId, michael@0: SourceEventType* aOutSourceEventType); michael@0: michael@0: /** michael@0: * Logging functions of different trace actions. michael@0: */ michael@0: enum ActionType { michael@0: ACTION_DISPATCH = 0, michael@0: ACTION_BEGIN, michael@0: ACTION_END, michael@0: ACTION_ADD_LABEL, michael@0: ACTION_GET_VTABLE michael@0: }; michael@0: michael@0: void LogDispatch(uint64_t aTaskId, uint64_t aParentTaskId, michael@0: uint64_t aSourceEventId, SourceEventType aSourceEventType); michael@0: michael@0: void LogBegin(uint64_t aTaskId, uint64_t aSourceEventId); michael@0: michael@0: void LogEnd(uint64_t aTaskId, uint64_t aSourceEventId); michael@0: michael@0: void LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, int* aVptr); michael@0: michael@0: } // namespace mozilla michael@0: } // namespace tasktracer michael@0: michael@0: #endif