tools/profiler/GeckoTaskTracerImpl.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:eed2dc79ffd1
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef GECKO_TASK_TRACER_IMPL_H
8 #define GECKO_TASK_TRACER_IMPL_H
9
10 #include "GeckoTaskTracer.h"
11
12 namespace mozilla {
13 namespace tasktracer {
14
15 struct TraceInfo
16 {
17 TraceInfo(uint32_t aThreadId) : mCurTraceSourceId(0)
18 , mCurTaskId(0)
19 , mSavedCurTraceSourceId(0)
20 , mSavedCurTaskId(0)
21 , mCurTraceSourceType(UNKNOWN)
22 , mSavedCurTraceSourceType(UNKNOWN)
23 , mThreadId(aThreadId)
24 , mLastUniqueTaskId(0)
25 {
26 MOZ_COUNT_CTOR(TraceInfo);
27 }
28
29 ~TraceInfo() { MOZ_COUNT_DTOR(TraceInfo); }
30
31 uint64_t mCurTraceSourceId;
32 uint64_t mCurTaskId;
33 uint64_t mSavedCurTraceSourceId;
34 uint64_t mSavedCurTaskId;
35 SourceEventType mCurTraceSourceType;
36 SourceEventType mSavedCurTraceSourceType;
37 uint32_t mThreadId;
38 uint32_t mLastUniqueTaskId;
39 };
40
41 void InitTaskTracer();
42 void ShutdownTaskTracer();
43
44 // Return the TraceInfo of current thread, allocate a new one if not exit.
45 TraceInfo* GetOrCreateTraceInfo();
46
47 uint64_t GenNewUniqueTaskId();
48
49 class AutoSaveCurTraceInfo
50 {
51 public:
52 AutoSaveCurTraceInfo();
53 ~AutoSaveCurTraceInfo();
54 };
55
56 void SetCurTraceInfo(uint64_t aSourceEventId, uint64_t aParentTaskId,
57 SourceEventType aSourceEventType);
58
59 void GetCurTraceInfo(uint64_t* aOutSourceEventId, uint64_t* aOutParentTaskId,
60 SourceEventType* aOutSourceEventType);
61
62 /**
63 * Logging functions of different trace actions.
64 */
65 enum ActionType {
66 ACTION_DISPATCH = 0,
67 ACTION_BEGIN,
68 ACTION_END,
69 ACTION_ADD_LABEL,
70 ACTION_GET_VTABLE
71 };
72
73 void LogDispatch(uint64_t aTaskId, uint64_t aParentTaskId,
74 uint64_t aSourceEventId, SourceEventType aSourceEventType);
75
76 void LogBegin(uint64_t aTaskId, uint64_t aSourceEventId);
77
78 void LogEnd(uint64_t aTaskId, uint64_t aSourceEventId);
79
80 void LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, int* aVptr);
81
82 } // namespace mozilla
83 } // namespace tasktracer
84
85 #endif

mercurial