1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include <debugger/debuggerengine.h>
#include <utils/qtcprocess.h>
#include <QLoggingCategory>
namespace Debugger::Internal {
class IDataProvider : public QObject
{
Q_OBJECT
public:
IDataProvider(QObject *parent = nullptr) : QObject(parent) {}
~IDataProvider() override = default;
virtual void start() = 0;
virtual bool isRunning() const = 0;
virtual void writeRaw(const QByteArray &input) = 0;
virtual void kill() = 0;
virtual QByteArray readAllStandardOutput() = 0;
virtual QString readAllStandardError() = 0;
virtual int exitCode() const = 0;
virtual QString executable() const = 0;
virtual QProcess::ExitStatus exitStatus() const = 0;
virtual QProcess::ProcessError error() const = 0;
virtual Utils::ProcessResult result() const = 0;
virtual QString exitMessage() const = 0;
signals:
void started();
void done();
void readyReadStandardOutput();
void readyReadStandardError();
};
enum class DapResponseType
{
Initialize,
ConfigurationDone,
Continue,
StackTrace,
Scopes,
DapThreads,
Variables,
StepIn,
StepOut,
StepOver,
Pause,
Evaluate,
SetBreakpoints,
SetFunctionBreakpoints,
Attach,
Launch,
Unknown
};
enum class DapEventType
{
Initialized,
Stopped,
Exited,
DapThread,
Output,
DapBreakpoint,
Unknown
};
struct Capabilities
{
bool supportsConfigurationDoneRequest = false;
bool supportsFunctionBreakpoints = false;
bool supportsConditionalBreakpoints = false;
bool supportsHitConditionalBreakpoints = false;
bool supportsEvaluateForHovers = false;
bool supportsStepBack = false;
bool supportsSetVariable = false;
bool supportsRestartFrame = false;
bool supportsGotoTargetsRequest = false;
bool supportsStepInTargetsRequest = false;
bool supportsCompletionsRequest = false;
bool supportsModulesRequest = false;
bool supportsRestartRequest = false;
bool supportsExceptionOptions = false;
bool supportsValueFormattingOptions = false;
bool supportsExceptionInfoRequest = false;
bool supportTerminateDebuggee = false;
bool supportSuspendDebuggee = false;
bool supportsDelayedStackTraceLoading = false;
bool supportsLoadedSourcesRequest = false;
bool supportsLogPoints = false;
bool supportsTerminateThreadsRequest = false;
bool supportsSetExpression = false;
bool supportsTerminateRequest = false;
bool supportsDataBreakpoints = false;
bool supportsReadMemoryRequest = false;
bool supportsWriteMemoryRequest = false;
bool supportsDisassembleRequest = false;
bool supportsCancelRequest = false;
bool supportsBreakpointLocationsRequest = false;
bool supportsClipboardContext = false;
bool supportsSteppingGranularity = false;
bool supportsInstructionBreakpoints = false;
bool supportsExceptionFilterOptions = false;
bool supportsSingleThreadExecutionRequests = false;
// exceptionBreakpointFilters?: ExceptionBreakpointsFilter[];
// completionTriggerCharacters?: string[];
// additionalModuleColumns?: ColumnDescriptor[];
// supportedChecksumAlgorithms?: ChecksumAlgorithm[];
};
class DapClient : public QObject
{
Q_OBJECT
public:
DapClient(IDataProvider *dataProvider, QObject *parent = nullptr);
~DapClient() override;
IDataProvider *dataProvider() const { return m_dataProvider; }
void postRequest(const QString &command, const QJsonObject &arguments = {});
virtual void sendInitialize();
void sendLaunch(const Utils::CommandLine &command);
void sendAttach();
void sendConfigurationDone();
void sendDisconnect();
void sendTerminate();
void sendPause();
void sendContinue(int threadId);
void sendStepIn(int threadId);
void sendStepOut(int threadId);
void sendStepOver(int threadId);
void evaluateVariable(const QString &expression, int frameId);
void stackTrace(int threadId);
void scopes(int frameId);
void threads();
void variables(int variablesReference);
void setBreakpoints(const QJsonArray &breakpoints, const Utils::FilePath &fileName);
void setFunctionBreakpoints(const QJsonArray &breakpoints);
void emitSignals(const QJsonDocument &doc);
void fillCapabilities(const QJsonObject &response);
Capabilities capabilities() const { return m_capabilities; }
signals:
void started();
void done();
void readyReadStandardError();
void responseReady(DapResponseType type, const QJsonObject &response);
void eventReady(DapEventType type, const QJsonObject &response);
private:
void readOutput();
virtual const QLoggingCategory &logCategory()
{
static const QLoggingCategory logCategory = QLoggingCategory("qtc.dbg.dapengine",
QtWarningMsg);
return logCategory;
}
IDataProvider *m_dataProvider = nullptr;
QByteArray m_inbuffer;
Capabilities m_capabilities;
};
} // namespace Debugger::Internal
|