Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qctflib_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT_CTFLIB_H
5#define QT_CTFLIB_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17//
18
19#include <private/qctf_p.h>
20#include "qctfplugin_p.h"
21#include <qstring.h>
22#include <qmutex.h>
23#include <qelapsedtimer.h>
24#include <qhash.h>
25#include <qset.h>
26#include <qthreadstorage.h>
27#include <qthread.h>
28#include <qloggingcategory.h>
29
31
33
35{
37 quint32 id = 0;
38 quint32 payloadSize = 0;
39 bool metadataWritten = false;
40};
41
42class QCtfLibImpl : public QCtfLib
43{
44 struct Session
45 {
47 QStringList tracepoints;
48 bool all = false;
49 };
50 struct Channel
51 {
52 char channelName[512];
54 quint64 minTimestamp = 0;
55 quint64 maxTimestamp = 0;
56 quint64 seqnumber = 0;
57 QThread *thread = nullptr;
58 quint32 threadIndex = 0;
59 QByteArray threadName;
60 quint32 threadNameLength = 0;
61 bool locked = false;
62 Channel()
63 {
64 memset(channelName, 0, sizeof(channelName));
65 }
66
67 ~Channel();
68 };
69
70public:
73
74 bool tracepointEnabled(const QCtfTracePointEvent &point) override;
75 void doTracepoint(const QCtfTracePointEvent &point, const QByteArray &arr) override;
76 bool sessionEnabled() override;
78 void registerMetadata(const QCtfTraceMetadata &metadata);
79 int eventId();
80 void shutdown(bool *) override
81 {
82
83 }
84
85 static QCtfLib *instance();
86 static void cleanup();
87private:
88 static QCtfLibImpl *s_instance;
90 void updateMetadata(const QCtfTracePointEvent &point);
91 void writeMetadata(const QString &metadata, bool overwrite = false);
92 static void writeCtfPacket(Channel &ch);
93
94 static constexpr QUuid s_TraceUuid = QUuid(0x3e589c95, 0xed11, 0xc159, 0x42, 0x02, 0x6a, 0x9b, 0x02, 0x00, 0x12, 0xac);
95 static constexpr quint32 s_CtfHeaderMagic = 0xC1FC1FC1;
96
97 QMutex m_mutex;
98 QElapsedTimer m_timer;
99 QString m_metadata;
100 QString m_location;
101 Session m_session;
102 QHash<QThread*, quint32> m_threadIndices;
103 QThreadStorage<Channel> m_threadData;
105 QSet<QString> m_newAdditionalMetadata;
106 int m_eventId = 0;
107};
108
110
111#endif
\inmodule QtCore
Definition qbytearray.h:57
int eventId()
Definition qctflib.cpp:316
static QCtfLib * instance()
Definition qctflib.cpp:43
static void cleanup()
Definition qctflib.cpp:50
bool sessionEnabled() override
Definition qctflib.cpp:311
void registerMetadata(const QCtfTraceMetadata &metadata)
Definition qctflib.cpp:321
bool tracepointEnabled(const QCtfTracePointEvent &point) override
Definition qctflib.cpp:186
QCtfTracePointPrivate * initializeTracepoint(const QCtfTracePointEvent &point) override
Definition qctflib.cpp:219
void doTracepoint(const QCtfTracePointEvent &point, const QByteArray &arr) override
Definition qctflib.cpp:236
void shutdown(bool *) override
Definition qctflib_p.h:80
\inmodule QtCore
\inmodule QtCore
Definition qhash.h:818
\inmodule QtCore
Definition qmutex.h:285
Definition qset.h:18
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
\inmodule QtCore
Definition quuid.h:31
Combined button and popup list for selecting options.
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint name
unsigned int quint32
Definition qtypes.h:45
unsigned long long quint64
Definition qtypes.h:56