tools/profiler/GeckoTaskTracerImpl.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/profiler/GeckoTaskTracerImpl.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,85 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef GECKO_TASK_TRACER_IMPL_H
    1.11 +#define GECKO_TASK_TRACER_IMPL_H
    1.12 +
    1.13 +#include "GeckoTaskTracer.h"
    1.14 +
    1.15 +namespace mozilla {
    1.16 +namespace tasktracer {
    1.17 +
    1.18 +struct TraceInfo
    1.19 +{
    1.20 +  TraceInfo(uint32_t aThreadId) : mCurTraceSourceId(0)
    1.21 +                                , mCurTaskId(0)
    1.22 +                                , mSavedCurTraceSourceId(0)
    1.23 +                                , mSavedCurTaskId(0)
    1.24 +                                , mCurTraceSourceType(UNKNOWN)
    1.25 +                                , mSavedCurTraceSourceType(UNKNOWN)
    1.26 +                                , mThreadId(aThreadId)
    1.27 +                                , mLastUniqueTaskId(0)
    1.28 +  {
    1.29 +    MOZ_COUNT_CTOR(TraceInfo);
    1.30 +  }
    1.31 +
    1.32 +  ~TraceInfo() { MOZ_COUNT_DTOR(TraceInfo); }
    1.33 +
    1.34 +  uint64_t mCurTraceSourceId;
    1.35 +  uint64_t mCurTaskId;
    1.36 +  uint64_t mSavedCurTraceSourceId;
    1.37 +  uint64_t mSavedCurTaskId;
    1.38 +  SourceEventType mCurTraceSourceType;
    1.39 +  SourceEventType mSavedCurTraceSourceType;
    1.40 +  uint32_t mThreadId;
    1.41 +  uint32_t mLastUniqueTaskId;
    1.42 +};
    1.43 +
    1.44 +void InitTaskTracer();
    1.45 +void ShutdownTaskTracer();
    1.46 +
    1.47 +// Return the TraceInfo of current thread, allocate a new one if not exit.
    1.48 +TraceInfo* GetOrCreateTraceInfo();
    1.49 +
    1.50 +uint64_t GenNewUniqueTaskId();
    1.51 +
    1.52 +class AutoSaveCurTraceInfo
    1.53 +{
    1.54 +public:
    1.55 +  AutoSaveCurTraceInfo();
    1.56 +  ~AutoSaveCurTraceInfo();
    1.57 +};
    1.58 +
    1.59 +void SetCurTraceInfo(uint64_t aSourceEventId, uint64_t aParentTaskId,
    1.60 +                     SourceEventType aSourceEventType);
    1.61 +
    1.62 +void GetCurTraceInfo(uint64_t* aOutSourceEventId, uint64_t* aOutParentTaskId,
    1.63 +                     SourceEventType* aOutSourceEventType);
    1.64 +
    1.65 +/**
    1.66 + * Logging functions of different trace actions.
    1.67 + */
    1.68 +enum ActionType {
    1.69 +  ACTION_DISPATCH = 0,
    1.70 +  ACTION_BEGIN,
    1.71 +  ACTION_END,
    1.72 +  ACTION_ADD_LABEL,
    1.73 +  ACTION_GET_VTABLE
    1.74 +};
    1.75 +
    1.76 +void LogDispatch(uint64_t aTaskId, uint64_t aParentTaskId,
    1.77 +                 uint64_t aSourceEventId, SourceEventType aSourceEventType);
    1.78 +
    1.79 +void LogBegin(uint64_t aTaskId, uint64_t aSourceEventId);
    1.80 +
    1.81 +void LogEnd(uint64_t aTaskId, uint64_t aSourceEventId);
    1.82 +
    1.83 +void LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, int* aVptr);
    1.84 +
    1.85 +} // namespace mozilla
    1.86 +} // namespace tasktracer
    1.87 +
    1.88 +#endif

mercurial