-
Notifications
You must be signed in to change notification settings - Fork 0
/
DebugSession.cs
executable file
·258 lines (216 loc) · 5.81 KB
/
DebugSession.cs
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace VSCodeDebug
{
// ---- Types -------------------------------------------------------------------------
public class Message {
public int id { get; }
public string format { get; }
public dynamic variables { get; }
public dynamic showUser { get; }
public dynamic sendTelemetry { get; }
public Message(int id, string format, dynamic variables = null, bool user = true, bool telemetry = false) {
this.id = id;
this.format = format;
this.variables = variables;
this.showUser = user;
this.sendTelemetry = telemetry;
}
}
public class StackFrame
{
public int id { get; }
public Source source { get; }
public int line { get; }
public int column { get; }
public string name { get; }
public StackFrame(int id, string name, Source source, int line, int column) {
this.id = id;
this.name = name;
this.source = source;
this.line = line;
this.column = column;
}
}
public class Scope
{
public string name { get; }
public int variablesReference { get; }
public bool expensive { get; }
public Scope(string name, int variablesReference, bool expensive = false) {
this.name = name;
this.variablesReference = variablesReference;
this.expensive = expensive;
}
}
public class Variable
{
public string name { get; }
public string value { get; }
public int variablesReference { get; }
public Variable(string name, string value, int variablesReference = 0) {
this.name = name;
this.value = value;
this.variablesReference = variablesReference;
}
}
public class Thread
{
public int id { get; }
public string name { get; }
public Thread(int id, string name) {
this.id = id;
if (name == null || name.Length == 0) {
this.name = string.Format("Thread #{0}", id);
}
else {
this.name = name;
}
}
}
public class Source
{
public string name { get; }
public string path { get; }
public int sourceReference { get; }
public Source(string name, string path, int sourceReference = 0) {
this.name = name;
this.path = path;
this.sourceReference = sourceReference;
}
public Source(string path, int sourceReference = 0) {
this.name = Path.GetFileName(path);
this.path = path;
this.sourceReference = sourceReference;
}
}
public class Breakpoint
{
public bool verified { get; }
public int line { get; }
public Breakpoint(bool verified, int line) {
this.verified = verified;
this.line = line;
}
}
// ---- Events -------------------------------------------------------------------------
public class InitializedEvent : Event
{
public InitializedEvent()
: base("initialized") { }
}
public class StoppedEvent : Event
{
public StoppedEvent(int tid, string reasn, string txt = null)
: base("stopped", new {
threadId = tid,
reason = reasn,
text = txt
}) { }
}
public class ExitedEvent : Event
{
public ExitedEvent(int exCode)
: base("exited", new { exitCode = exCode } ) { }
}
public class TerminatedEvent : Event
{
public TerminatedEvent()
: base("terminated") { }
}
public class ThreadEvent : Event
{
public ThreadEvent(string reasn, int tid)
: base("thread", new {
reason = reasn,
threadId = tid
}) { }
}
public class OutputEvent : Event
{
public OutputEvent(string cat, string outpt)
: base("output", new {
category = cat,
output = outpt
}) { }
}
// ---- Response -------------------------------------------------------------------------
public class Capabilities : ResponseBody {
public bool supportsConfigurationDoneRequest;
public bool supportsFunctionBreakpoints;
public bool supportsConditionalBreakpoints;
public bool supportsEvaluateForHovers;
public dynamic[] exceptionBreakpointFilters;
}
public class ErrorResponseBody : ResponseBody {
public Message error { get; }
public ErrorResponseBody(Message error) {
this.error = error;
}
}
public class StackTraceResponseBody : ResponseBody
{
public StackFrame[] stackFrames { get; }
public StackTraceResponseBody(List<StackFrame> frames = null) {
if (frames == null)
stackFrames = new StackFrame[0];
else
stackFrames = frames.ToArray<StackFrame>();
}
}
public class ScopesResponseBody : ResponseBody
{
public Scope[] scopes { get; }
public ScopesResponseBody(List<Scope> scps = null) {
if (scps == null)
scopes = new Scope[0];
else
scopes = scps.ToArray<Scope>();
}
}
public class VariablesResponseBody : ResponseBody
{
public Variable[] variables { get; }
public VariablesResponseBody(List<Variable> vars = null) {
if (vars == null)
variables = new Variable[0];
else
variables = vars.ToArray<Variable>();
}
}
public class ThreadsResponseBody : ResponseBody
{
public Thread[] threads { get; }
public ThreadsResponseBody(List<Thread> vars = null) {
if (vars == null)
threads = new Thread[0];
else
threads = vars.ToArray<Thread>();
}
}
public class EvaluateResponseBody : ResponseBody
{
public string result { get; }
public int variablesReference { get; }
public EvaluateResponseBody(string value, int reff = 0) {
result = value;
variablesReference = reff;
}
}
public class SetBreakpointsResponseBody : ResponseBody
{
public Breakpoint[] breakpoints { get; }
public SetBreakpointsResponseBody(List<Breakpoint> bpts = null) {
if (bpts == null)
breakpoints = new Breakpoint[0];
else
breakpoints = bpts.ToArray<Breakpoint>();
}
}
}