Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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#include "qctfserver_p.h"
30
32
34
36{
38 quint32 id = 0;
39 quint32 payloadSize = 0;
40 bool metadataWritten = false;
41};
42
44{
45 struct Session
46 {
48 QStringList tracepoints;
49 bool all = false;
50 };
51 struct Channel
52 {
53 char channelName[512];
55 quint64 minTimestamp = 0;
56 quint64 maxTimestamp = 0;
57 quint64 seqnumber = 0;
58 QThread *thread = nullptr;
59 quint32 threadIndex = 0;
60 QByteArray threadName;
61 quint32 threadNameLength = 0;
62 bool locked = false;
63 QCtfLibImpl *impl = nullptr;
64 Channel()
65 {
66 memset(channelName, 0, sizeof(channelName));
67 }
68
69 ~Channel();
70 };
71
72public:
75
76 bool tracepointEnabled(const QCtfTracePointEvent &point) override;
77 void doTracepoint(const QCtfTracePointEvent &point, const QByteArray &arr) override;
78 bool sessionEnabled() override;
80 void registerMetadata(const QCtfTraceMetadata &metadata);
81 int eventId();
82 void shutdown(bool *) override
83 {
84
85 }
86
87 static QCtfLib *instance();
88 static void cleanup();
89private:
90 static QCtfLibImpl *s_instance;
91 QHash<QString, QCtfTracePointPrivate *> m_eventPrivs;
92 void removeChannel(Channel *ch);
93 void updateMetadata(const QCtfTracePointEvent &point);
94 void writeMetadata(const QString &metadata, bool overwrite = false);
95 void clearLocation();
96 void handleSessionChange() override;
97 void handleStatusChange(QCtfServer::ServerStatus status) override;
98 void writeCtfPacket(Channel &ch);
99 void buildMetadata();
100
101 static constexpr QUuid s_TraceUuid = QUuid(0x3e589c95, 0xed11, 0xc159, 0x42, 0x02, 0x6a, 0x9b, 0x02, 0x00, 0x12, 0xac);
102 static constexpr quint32 s_CtfHeaderMagic = 0xC1FC1FC1;
103
104 QMutex m_mutex;
105 QElapsedTimer m_timer;
106 QString m_metadata;
107 QString m_location;
108 Session m_session;
109 QHash<QThread*, quint32> m_threadIndices;
110 QThreadStorage<Channel> m_threadData;
111 QList<Channel *> m_channels;
112 QHash<QString, const QCtfTraceMetadata *> m_additionalMetadata;
113 QSet<QString> m_newAdditionalMetadata;
114 QDateTime m_datetime;
115 int m_eventId = 0;
116 bool m_streaming = false;
117 std::atomic_bool m_sessionChanged = false;
118 std::atomic_bool m_serverClosed = false;
119 QScopedPointer<QCtfServer> m_server;
120 friend struct Channel;
121};
122
124
125#endif
\inmodule QtCore
Definition qbytearray.h:57
void handleStatusChange(QCtfServer::ServerStatus status) override
Definition qctflib.cpp:77
int eventId()
Definition qctflib.cpp:433
static QCtfLib * instance()
Definition qctflib.cpp:59
static void cleanup()
Definition qctflib.cpp:66
bool sessionEnabled() override
Definition qctflib.cpp:428
void registerMetadata(const QCtfTraceMetadata &metadata)
Definition qctflib.cpp:438
bool tracepointEnabled(const QCtfTracePointEvent &point) override
Definition qctflib.cpp:291
QCtfTracePointPrivate * initializeTracepoint(const QCtfTracePointEvent &point) override
Definition qctflib.cpp:336
friend struct Channel
Definition qctflib_p.h:120
void handleSessionChange() override
Definition qctflib.cpp:72
void doTracepoint(const QCtfTracePointEvent &point, const QByteArray &arr) override
Definition qctflib.cpp:353
void shutdown(bool *) override
Definition qctflib_p.h:82
\inmodule QtCore\reentrant
Definition qdatetime.h:283
\inmodule QtCore
\inmodule QtCore
Definition qmutex.h:281
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\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:50
unsigned long long quint64
Definition qtypes.h:61