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#ifndef QV4DEBUGSERVICE_H
5#define QV4DEBUGSERVICE_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#include "qv4debuggeragent.h"
19#include "qv4datacollector.h"
20#include <private/qqmlconfigurabledebugservice_p.h>
21#include <private/qqmldebugserviceinterfaces_p.h>
22#include <private/qv4debugging_p.h>
23
24#include <QtCore/QJsonValue>
25
26QT_BEGIN_NAMESPACE
27
28namespace QV4 { struct ExecutionEngine; }
29
30class VariableCollector;
31class V4CommandHandler;
32class UnknownV4CommandHandler;
33class QV4DebugServiceImpl;
34
35class QV4DebugServiceImpl : public QQmlConfigurableDebugService<QV4DebugService>
36{
37 Q_OBJECT
38public:
39 explicit QV4DebugServiceImpl(QObject *parent = nullptr);
40 ~QV4DebugServiceImpl() override;
41
42 void engineAdded(QJSEngine *engine) override;
43 void engineAboutToBeRemoved(QJSEngine *engine) override;
44
45 void stateAboutToBeChanged(State state) override;
46
47 void signalEmitted(const QString &signal) override;
48 void send(QJsonObject v4Payload);
49
50 int selectedFrame() const;
51 void selectFrame(int frameNr);
52
53 QV4DebuggerAgent debuggerAgent;
54
55protected:
56 void messageReceived(const QByteArray &) override;
57 void sendSomethingToSomebody(const char *type, int magicNumber = 1);
58
59private:
60 friend class QQmlDebuggerServiceFactory;
61
62 void handleV4Request(const QByteArray &payload);
63 static QByteArray packMessage(const QByteArray &command,
64 const QByteArray &message = QByteArray());
65 void processCommand(const QByteArray &command, const QByteArray &data);
66 V4CommandHandler *v4CommandHandler(const QString &command) const;
67
68 QStringList breakOnSignals;
69 static int sequence;
70 int theSelectedFrame;
71
72 void addHandler(V4CommandHandler* handler);
73 QHash<QString, V4CommandHandler*> handlers;
74 QScopedPointer<UnknownV4CommandHandler> unknownV4CommandHandler;
75};
76
77QT_END_NAMESPACE
78
79#endif // QV4DEBUGSERVICE_H
80

source code of qtdeclarative/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h