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
qqmldebug.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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#include "qqmldebug.h"
7
8#include <private/qqmlengine_p.h>
9#include <private/qv4compileddata_p.h>
10
11#include <atomic>
12#include <cstdio>
13
15
17
18#if __cplusplus >= 202002L
19# define Q_ATOMIC_FLAG_INIT {}
20#else
21# define Q_ATOMIC_FLAG_INIT ATOMIC_FLAG_INIT // deprecated in C++20
22#endif
23
24Q_CONSTINIT static std::atomic_flag s_printedWarning = Q_ATOMIC_FLAG_INIT;
25
26void QQmlDebuggingEnabler::enableDebugging(bool printWarning)
27{
28 if (printWarning && !s_printedWarning.test_and_set(std::memory_order_relaxed))
29 fprintf(stderr, "QML debugging is enabled. Only use this in a safe environment.\n");
30 QQmlEnginePrivate::qml_debugging_enabled.store(true, std::memory_order_relaxed);
31}
32
33#if QT_DEPRECATED_SINCE(6, 4)
34QQmlDebuggingEnabler::QQmlDebuggingEnabler(bool printWarning)
35{
36 enableDebugging(printWarning);
37};
38#endif // QT_DEPRECATED_SINCE(6, 4)
39
46QStringList QQmlDebuggingEnabler::debuggerServices()
47{
48 return {QV4DebugService::s_key, QQmlEngineDebugService::s_key, QDebugMessageService::s_key};
49}
50
56QStringList QQmlDebuggingEnabler::inspectorServices()
57{
58 return {QQmlInspectorService::s_key};
59}
60
67QStringList QQmlDebuggingEnabler::profilerServices()
68{
69 return {QQmlProfilerService::s_key, QQmlEngineControlService::s_key, QDebugMessageService::s_key};
70}
71
78QStringList QQmlDebuggingEnabler::nativeDebuggerServices()
79{
80 return {QQmlNativeDebugService::s_key};
81}
82
95void QQmlDebuggingEnabler::setServices(const QStringList &services)
96{
97 QQmlDebugConnector::setServices(services);
98}
99
120bool QQmlDebuggingEnabler::startTcpDebugServer(int port, StartMode mode, const QString &hostName)
121{
122 QVariantHash configuration;
123 configuration[QLatin1String("portFrom")] = configuration[QLatin1String("portTo")] = port;
124 configuration[QLatin1String("block")] = (mode == WaitForClient);
125 configuration[QLatin1String("hostAddress")] = hostName;
126 return startDebugConnector(QLatin1String("QQmlDebugServer"), configuration);
127}
128
139bool QQmlDebuggingEnabler::connectToLocalDebugger(const QString &socketFileName, StartMode mode)
140{
141 QVariantHash configuration;
142 configuration[QLatin1String("fileName")] = socketFileName;
143 configuration[QLatin1String("block")] = (mode == WaitForClient);
144 return startDebugConnector(QLatin1String("QQmlDebugServer"), configuration);
145}
146
157bool QQmlDebuggingEnabler::startDebugConnector(const QString &pluginName,
158 const QVariantHash &configuration)
159{
160 QQmlDebugConnector::setPluginKey(pluginName);
162 return connector ? connector->open(configuration) : false;
163}
164
165enum { HookCount = 4 };
166
167// Only add to the end, and bump version if you do.
169 // Version of this Array. Bump if you add to end.
170 2,
171
172 // Number of entries in this array.
173 HookCount,
174
175 // TypeInformationVersion, an integral value, bumped whenever private
176 // object sizes or member offsets that are used in Qt Creator's
177 // data structure "pretty printing" change.
178 4,
179
180 // Version of the cache data.
182};
183
185
std::vector< ObjCStrongReference< CBMutableService > > services
static QQmlDebugConnector * instance()
static std::atomic< bool > qml_debugging_enabled
\qmltype QtObject \instantiates QObject \inqmlmodule QtQml
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
#define Q_STATIC_ASSERT(Condition)
Definition qassert.h:108
EGLOutputPortEXT port
GLenum mode
#define Q_ATOMIC_FLAG_INIT
Definition qqmldebug.cpp:21
@ HookCount
quintptr Q_QML_EXPORT qtDeclarativeHookData[]
static Q_CONSTINIT std::atomic_flag s_printedWarning
Definition qqmldebug.cpp:24
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
#define QT_REQUIRE_CONFIG(feature)
size_t quintptr
Definition qtypes.h:167
#define QV4_DATA_STRUCTURE_VERSION