Dobby 3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Loading...
Searching...
No Matches
PerfettoTracingSingleton.h
1/*
2* If not stated otherwise in this file or this component's LICENSE file the
3* following copyright and licenses apply:
4*
5* Copyright 2020 Sky UK
6*
7* Licensed under the Apache License, Version 2.0 (the "License");
8* you may not use this file except in compliance with the License.
9* You may obtain a copy of the License at
10*
11* http://www.apache.org/licenses/LICENSE-2.0
12*
13* Unless required by applicable law or agreed to in writing, software
14* distributed under the License is distributed on an "AS IS" BASIS,
15* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16* See the License for the specific language governing permissions and
17* limitations under the License.
18*/
19//
20// PerfettoTracingSingleton.h
21//
22#ifndef PERFETTOTRACINGSINGLETON_H
23#define PERFETTOTRACINGSINGLETON_H
24
25#include <perfetto.h>
26
27#include <pthread.h>
28
29#include <string>
30#include <memory>
31#include <mutex>
32#include <chrono>
33
34// define an empty set of categories if tracing is disabled
35#if !defined(AI_ENABLE_TRACING)
36 PERFETTO_DEFINE_CATEGORIES();
37#endif
38
39
41{
42private:
43 static void cleanUp();
44 static PerfettoTracingSingleton* mInstance;
45 static pthread_rwlock_t mInstanceLock;
46
47private:
49
50public:
53
54 bool initialise(unsigned backends);
55
56 bool isTracing() const;
57
58 bool startInProcessTracing(int fd, const std::string &categoryFilter);
60
61private:
62 mutable std::mutex mLock;
63 bool mInitialised;
64 unsigned mBackends;
65
66 int mTraceFileFd;
67 std::unique_ptr<perfetto::TracingSession> mInProcessSession;
68
69};
70
71
72#endif // PERFETTOTRACINGSINGLETON_H
Definition PerfettoTracingSingleton.h:41
void stopInProcessTracing()
Definition PerfettoTracingSingleton.cpp:268
static PerfettoTracingSingleton * instance()
Definition PerfettoTracingSingleton.cpp:41
bool isTracing() const
Definition PerfettoTracingSingleton.cpp:240
bool startInProcessTracing(int fd, const std::string &categoryFilter)
Definition PerfettoTracingSingleton.cpp:168
bool initialise(unsigned backends)
Definition PerfettoTracingSingleton.cpp:120