Line data Source code
1 : // This file is generated
2 :
3 : // Copyright (c) 2016 The Chromium Authors. All rights reserved.
4 : // Use of this source code is governed by a BSD-style license that can be
5 : // found in the LICENSE file.
6 :
7 : #include "src/inspector/protocol/Debugger.h"
8 :
9 : #include "src/inspector/protocol/Protocol.h"
10 :
11 : namespace v8_inspector {
12 : namespace protocol {
13 : namespace Debugger {
14 :
15 : // ------------- Enum values from types.
16 :
17 : const char Metainfo::domainName[] = "Debugger";
18 : const char Metainfo::commandPrefix[] = "Debugger.";
19 : const char Metainfo::version[] = "1.2";
20 :
21 1289318 : std::unique_ptr<Location> Location::fromValue(protocol::Value* value, ErrorSupport* errors)
22 : {
23 1289318 : if (!value || value->type() != protocol::Value::TypeObject) {
24 12 : errors->addError("object expected");
25 : return nullptr;
26 : }
27 :
28 644656 : std::unique_ptr<Location> result(new Location());
29 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
30 644656 : errors->push();
31 1289312 : protocol::Value* scriptIdValue = object->get("scriptId");
32 1289312 : errors->setName("scriptId");
33 1289312 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
34 1289312 : protocol::Value* lineNumberValue = object->get("lineNumber");
35 1289312 : errors->setName("lineNumber");
36 644656 : result->m_lineNumber = ValueConversions<int>::fromValue(lineNumberValue, errors);
37 1289312 : protocol::Value* columnNumberValue = object->get("columnNumber");
38 644656 : if (columnNumberValue) {
39 1288820 : errors->setName("columnNumber");
40 644410 : result->m_columnNumber = ValueConversions<int>::fromValue(columnNumberValue, errors);
41 : }
42 644656 : errors->pop();
43 644656 : if (errors->hasErrors())
44 : return nullptr;
45 : return result;
46 : }
47 :
48 644140 : std::unique_ptr<protocol::DictionaryValue> Location::toValue() const
49 : {
50 644140 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
51 3220700 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
52 3220700 : result->setValue("lineNumber", ValueConversions<int>::toValue(m_lineNumber));
53 644140 : if (m_columnNumber.isJust())
54 2576560 : result->setValue("columnNumber", ValueConversions<int>::toValue(m_columnNumber.fromJust()));
55 644140 : return result;
56 : }
57 :
58 0 : std::unique_ptr<Location> Location::clone() const
59 : {
60 0 : ErrorSupport errors;
61 0 : return fromValue(toValue().get(), &errors);
62 : }
63 :
64 228 : std::unique_ptr<ScriptPosition> ScriptPosition::fromValue(protocol::Value* value, ErrorSupport* errors)
65 : {
66 228 : if (!value || value->type() != protocol::Value::TypeObject) {
67 0 : errors->addError("object expected");
68 : return nullptr;
69 : }
70 :
71 114 : std::unique_ptr<ScriptPosition> result(new ScriptPosition());
72 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
73 114 : errors->push();
74 228 : protocol::Value* lineNumberValue = object->get("lineNumber");
75 228 : errors->setName("lineNumber");
76 114 : result->m_lineNumber = ValueConversions<int>::fromValue(lineNumberValue, errors);
77 228 : protocol::Value* columnNumberValue = object->get("columnNumber");
78 228 : errors->setName("columnNumber");
79 114 : result->m_columnNumber = ValueConversions<int>::fromValue(columnNumberValue, errors);
80 114 : errors->pop();
81 114 : if (errors->hasErrors())
82 : return nullptr;
83 : return result;
84 : }
85 :
86 0 : std::unique_ptr<protocol::DictionaryValue> ScriptPosition::toValue() const
87 : {
88 0 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
89 0 : result->setValue("lineNumber", ValueConversions<int>::toValue(m_lineNumber));
90 0 : result->setValue("columnNumber", ValueConversions<int>::toValue(m_columnNumber));
91 0 : return result;
92 : }
93 :
94 0 : std::unique_ptr<ScriptPosition> ScriptPosition::clone() const
95 : {
96 0 : ErrorSupport errors;
97 0 : return fromValue(toValue().get(), &errors);
98 : }
99 :
100 382664 : std::unique_ptr<CallFrame> CallFrame::fromValue(protocol::Value* value, ErrorSupport* errors)
101 : {
102 382664 : if (!value || value->type() != protocol::Value::TypeObject) {
103 0 : errors->addError("object expected");
104 : return nullptr;
105 : }
106 :
107 191332 : std::unique_ptr<CallFrame> result(new CallFrame());
108 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
109 191332 : errors->push();
110 382664 : protocol::Value* callFrameIdValue = object->get("callFrameId");
111 382664 : errors->setName("callFrameId");
112 382664 : result->m_callFrameId = ValueConversions<String>::fromValue(callFrameIdValue, errors);
113 382664 : protocol::Value* functionNameValue = object->get("functionName");
114 382664 : errors->setName("functionName");
115 382664 : result->m_functionName = ValueConversions<String>::fromValue(functionNameValue, errors);
116 382664 : protocol::Value* functionLocationValue = object->get("functionLocation");
117 191332 : if (functionLocationValue) {
118 381916 : errors->setName("functionLocation");
119 190958 : result->m_functionLocation = ValueConversions<protocol::Debugger::Location>::fromValue(functionLocationValue, errors);
120 : }
121 382664 : protocol::Value* locationValue = object->get("location");
122 382664 : errors->setName("location");
123 191332 : result->m_location = ValueConversions<protocol::Debugger::Location>::fromValue(locationValue, errors);
124 382664 : protocol::Value* scopeChainValue = object->get("scopeChain");
125 382664 : errors->setName("scopeChain");
126 191332 : result->m_scopeChain = ValueConversions<protocol::Array<protocol::Debugger::Scope>>::fromValue(scopeChainValue, errors);
127 382664 : protocol::Value* thisValue = object->get("this");
128 382664 : errors->setName("this");
129 191332 : result->m_this = ValueConversions<protocol::Runtime::RemoteObject>::fromValue(thisValue, errors);
130 382664 : protocol::Value* returnValueValue = object->get("returnValue");
131 191332 : if (returnValueValue) {
132 17372 : errors->setName("returnValue");
133 8686 : result->m_returnValue = ValueConversions<protocol::Runtime::RemoteObject>::fromValue(returnValueValue, errors);
134 : }
135 191332 : errors->pop();
136 191332 : if (errors->hasErrors())
137 : return nullptr;
138 : return result;
139 : }
140 :
141 191332 : std::unique_ptr<protocol::DictionaryValue> CallFrame::toValue() const
142 : {
143 191332 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
144 956660 : result->setValue("callFrameId", ValueConversions<String>::toValue(m_callFrameId));
145 956660 : result->setValue("functionName", ValueConversions<String>::toValue(m_functionName));
146 191332 : if (m_functionLocation.isJust())
147 763832 : result->setValue("functionLocation", ValueConversions<protocol::Debugger::Location>::toValue(m_functionLocation.fromJust()));
148 765328 : result->setValue("location", ValueConversions<protocol::Debugger::Location>::toValue(m_location.get()));
149 765328 : result->setValue("scopeChain", ValueConversions<protocol::Array<protocol::Debugger::Scope>>::toValue(m_scopeChain.get()));
150 765328 : result->setValue("this", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_this.get()));
151 191332 : if (m_returnValue.isJust())
152 34744 : result->setValue("returnValue", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_returnValue.fromJust()));
153 191332 : return result;
154 : }
155 :
156 0 : std::unique_ptr<CallFrame> CallFrame::clone() const
157 : {
158 0 : ErrorSupport errors;
159 0 : return fromValue(toValue().get(), &errors);
160 : }
161 :
162 : const char* Scope::TypeEnum::Global = "global";
163 : const char* Scope::TypeEnum::Local = "local";
164 : const char* Scope::TypeEnum::With = "with";
165 : const char* Scope::TypeEnum::Closure = "closure";
166 : const char* Scope::TypeEnum::Catch = "catch";
167 : const char* Scope::TypeEnum::Block = "block";
168 : const char* Scope::TypeEnum::Script = "script";
169 : const char* Scope::TypeEnum::Eval = "eval";
170 : const char* Scope::TypeEnum::Module = "module";
171 :
172 993704 : std::unique_ptr<Scope> Scope::fromValue(protocol::Value* value, ErrorSupport* errors)
173 : {
174 993704 : if (!value || value->type() != protocol::Value::TypeObject) {
175 0 : errors->addError("object expected");
176 : return nullptr;
177 : }
178 :
179 496852 : std::unique_ptr<Scope> result(new Scope());
180 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
181 496852 : errors->push();
182 993704 : protocol::Value* typeValue = object->get("type");
183 993704 : errors->setName("type");
184 993704 : result->m_type = ValueConversions<String>::fromValue(typeValue, errors);
185 993704 : protocol::Value* objectValue = object->get("object");
186 993704 : errors->setName("object");
187 496852 : result->m_object = ValueConversions<protocol::Runtime::RemoteObject>::fromValue(objectValue, errors);
188 993704 : protocol::Value* nameValue = object->get("name");
189 496852 : if (nameValue) {
190 232592 : errors->setName("name");
191 232592 : result->m_name = ValueConversions<String>::fromValue(nameValue, errors);
192 : }
193 993704 : protocol::Value* startLocationValue = object->get("startLocation");
194 496852 : if (startLocationValue) {
195 259444 : errors->setName("startLocation");
196 129722 : result->m_startLocation = ValueConversions<protocol::Debugger::Location>::fromValue(startLocationValue, errors);
197 : }
198 993704 : protocol::Value* endLocationValue = object->get("endLocation");
199 496852 : if (endLocationValue) {
200 259444 : errors->setName("endLocation");
201 129722 : result->m_endLocation = ValueConversions<protocol::Debugger::Location>::fromValue(endLocationValue, errors);
202 : }
203 496852 : errors->pop();
204 496852 : if (errors->hasErrors())
205 : return nullptr;
206 : return result;
207 : }
208 :
209 496852 : std::unique_ptr<protocol::DictionaryValue> Scope::toValue() const
210 : {
211 496852 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
212 2484260 : result->setValue("type", ValueConversions<String>::toValue(m_type));
213 1987408 : result->setValue("object", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_object.get()));
214 496852 : if (m_name.isJust())
215 581480 : result->setValue("name", ValueConversions<String>::toValue(m_name.fromJust()));
216 496852 : if (m_startLocation.isJust())
217 518888 : result->setValue("startLocation", ValueConversions<protocol::Debugger::Location>::toValue(m_startLocation.fromJust()));
218 496852 : if (m_endLocation.isJust())
219 518888 : result->setValue("endLocation", ValueConversions<protocol::Debugger::Location>::toValue(m_endLocation.fromJust()));
220 496852 : return result;
221 : }
222 :
223 0 : std::unique_ptr<Scope> Scope::clone() const
224 : {
225 0 : ErrorSupport errors;
226 0 : return fromValue(toValue().get(), &errors);
227 : }
228 :
229 0 : std::unique_ptr<SearchMatch> SearchMatch::fromValue(protocol::Value* value, ErrorSupport* errors)
230 : {
231 0 : if (!value || value->type() != protocol::Value::TypeObject) {
232 0 : errors->addError("object expected");
233 : return nullptr;
234 : }
235 :
236 0 : std::unique_ptr<SearchMatch> result(new SearchMatch());
237 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
238 0 : errors->push();
239 0 : protocol::Value* lineNumberValue = object->get("lineNumber");
240 0 : errors->setName("lineNumber");
241 0 : result->m_lineNumber = ValueConversions<double>::fromValue(lineNumberValue, errors);
242 0 : protocol::Value* lineContentValue = object->get("lineContent");
243 0 : errors->setName("lineContent");
244 0 : result->m_lineContent = ValueConversions<String>::fromValue(lineContentValue, errors);
245 0 : errors->pop();
246 0 : if (errors->hasErrors())
247 : return nullptr;
248 : return result;
249 : }
250 :
251 0 : std::unique_ptr<protocol::DictionaryValue> SearchMatch::toValue() const
252 : {
253 0 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
254 0 : result->setValue("lineNumber", ValueConversions<double>::toValue(m_lineNumber));
255 0 : result->setValue("lineContent", ValueConversions<String>::toValue(m_lineContent));
256 0 : return result;
257 : }
258 :
259 0 : std::unique_ptr<SearchMatch> SearchMatch::clone() const
260 : {
261 0 : ErrorSupport errors;
262 0 : return fromValue(toValue().get(), &errors);
263 : }
264 :
265 0 : std::unique_ptr<StringBuffer> SearchMatch::toJSONString() const
266 : {
267 0 : String json = toValue()->serialize();
268 0 : return StringBufferImpl::adopt(json);
269 : }
270 :
271 : // static
272 0 : std::unique_ptr<API::SearchMatch> API::SearchMatch::fromJSONString(const StringView& json)
273 : {
274 0 : ErrorSupport errors;
275 0 : std::unique_ptr<Value> value = StringUtil::parseJSON(json);
276 0 : if (!value)
277 : return nullptr;
278 0 : return protocol::Debugger::SearchMatch::fromValue(value.get(), &errors);
279 : }
280 :
281 : const char* BreakLocation::TypeEnum::DebuggerStatement = "debuggerStatement";
282 : const char* BreakLocation::TypeEnum::Call = "call";
283 : const char* BreakLocation::TypeEnum::Return = "return";
284 :
285 0 : std::unique_ptr<BreakLocation> BreakLocation::fromValue(protocol::Value* value, ErrorSupport* errors)
286 : {
287 0 : if (!value || value->type() != protocol::Value::TypeObject) {
288 0 : errors->addError("object expected");
289 : return nullptr;
290 : }
291 :
292 0 : std::unique_ptr<BreakLocation> result(new BreakLocation());
293 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
294 0 : errors->push();
295 0 : protocol::Value* scriptIdValue = object->get("scriptId");
296 0 : errors->setName("scriptId");
297 0 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
298 0 : protocol::Value* lineNumberValue = object->get("lineNumber");
299 0 : errors->setName("lineNumber");
300 0 : result->m_lineNumber = ValueConversions<int>::fromValue(lineNumberValue, errors);
301 0 : protocol::Value* columnNumberValue = object->get("columnNumber");
302 0 : if (columnNumberValue) {
303 0 : errors->setName("columnNumber");
304 0 : result->m_columnNumber = ValueConversions<int>::fromValue(columnNumberValue, errors);
305 : }
306 0 : protocol::Value* typeValue = object->get("type");
307 0 : if (typeValue) {
308 0 : errors->setName("type");
309 0 : result->m_type = ValueConversions<String>::fromValue(typeValue, errors);
310 : }
311 0 : errors->pop();
312 0 : if (errors->hasErrors())
313 : return nullptr;
314 : return result;
315 : }
316 :
317 2838 : std::unique_ptr<protocol::DictionaryValue> BreakLocation::toValue() const
318 : {
319 2838 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
320 14190 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
321 14190 : result->setValue("lineNumber", ValueConversions<int>::toValue(m_lineNumber));
322 2838 : if (m_columnNumber.isJust())
323 11352 : result->setValue("columnNumber", ValueConversions<int>::toValue(m_columnNumber.fromJust()));
324 2838 : if (m_type.isJust())
325 8250 : result->setValue("type", ValueConversions<String>::toValue(m_type.fromJust()));
326 2838 : return result;
327 : }
328 :
329 0 : std::unique_ptr<BreakLocation> BreakLocation::clone() const
330 : {
331 0 : ErrorSupport errors;
332 0 : return fromValue(toValue().get(), &errors);
333 : }
334 :
335 0 : std::unique_ptr<ScriptParsedNotification> ScriptParsedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
336 : {
337 0 : if (!value || value->type() != protocol::Value::TypeObject) {
338 0 : errors->addError("object expected");
339 : return nullptr;
340 : }
341 :
342 0 : std::unique_ptr<ScriptParsedNotification> result(new ScriptParsedNotification());
343 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
344 0 : errors->push();
345 0 : protocol::Value* scriptIdValue = object->get("scriptId");
346 0 : errors->setName("scriptId");
347 0 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
348 0 : protocol::Value* urlValue = object->get("url");
349 0 : errors->setName("url");
350 0 : result->m_url = ValueConversions<String>::fromValue(urlValue, errors);
351 0 : protocol::Value* startLineValue = object->get("startLine");
352 0 : errors->setName("startLine");
353 0 : result->m_startLine = ValueConversions<int>::fromValue(startLineValue, errors);
354 0 : protocol::Value* startColumnValue = object->get("startColumn");
355 0 : errors->setName("startColumn");
356 0 : result->m_startColumn = ValueConversions<int>::fromValue(startColumnValue, errors);
357 0 : protocol::Value* endLineValue = object->get("endLine");
358 0 : errors->setName("endLine");
359 0 : result->m_endLine = ValueConversions<int>::fromValue(endLineValue, errors);
360 0 : protocol::Value* endColumnValue = object->get("endColumn");
361 0 : errors->setName("endColumn");
362 0 : result->m_endColumn = ValueConversions<int>::fromValue(endColumnValue, errors);
363 0 : protocol::Value* executionContextIdValue = object->get("executionContextId");
364 0 : errors->setName("executionContextId");
365 0 : result->m_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
366 0 : protocol::Value* hashValue = object->get("hash");
367 0 : errors->setName("hash");
368 0 : result->m_hash = ValueConversions<String>::fromValue(hashValue, errors);
369 0 : protocol::Value* executionContextAuxDataValue = object->get("executionContextAuxData");
370 0 : if (executionContextAuxDataValue) {
371 0 : errors->setName("executionContextAuxData");
372 0 : result->m_executionContextAuxData = ValueConversions<protocol::DictionaryValue>::fromValue(executionContextAuxDataValue, errors);
373 : }
374 0 : protocol::Value* isLiveEditValue = object->get("isLiveEdit");
375 0 : if (isLiveEditValue) {
376 0 : errors->setName("isLiveEdit");
377 0 : result->m_isLiveEdit = ValueConversions<bool>::fromValue(isLiveEditValue, errors);
378 : }
379 0 : protocol::Value* sourceMapURLValue = object->get("sourceMapURL");
380 0 : if (sourceMapURLValue) {
381 0 : errors->setName("sourceMapURL");
382 0 : result->m_sourceMapURL = ValueConversions<String>::fromValue(sourceMapURLValue, errors);
383 : }
384 0 : protocol::Value* hasSourceURLValue = object->get("hasSourceURL");
385 0 : if (hasSourceURLValue) {
386 0 : errors->setName("hasSourceURL");
387 0 : result->m_hasSourceURL = ValueConversions<bool>::fromValue(hasSourceURLValue, errors);
388 : }
389 0 : protocol::Value* isModuleValue = object->get("isModule");
390 0 : if (isModuleValue) {
391 0 : errors->setName("isModule");
392 0 : result->m_isModule = ValueConversions<bool>::fromValue(isModuleValue, errors);
393 : }
394 0 : protocol::Value* lengthValue = object->get("length");
395 0 : if (lengthValue) {
396 0 : errors->setName("length");
397 0 : result->m_length = ValueConversions<int>::fromValue(lengthValue, errors);
398 : }
399 0 : protocol::Value* stackTraceValue = object->get("stackTrace");
400 0 : if (stackTraceValue) {
401 0 : errors->setName("stackTrace");
402 0 : result->m_stackTrace = ValueConversions<protocol::Runtime::StackTrace>::fromValue(stackTraceValue, errors);
403 : }
404 0 : errors->pop();
405 0 : if (errors->hasErrors())
406 : return nullptr;
407 : return result;
408 : }
409 :
410 36492 : std::unique_ptr<protocol::DictionaryValue> ScriptParsedNotification::toValue() const
411 : {
412 36492 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
413 182460 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
414 182460 : result->setValue("url", ValueConversions<String>::toValue(m_url));
415 182460 : result->setValue("startLine", ValueConversions<int>::toValue(m_startLine));
416 182460 : result->setValue("startColumn", ValueConversions<int>::toValue(m_startColumn));
417 145968 : result->setValue("endLine", ValueConversions<int>::toValue(m_endLine));
418 182460 : result->setValue("endColumn", ValueConversions<int>::toValue(m_endColumn));
419 182460 : result->setValue("executionContextId", ValueConversions<int>::toValue(m_executionContextId));
420 182460 : result->setValue("hash", ValueConversions<String>::toValue(m_hash));
421 36492 : if (m_executionContextAuxData.isJust())
422 0 : result->setValue("executionContextAuxData", ValueConversions<protocol::DictionaryValue>::toValue(m_executionContextAuxData.fromJust()));
423 36492 : if (m_isLiveEdit.isJust())
424 145968 : result->setValue("isLiveEdit", ValueConversions<bool>::toValue(m_isLiveEdit.fromJust()));
425 36492 : if (m_sourceMapURL.isJust())
426 182460 : result->setValue("sourceMapURL", ValueConversions<String>::toValue(m_sourceMapURL.fromJust()));
427 36492 : if (m_hasSourceURL.isJust())
428 145968 : result->setValue("hasSourceURL", ValueConversions<bool>::toValue(m_hasSourceURL.fromJust()));
429 36492 : if (m_isModule.isJust())
430 145968 : result->setValue("isModule", ValueConversions<bool>::toValue(m_isModule.fromJust()));
431 36492 : if (m_length.isJust())
432 145968 : result->setValue("length", ValueConversions<int>::toValue(m_length.fromJust()));
433 36492 : if (m_stackTrace.isJust())
434 130532 : result->setValue("stackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(m_stackTrace.fromJust()));
435 36492 : return result;
436 : }
437 :
438 0 : std::unique_ptr<ScriptParsedNotification> ScriptParsedNotification::clone() const
439 : {
440 0 : ErrorSupport errors;
441 0 : return fromValue(toValue().get(), &errors);
442 : }
443 :
444 0 : std::unique_ptr<ScriptFailedToParseNotification> ScriptFailedToParseNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
445 : {
446 0 : if (!value || value->type() != protocol::Value::TypeObject) {
447 0 : errors->addError("object expected");
448 : return nullptr;
449 : }
450 :
451 0 : std::unique_ptr<ScriptFailedToParseNotification> result(new ScriptFailedToParseNotification());
452 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
453 0 : errors->push();
454 0 : protocol::Value* scriptIdValue = object->get("scriptId");
455 0 : errors->setName("scriptId");
456 0 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
457 0 : protocol::Value* urlValue = object->get("url");
458 0 : errors->setName("url");
459 0 : result->m_url = ValueConversions<String>::fromValue(urlValue, errors);
460 0 : protocol::Value* startLineValue = object->get("startLine");
461 0 : errors->setName("startLine");
462 0 : result->m_startLine = ValueConversions<int>::fromValue(startLineValue, errors);
463 0 : protocol::Value* startColumnValue = object->get("startColumn");
464 0 : errors->setName("startColumn");
465 0 : result->m_startColumn = ValueConversions<int>::fromValue(startColumnValue, errors);
466 0 : protocol::Value* endLineValue = object->get("endLine");
467 0 : errors->setName("endLine");
468 0 : result->m_endLine = ValueConversions<int>::fromValue(endLineValue, errors);
469 0 : protocol::Value* endColumnValue = object->get("endColumn");
470 0 : errors->setName("endColumn");
471 0 : result->m_endColumn = ValueConversions<int>::fromValue(endColumnValue, errors);
472 0 : protocol::Value* executionContextIdValue = object->get("executionContextId");
473 0 : errors->setName("executionContextId");
474 0 : result->m_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
475 0 : protocol::Value* hashValue = object->get("hash");
476 0 : errors->setName("hash");
477 0 : result->m_hash = ValueConversions<String>::fromValue(hashValue, errors);
478 0 : protocol::Value* executionContextAuxDataValue = object->get("executionContextAuxData");
479 0 : if (executionContextAuxDataValue) {
480 0 : errors->setName("executionContextAuxData");
481 0 : result->m_executionContextAuxData = ValueConversions<protocol::DictionaryValue>::fromValue(executionContextAuxDataValue, errors);
482 : }
483 0 : protocol::Value* sourceMapURLValue = object->get("sourceMapURL");
484 0 : if (sourceMapURLValue) {
485 0 : errors->setName("sourceMapURL");
486 0 : result->m_sourceMapURL = ValueConversions<String>::fromValue(sourceMapURLValue, errors);
487 : }
488 0 : protocol::Value* hasSourceURLValue = object->get("hasSourceURL");
489 0 : if (hasSourceURLValue) {
490 0 : errors->setName("hasSourceURL");
491 0 : result->m_hasSourceURL = ValueConversions<bool>::fromValue(hasSourceURLValue, errors);
492 : }
493 0 : protocol::Value* isModuleValue = object->get("isModule");
494 0 : if (isModuleValue) {
495 0 : errors->setName("isModule");
496 0 : result->m_isModule = ValueConversions<bool>::fromValue(isModuleValue, errors);
497 : }
498 0 : protocol::Value* lengthValue = object->get("length");
499 0 : if (lengthValue) {
500 0 : errors->setName("length");
501 0 : result->m_length = ValueConversions<int>::fromValue(lengthValue, errors);
502 : }
503 0 : protocol::Value* stackTraceValue = object->get("stackTrace");
504 0 : if (stackTraceValue) {
505 0 : errors->setName("stackTrace");
506 0 : result->m_stackTrace = ValueConversions<protocol::Runtime::StackTrace>::fromValue(stackTraceValue, errors);
507 : }
508 0 : errors->pop();
509 0 : if (errors->hasErrors())
510 : return nullptr;
511 : return result;
512 : }
513 :
514 184 : std::unique_ptr<protocol::DictionaryValue> ScriptFailedToParseNotification::toValue() const
515 : {
516 184 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
517 920 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
518 920 : result->setValue("url", ValueConversions<String>::toValue(m_url));
519 920 : result->setValue("startLine", ValueConversions<int>::toValue(m_startLine));
520 920 : result->setValue("startColumn", ValueConversions<int>::toValue(m_startColumn));
521 920 : result->setValue("endLine", ValueConversions<int>::toValue(m_endLine));
522 920 : result->setValue("endColumn", ValueConversions<int>::toValue(m_endColumn));
523 920 : result->setValue("executionContextId", ValueConversions<int>::toValue(m_executionContextId));
524 920 : result->setValue("hash", ValueConversions<String>::toValue(m_hash));
525 184 : if (m_executionContextAuxData.isJust())
526 0 : result->setValue("executionContextAuxData", ValueConversions<protocol::DictionaryValue>::toValue(m_executionContextAuxData.fromJust()));
527 184 : if (m_sourceMapURL.isJust())
528 920 : result->setValue("sourceMapURL", ValueConversions<String>::toValue(m_sourceMapURL.fromJust()));
529 184 : if (m_hasSourceURL.isJust())
530 736 : result->setValue("hasSourceURL", ValueConversions<bool>::toValue(m_hasSourceURL.fromJust()));
531 184 : if (m_isModule.isJust())
532 736 : result->setValue("isModule", ValueConversions<bool>::toValue(m_isModule.fromJust()));
533 184 : if (m_length.isJust())
534 736 : result->setValue("length", ValueConversions<int>::toValue(m_length.fromJust()));
535 184 : if (m_stackTrace.isJust())
536 568 : result->setValue("stackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(m_stackTrace.fromJust()));
537 184 : return result;
538 : }
539 :
540 0 : std::unique_ptr<ScriptFailedToParseNotification> ScriptFailedToParseNotification::clone() const
541 : {
542 0 : ErrorSupport errors;
543 0 : return fromValue(toValue().get(), &errors);
544 : }
545 :
546 0 : std::unique_ptr<BreakpointResolvedNotification> BreakpointResolvedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
547 : {
548 0 : if (!value || value->type() != protocol::Value::TypeObject) {
549 0 : errors->addError("object expected");
550 : return nullptr;
551 : }
552 :
553 0 : std::unique_ptr<BreakpointResolvedNotification> result(new BreakpointResolvedNotification());
554 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
555 0 : errors->push();
556 0 : protocol::Value* breakpointIdValue = object->get("breakpointId");
557 0 : errors->setName("breakpointId");
558 0 : result->m_breakpointId = ValueConversions<String>::fromValue(breakpointIdValue, errors);
559 0 : protocol::Value* locationValue = object->get("location");
560 0 : errors->setName("location");
561 0 : result->m_location = ValueConversions<protocol::Debugger::Location>::fromValue(locationValue, errors);
562 0 : errors->pop();
563 0 : if (errors->hasErrors())
564 : return nullptr;
565 : return result;
566 : }
567 :
568 72 : std::unique_ptr<protocol::DictionaryValue> BreakpointResolvedNotification::toValue() const
569 : {
570 72 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
571 360 : result->setValue("breakpointId", ValueConversions<String>::toValue(m_breakpointId));
572 288 : result->setValue("location", ValueConversions<protocol::Debugger::Location>::toValue(m_location.get()));
573 72 : return result;
574 : }
575 :
576 0 : std::unique_ptr<BreakpointResolvedNotification> BreakpointResolvedNotification::clone() const
577 : {
578 0 : ErrorSupport errors;
579 0 : return fromValue(toValue().get(), &errors);
580 : }
581 :
582 : const char* PausedNotification::ReasonEnum::XHR = "XHR";
583 : const char* PausedNotification::ReasonEnum::DOM = "DOM";
584 : const char* PausedNotification::ReasonEnum::EventListener = "EventListener";
585 : const char* PausedNotification::ReasonEnum::Exception = "exception";
586 : const char* PausedNotification::ReasonEnum::Assert = "assert";
587 : const char* PausedNotification::ReasonEnum::DebugCommand = "debugCommand";
588 : const char* PausedNotification::ReasonEnum::PromiseRejection = "promiseRejection";
589 : const char* PausedNotification::ReasonEnum::OOM = "OOM";
590 : const char* PausedNotification::ReasonEnum::Other = "other";
591 : const char* PausedNotification::ReasonEnum::Ambiguous = "ambiguous";
592 :
593 0 : std::unique_ptr<PausedNotification> PausedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
594 : {
595 0 : if (!value || value->type() != protocol::Value::TypeObject) {
596 0 : errors->addError("object expected");
597 : return nullptr;
598 : }
599 :
600 0 : std::unique_ptr<PausedNotification> result(new PausedNotification());
601 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
602 0 : errors->push();
603 0 : protocol::Value* callFramesValue = object->get("callFrames");
604 0 : errors->setName("callFrames");
605 0 : result->m_callFrames = ValueConversions<protocol::Array<protocol::Debugger::CallFrame>>::fromValue(callFramesValue, errors);
606 0 : protocol::Value* reasonValue = object->get("reason");
607 0 : errors->setName("reason");
608 0 : result->m_reason = ValueConversions<String>::fromValue(reasonValue, errors);
609 0 : protocol::Value* dataValue = object->get("data");
610 0 : if (dataValue) {
611 0 : errors->setName("data");
612 0 : result->m_data = ValueConversions<protocol::DictionaryValue>::fromValue(dataValue, errors);
613 : }
614 0 : protocol::Value* hitBreakpointsValue = object->get("hitBreakpoints");
615 0 : if (hitBreakpointsValue) {
616 0 : errors->setName("hitBreakpoints");
617 0 : result->m_hitBreakpoints = ValueConversions<protocol::Array<String>>::fromValue(hitBreakpointsValue, errors);
618 : }
619 0 : protocol::Value* asyncStackTraceValue = object->get("asyncStackTrace");
620 0 : if (asyncStackTraceValue) {
621 0 : errors->setName("asyncStackTrace");
622 0 : result->m_asyncStackTrace = ValueConversions<protocol::Runtime::StackTrace>::fromValue(asyncStackTraceValue, errors);
623 : }
624 0 : errors->pop();
625 0 : if (errors->hasErrors())
626 : return nullptr;
627 : return result;
628 : }
629 :
630 77060 : std::unique_ptr<protocol::DictionaryValue> PausedNotification::toValue() const
631 : {
632 77060 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
633 308240 : result->setValue("callFrames", ValueConversions<protocol::Array<protocol::Debugger::CallFrame>>::toValue(m_callFrames.get()));
634 385300 : result->setValue("reason", ValueConversions<String>::toValue(m_reason));
635 77060 : if (m_data.isJust())
636 10864 : result->setValue("data", ValueConversions<protocol::DictionaryValue>::toValue(m_data.fromJust()));
637 77060 : if (m_hitBreakpoints.isJust())
638 308240 : result->setValue("hitBreakpoints", ValueConversions<protocol::Array<String>>::toValue(m_hitBreakpoints.fromJust()));
639 77060 : if (m_asyncStackTrace.isJust())
640 1512 : result->setValue("asyncStackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(m_asyncStackTrace.fromJust()));
641 77060 : return result;
642 : }
643 :
644 0 : std::unique_ptr<PausedNotification> PausedNotification::clone() const
645 : {
646 0 : ErrorSupport errors;
647 0 : return fromValue(toValue().get(), &errors);
648 : }
649 :
650 : // ------------- Enum values from params.
651 :
652 :
653 : namespace SetPauseOnExceptions {
654 : namespace StateEnum {
655 : const char* None = "none";
656 : const char* Uncaught = "uncaught";
657 : const char* All = "all";
658 : } // namespace StateEnum
659 : } // namespace SetPauseOnExceptions
660 :
661 : namespace Paused {
662 : namespace ReasonEnum {
663 : const char* XHR = "XHR";
664 : const char* DOM = "DOM";
665 : const char* EventListener = "EventListener";
666 : const char* Exception = "exception";
667 : const char* Assert = "assert";
668 : const char* DebugCommand = "debugCommand";
669 : const char* PromiseRejection = "promiseRejection";
670 : const char* OOM = "OOM";
671 : const char* Other = "other";
672 : const char* Ambiguous = "ambiguous";
673 : } // namespace ReasonEnum
674 : } // namespace Paused
675 :
676 : namespace API {
677 : namespace Paused {
678 : namespace ReasonEnum {
679 : const char* XHR = "XHR";
680 : const char* DOM = "DOM";
681 : const char* EventListener = "EventListener";
682 : const char* Exception = "exception";
683 : const char* Assert = "assert";
684 : const char* DebugCommand = "debugCommand";
685 : const char* PromiseRejection = "promiseRejection";
686 : const char* OOM = "OOM";
687 : const char* Other = "other";
688 : const char* Ambiguous = "ambiguous";
689 : } // namespace ReasonEnum
690 : } // namespace Paused
691 : } // namespace API
692 :
693 : // ------------- Frontend notifications.
694 :
695 36492 : void Frontend::scriptParsed(const String& scriptId, const String& url, int startLine, int startColumn, int endLine, int endColumn, int executionContextId, const String& hash, Maybe<protocol::DictionaryValue> executionContextAuxData, Maybe<bool> isLiveEdit, Maybe<String> sourceMapURL, Maybe<bool> hasSourceURL, Maybe<bool> isModule, Maybe<int> length, Maybe<protocol::Runtime::StackTrace> stackTrace)
696 : {
697 36492 : if (!m_frontendChannel)
698 36492 : return;
699 : std::unique_ptr<ScriptParsedNotification> messageData = ScriptParsedNotification::create()
700 36492 : .setScriptId(scriptId)
701 : .setUrl(url)
702 : .setStartLine(startLine)
703 : .setStartColumn(startColumn)
704 : .setEndLine(endLine)
705 : .setEndColumn(endColumn)
706 : .setExecutionContextId(executionContextId)
707 : .setHash(hash)
708 : .build();
709 36492 : if (executionContextAuxData.isJust())
710 : messageData->setExecutionContextAuxData(std::move(executionContextAuxData).takeJust());
711 36492 : if (isLiveEdit.isJust())
712 36492 : messageData->setIsLiveEdit(std::move(isLiveEdit).takeJust());
713 36492 : if (sourceMapURL.isJust())
714 72984 : messageData->setSourceMapURL(std::move(sourceMapURL).takeJust());
715 36492 : if (hasSourceURL.isJust())
716 36492 : messageData->setHasSourceURL(std::move(hasSourceURL).takeJust());
717 36492 : if (isModule.isJust())
718 36492 : messageData->setIsModule(std::move(isModule).takeJust());
719 36492 : if (length.isJust())
720 36492 : messageData->setLength(std::move(length).takeJust());
721 36492 : if (stackTrace.isJust())
722 : messageData->setStackTrace(std::move(stackTrace).takeJust());
723 255444 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.scriptParsed", std::move(messageData)));
724 : }
725 :
726 184 : void Frontend::scriptFailedToParse(const String& scriptId, const String& url, int startLine, int startColumn, int endLine, int endColumn, int executionContextId, const String& hash, Maybe<protocol::DictionaryValue> executionContextAuxData, Maybe<String> sourceMapURL, Maybe<bool> hasSourceURL, Maybe<bool> isModule, Maybe<int> length, Maybe<protocol::Runtime::StackTrace> stackTrace)
727 : {
728 184 : if (!m_frontendChannel)
729 184 : return;
730 : std::unique_ptr<ScriptFailedToParseNotification> messageData = ScriptFailedToParseNotification::create()
731 184 : .setScriptId(scriptId)
732 : .setUrl(url)
733 : .setStartLine(startLine)
734 : .setStartColumn(startColumn)
735 : .setEndLine(endLine)
736 : .setEndColumn(endColumn)
737 : .setExecutionContextId(executionContextId)
738 : .setHash(hash)
739 : .build();
740 184 : if (executionContextAuxData.isJust())
741 : messageData->setExecutionContextAuxData(std::move(executionContextAuxData).takeJust());
742 184 : if (sourceMapURL.isJust())
743 368 : messageData->setSourceMapURL(std::move(sourceMapURL).takeJust());
744 184 : if (hasSourceURL.isJust())
745 184 : messageData->setHasSourceURL(std::move(hasSourceURL).takeJust());
746 184 : if (isModule.isJust())
747 184 : messageData->setIsModule(std::move(isModule).takeJust());
748 184 : if (length.isJust())
749 184 : messageData->setLength(std::move(length).takeJust());
750 184 : if (stackTrace.isJust())
751 : messageData->setStackTrace(std::move(stackTrace).takeJust());
752 1288 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.scriptFailedToParse", std::move(messageData)));
753 : }
754 :
755 72 : void Frontend::breakpointResolved(const String& breakpointId, std::unique_ptr<protocol::Debugger::Location> location)
756 : {
757 72 : if (!m_frontendChannel)
758 72 : return;
759 : std::unique_ptr<BreakpointResolvedNotification> messageData = BreakpointResolvedNotification::create()
760 72 : .setBreakpointId(breakpointId)
761 : .setLocation(std::move(location))
762 : .build();
763 504 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.breakpointResolved", std::move(messageData)));
764 : }
765 :
766 77060 : void Frontend::paused(std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>> callFrames, const String& reason, Maybe<protocol::DictionaryValue> data, Maybe<protocol::Array<String>> hitBreakpoints, Maybe<protocol::Runtime::StackTrace> asyncStackTrace)
767 : {
768 77060 : if (!m_frontendChannel)
769 77060 : return;
770 : std::unique_ptr<PausedNotification> messageData = PausedNotification::create()
771 77060 : .setCallFrames(std::move(callFrames))
772 : .setReason(reason)
773 : .build();
774 77060 : if (data.isJust())
775 : messageData->setData(std::move(data).takeJust());
776 77060 : if (hitBreakpoints.isJust())
777 : messageData->setHitBreakpoints(std::move(hitBreakpoints).takeJust());
778 77060 : if (asyncStackTrace.isJust())
779 : messageData->setAsyncStackTrace(std::move(asyncStackTrace).takeJust());
780 539420 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.paused", std::move(messageData)));
781 : }
782 :
783 76975 : void Frontend::resumed()
784 : {
785 76975 : if (!m_frontendChannel)
786 76975 : return;
787 538825 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.resumed"));
788 : }
789 :
790 0 : void Frontend::flush()
791 : {
792 0 : m_frontendChannel->flushProtocolNotifications();
793 0 : }
794 :
795 0 : void Frontend::sendRawNotification(const String& notification)
796 : {
797 0 : m_frontendChannel->sendProtocolNotification(InternalRawNotification::create(notification));
798 0 : }
799 :
800 : // --------------------- Dispatcher.
801 :
802 : class DispatcherImpl : public protocol::DispatcherBase {
803 : public:
804 4573 : DispatcherImpl(FrontendChannel* frontendChannel, Backend* backend, bool fallThroughForNotFound)
805 : : DispatcherBase(frontendChannel)
806 : , m_backend(backend)
807 9146 : , m_fallThroughForNotFound(fallThroughForNotFound) {
808 13719 : m_dispatchMap["Debugger.enable"] = &DispatcherImpl::enable;
809 13719 : m_dispatchMap["Debugger.disable"] = &DispatcherImpl::disable;
810 13719 : m_dispatchMap["Debugger.setBreakpointsActive"] = &DispatcherImpl::setBreakpointsActive;
811 13719 : m_dispatchMap["Debugger.setSkipAllPauses"] = &DispatcherImpl::setSkipAllPauses;
812 13719 : m_dispatchMap["Debugger.setBreakpointByUrl"] = &DispatcherImpl::setBreakpointByUrl;
813 13719 : m_dispatchMap["Debugger.setBreakpoint"] = &DispatcherImpl::setBreakpoint;
814 13719 : m_dispatchMap["Debugger.removeBreakpoint"] = &DispatcherImpl::removeBreakpoint;
815 13719 : m_dispatchMap["Debugger.getPossibleBreakpoints"] = &DispatcherImpl::getPossibleBreakpoints;
816 13719 : m_dispatchMap["Debugger.continueToLocation"] = &DispatcherImpl::continueToLocation;
817 13719 : m_dispatchMap["Debugger.stepOver"] = &DispatcherImpl::stepOver;
818 13719 : m_dispatchMap["Debugger.stepInto"] = &DispatcherImpl::stepInto;
819 13719 : m_dispatchMap["Debugger.stepOut"] = &DispatcherImpl::stepOut;
820 13719 : m_dispatchMap["Debugger.pause"] = &DispatcherImpl::pause;
821 13719 : m_dispatchMap["Debugger.scheduleStepIntoAsync"] = &DispatcherImpl::scheduleStepIntoAsync;
822 13719 : m_dispatchMap["Debugger.resume"] = &DispatcherImpl::resume;
823 13719 : m_dispatchMap["Debugger.searchInContent"] = &DispatcherImpl::searchInContent;
824 13719 : m_dispatchMap["Debugger.setScriptSource"] = &DispatcherImpl::setScriptSource;
825 13719 : m_dispatchMap["Debugger.restartFrame"] = &DispatcherImpl::restartFrame;
826 13719 : m_dispatchMap["Debugger.getScriptSource"] = &DispatcherImpl::getScriptSource;
827 13719 : m_dispatchMap["Debugger.setPauseOnExceptions"] = &DispatcherImpl::setPauseOnExceptions;
828 13719 : m_dispatchMap["Debugger.evaluateOnCallFrame"] = &DispatcherImpl::evaluateOnCallFrame;
829 13719 : m_dispatchMap["Debugger.setVariableValue"] = &DispatcherImpl::setVariableValue;
830 13719 : m_dispatchMap["Debugger.setAsyncCallStackDepth"] = &DispatcherImpl::setAsyncCallStackDepth;
831 13719 : m_dispatchMap["Debugger.setBlackboxPatterns"] = &DispatcherImpl::setBlackboxPatterns;
832 13719 : m_dispatchMap["Debugger.setBlackboxedRanges"] = &DispatcherImpl::setBlackboxedRanges;
833 4573 : }
834 13719 : ~DispatcherImpl() override { }
835 : DispatchResponse::Status dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject) override;
836 :
837 : protected:
838 : using CallHandler = DispatchResponse::Status (DispatcherImpl::*)(int callId, std::unique_ptr<DictionaryValue> messageObject, ErrorSupport* errors);
839 : using DispatchMap = protocol::HashMap<String, CallHandler>;
840 : DispatchMap m_dispatchMap;
841 :
842 : DispatchResponse::Status enable(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
843 : DispatchResponse::Status disable(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
844 : DispatchResponse::Status setBreakpointsActive(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
845 : DispatchResponse::Status setSkipAllPauses(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
846 : DispatchResponse::Status setBreakpointByUrl(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
847 : DispatchResponse::Status setBreakpoint(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
848 : DispatchResponse::Status removeBreakpoint(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
849 : DispatchResponse::Status getPossibleBreakpoints(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
850 : DispatchResponse::Status continueToLocation(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
851 : DispatchResponse::Status stepOver(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
852 : DispatchResponse::Status stepInto(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
853 : DispatchResponse::Status stepOut(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
854 : DispatchResponse::Status pause(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
855 : DispatchResponse::Status scheduleStepIntoAsync(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
856 : DispatchResponse::Status resume(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
857 : DispatchResponse::Status searchInContent(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
858 : DispatchResponse::Status setScriptSource(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
859 : DispatchResponse::Status restartFrame(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
860 : DispatchResponse::Status getScriptSource(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
861 : DispatchResponse::Status setPauseOnExceptions(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
862 : DispatchResponse::Status evaluateOnCallFrame(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
863 : DispatchResponse::Status setVariableValue(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
864 : DispatchResponse::Status setAsyncCallStackDepth(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
865 : DispatchResponse::Status setBlackboxPatterns(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
866 : DispatchResponse::Status setBlackboxedRanges(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
867 :
868 : Backend* m_backend;
869 : bool m_fallThroughForNotFound;
870 : };
871 :
872 96568 : DispatchResponse::Status DispatcherImpl::dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject)
873 : {
874 : protocol::HashMap<String, CallHandler>::iterator it = m_dispatchMap.find(method);
875 96568 : if (it == m_dispatchMap.end()) {
876 0 : if (m_fallThroughForNotFound)
877 : return DispatchResponse::kFallThrough;
878 0 : reportProtocolError(callId, DispatchResponse::kMethodNotFound, "'" + method + "' wasn't found", nullptr);
879 0 : return DispatchResponse::kError;
880 : }
881 :
882 96568 : protocol::ErrorSupport errors;
883 289704 : return (this->*(it->second))(callId, std::move(messageObject), &errors);
884 : }
885 :
886 :
887 4341 : DispatchResponse::Status DispatcherImpl::enable(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
888 : {
889 :
890 4341 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
891 4341 : DispatchResponse response = m_backend->enable();
892 4341 : if (weak->get())
893 4341 : weak->get()->sendResponse(callId, response);
894 8682 : return response.status();
895 : }
896 :
897 850 : DispatchResponse::Status DispatcherImpl::disable(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
898 : {
899 :
900 850 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
901 850 : DispatchResponse response = m_backend->disable();
902 850 : if (weak->get())
903 850 : weak->get()->sendResponse(callId, response);
904 1700 : return response.status();
905 : }
906 :
907 180 : DispatchResponse::Status DispatcherImpl::setBreakpointsActive(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
908 : {
909 : // Prepare input parameters.
910 540 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
911 180 : errors->push();
912 360 : protocol::Value* activeValue = object ? object->get("active") : nullptr;
913 360 : errors->setName("active");
914 180 : bool in_active = ValueConversions<bool>::fromValue(activeValue, errors);
915 180 : errors->pop();
916 180 : if (errors->hasErrors()) {
917 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
918 0 : return DispatchResponse::kError;
919 : }
920 :
921 180 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
922 180 : DispatchResponse response = m_backend->setBreakpointsActive(in_active);
923 180 : if (weak->get())
924 180 : weak->get()->sendResponse(callId, response);
925 180 : return response.status();
926 : }
927 :
928 0 : DispatchResponse::Status DispatcherImpl::setSkipAllPauses(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
929 : {
930 : // Prepare input parameters.
931 0 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
932 0 : errors->push();
933 0 : protocol::Value* skipValue = object ? object->get("skip") : nullptr;
934 0 : errors->setName("skip");
935 0 : bool in_skip = ValueConversions<bool>::fromValue(skipValue, errors);
936 0 : errors->pop();
937 0 : if (errors->hasErrors()) {
938 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
939 0 : return DispatchResponse::kError;
940 : }
941 :
942 0 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
943 0 : DispatchResponse response = m_backend->setSkipAllPauses(in_skip);
944 0 : if (weak->get())
945 0 : weak->get()->sendResponse(callId, response);
946 0 : return response.status();
947 : }
948 :
949 60 : DispatchResponse::Status DispatcherImpl::setBreakpointByUrl(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
950 : {
951 : // Prepare input parameters.
952 180 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
953 60 : errors->push();
954 120 : protocol::Value* lineNumberValue = object ? object->get("lineNumber") : nullptr;
955 120 : errors->setName("lineNumber");
956 60 : int in_lineNumber = ValueConversions<int>::fromValue(lineNumberValue, errors);
957 120 : protocol::Value* urlValue = object ? object->get("url") : nullptr;
958 : Maybe<String> in_url;
959 60 : if (urlValue) {
960 120 : errors->setName("url");
961 120 : in_url = ValueConversions<String>::fromValue(urlValue, errors);
962 : }
963 120 : protocol::Value* urlRegexValue = object ? object->get("urlRegex") : nullptr;
964 : Maybe<String> in_urlRegex;
965 60 : if (urlRegexValue) {
966 0 : errors->setName("urlRegex");
967 0 : in_urlRegex = ValueConversions<String>::fromValue(urlRegexValue, errors);
968 : }
969 120 : protocol::Value* columnNumberValue = object ? object->get("columnNumber") : nullptr;
970 : Maybe<int> in_columnNumber;
971 60 : if (columnNumberValue) {
972 72 : errors->setName("columnNumber");
973 36 : in_columnNumber = ValueConversions<int>::fromValue(columnNumberValue, errors);
974 : }
975 120 : protocol::Value* conditionValue = object ? object->get("condition") : nullptr;
976 : Maybe<String> in_condition;
977 60 : if (conditionValue) {
978 0 : errors->setName("condition");
979 0 : in_condition = ValueConversions<String>::fromValue(conditionValue, errors);
980 : }
981 60 : errors->pop();
982 60 : if (errors->hasErrors()) {
983 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
984 0 : return DispatchResponse::kError;
985 : }
986 : // Declare output parameters.
987 : String out_breakpointId;
988 60 : std::unique_ptr<protocol::Array<protocol::Debugger::Location>> out_locations;
989 :
990 60 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
991 300 : DispatchResponse response = m_backend->setBreakpointByUrl(in_lineNumber, std::move(in_url), std::move(in_urlRegex), std::move(in_columnNumber), std::move(in_condition), &out_breakpointId, &out_locations);
992 60 : if (response.status() == DispatchResponse::kFallThrough)
993 : return response.status();
994 60 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
995 60 : if (response.status() == DispatchResponse::kSuccess) {
996 240 : result->setValue("breakpointId", ValueConversions<String>::toValue(out_breakpointId));
997 240 : result->setValue("locations", ValueConversions<protocol::Array<protocol::Debugger::Location>>::toValue(out_locations.get()));
998 : }
999 60 : if (weak->get())
1000 120 : weak->get()->sendResponse(callId, response, std::move(result));
1001 60 : return response.status();
1002 : }
1003 :
1004 2496 : DispatchResponse::Status DispatcherImpl::setBreakpoint(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1005 : {
1006 : // Prepare input parameters.
1007 7488 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1008 2496 : errors->push();
1009 4992 : protocol::Value* locationValue = object ? object->get("location") : nullptr;
1010 4992 : errors->setName("location");
1011 : std::unique_ptr<protocol::Debugger::Location> in_location = ValueConversions<protocol::Debugger::Location>::fromValue(locationValue, errors);
1012 4992 : protocol::Value* conditionValue = object ? object->get("condition") : nullptr;
1013 : Maybe<String> in_condition;
1014 2496 : if (conditionValue) {
1015 560 : errors->setName("condition");
1016 560 : in_condition = ValueConversions<String>::fromValue(conditionValue, errors);
1017 : }
1018 2496 : errors->pop();
1019 2496 : if (errors->hasErrors()) {
1020 12 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1021 6 : return DispatchResponse::kError;
1022 : }
1023 : // Declare output parameters.
1024 : String out_breakpointId;
1025 2490 : std::unique_ptr<protocol::Debugger::Location> out_actualLocation;
1026 :
1027 2490 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1028 9960 : DispatchResponse response = m_backend->setBreakpoint(std::move(in_location), std::move(in_condition), &out_breakpointId, &out_actualLocation);
1029 2490 : if (response.status() == DispatchResponse::kFallThrough)
1030 : return response.status();
1031 2490 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1032 2490 : if (response.status() == DispatchResponse::kSuccess) {
1033 9064 : result->setValue("breakpointId", ValueConversions<String>::toValue(out_breakpointId));
1034 9064 : result->setValue("actualLocation", ValueConversions<protocol::Debugger::Location>::toValue(out_actualLocation.get()));
1035 : }
1036 2490 : if (weak->get())
1037 4980 : weak->get()->sendResponse(callId, response, std::move(result));
1038 2490 : return response.status();
1039 : }
1040 :
1041 726 : DispatchResponse::Status DispatcherImpl::removeBreakpoint(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1042 : {
1043 : // Prepare input parameters.
1044 2178 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1045 726 : errors->push();
1046 1452 : protocol::Value* breakpointIdValue = object ? object->get("breakpointId") : nullptr;
1047 1452 : errors->setName("breakpointId");
1048 726 : String in_breakpointId = ValueConversions<String>::fromValue(breakpointIdValue, errors);
1049 726 : errors->pop();
1050 726 : if (errors->hasErrors()) {
1051 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1052 0 : return DispatchResponse::kError;
1053 : }
1054 :
1055 726 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1056 726 : DispatchResponse response = m_backend->removeBreakpoint(in_breakpointId);
1057 726 : if (weak->get())
1058 726 : weak->get()->sendResponse(callId, response);
1059 726 : return response.status();
1060 : }
1061 :
1062 264 : DispatchResponse::Status DispatcherImpl::getPossibleBreakpoints(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1063 : {
1064 : // Prepare input parameters.
1065 792 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1066 264 : errors->push();
1067 528 : protocol::Value* startValue = object ? object->get("start") : nullptr;
1068 528 : errors->setName("start");
1069 : std::unique_ptr<protocol::Debugger::Location> in_start = ValueConversions<protocol::Debugger::Location>::fromValue(startValue, errors);
1070 528 : protocol::Value* endValue = object ? object->get("end") : nullptr;
1071 : Maybe<protocol::Debugger::Location> in_end;
1072 264 : if (endValue) {
1073 264 : errors->setName("end");
1074 132 : in_end = ValueConversions<protocol::Debugger::Location>::fromValue(endValue, errors);
1075 : }
1076 528 : protocol::Value* restrictToFunctionValue = object ? object->get("restrictToFunction") : nullptr;
1077 : Maybe<bool> in_restrictToFunction;
1078 264 : if (restrictToFunctionValue) {
1079 0 : errors->setName("restrictToFunction");
1080 0 : in_restrictToFunction = ValueConversions<bool>::fromValue(restrictToFunctionValue, errors);
1081 : }
1082 264 : errors->pop();
1083 264 : if (errors->hasErrors()) {
1084 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1085 0 : return DispatchResponse::kError;
1086 : }
1087 : // Declare output parameters.
1088 264 : std::unique_ptr<protocol::Array<protocol::Debugger::BreakLocation>> out_locations;
1089 :
1090 264 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1091 1056 : DispatchResponse response = m_backend->getPossibleBreakpoints(std::move(in_start), std::move(in_end), std::move(in_restrictToFunction), &out_locations);
1092 264 : if (response.status() == DispatchResponse::kFallThrough)
1093 : return response.status();
1094 264 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1095 264 : if (response.status() == DispatchResponse::kSuccess) {
1096 1008 : result->setValue("locations", ValueConversions<protocol::Array<protocol::Debugger::BreakLocation>>::toValue(out_locations.get()));
1097 : }
1098 264 : if (weak->get())
1099 528 : weak->get()->sendResponse(callId, response, std::move(result));
1100 264 : return response.status();
1101 : }
1102 :
1103 36 : DispatchResponse::Status DispatcherImpl::continueToLocation(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1104 : {
1105 : // Prepare input parameters.
1106 108 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1107 36 : errors->push();
1108 72 : protocol::Value* locationValue = object ? object->get("location") : nullptr;
1109 72 : errors->setName("location");
1110 : std::unique_ptr<protocol::Debugger::Location> in_location = ValueConversions<protocol::Debugger::Location>::fromValue(locationValue, errors);
1111 36 : errors->pop();
1112 36 : if (errors->hasErrors()) {
1113 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1114 0 : return DispatchResponse::kError;
1115 : }
1116 :
1117 36 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1118 108 : DispatchResponse response = m_backend->continueToLocation(std::move(in_location));
1119 36 : if (weak->get())
1120 36 : weak->get()->sendResponse(callId, response);
1121 36 : return response.status();
1122 : }
1123 :
1124 11616 : DispatchResponse::Status DispatcherImpl::stepOver(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1125 : {
1126 :
1127 11616 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1128 11616 : DispatchResponse response = m_backend->stepOver();
1129 11616 : if (weak->get())
1130 11616 : weak->get()->sendResponse(callId, response);
1131 23232 : return response.status();
1132 : }
1133 :
1134 50590 : DispatchResponse::Status DispatcherImpl::stepInto(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1135 : {
1136 :
1137 50590 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1138 50590 : DispatchResponse response = m_backend->stepInto();
1139 50590 : if (weak->get())
1140 50590 : weak->get()->sendResponse(callId, response);
1141 101180 : return response.status();
1142 : }
1143 :
1144 661 : DispatchResponse::Status DispatcherImpl::stepOut(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1145 : {
1146 :
1147 661 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1148 661 : DispatchResponse response = m_backend->stepOut();
1149 661 : if (weak->get())
1150 661 : weak->get()->sendResponse(callId, response);
1151 1322 : return response.status();
1152 : }
1153 :
1154 168 : DispatchResponse::Status DispatcherImpl::pause(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1155 : {
1156 :
1157 168 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1158 168 : DispatchResponse response = m_backend->pause();
1159 168 : if (weak->get())
1160 168 : weak->get()->sendResponse(callId, response);
1161 336 : return response.status();
1162 : }
1163 :
1164 180 : class ScheduleStepIntoAsyncCallbackImpl : public Backend::ScheduleStepIntoAsyncCallback, public DispatcherBase::Callback {
1165 : public:
1166 90 : ScheduleStepIntoAsyncCallbackImpl(std::unique_ptr<DispatcherBase::WeakPtr> backendImpl, int callId, int callbackId)
1167 180 : : DispatcherBase::Callback(std::move(backendImpl), callId, callbackId) { }
1168 :
1169 72 : void sendSuccess() override
1170 : {
1171 72 : std::unique_ptr<protocol::DictionaryValue> resultObject = DictionaryValue::create();
1172 288 : sendIfActive(std::move(resultObject), DispatchResponse::OK());
1173 72 : }
1174 :
1175 0 : void fallThrough() override
1176 : {
1177 0 : fallThroughIfActive();
1178 0 : }
1179 :
1180 18 : void sendFailure(const DispatchResponse& response) override
1181 : {
1182 : DCHECK(response.status() == DispatchResponse::kError);
1183 36 : sendIfActive(nullptr, response);
1184 18 : }
1185 : };
1186 :
1187 90 : DispatchResponse::Status DispatcherImpl::scheduleStepIntoAsync(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1188 : {
1189 :
1190 90 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1191 180 : std::unique_ptr<ScheduleStepIntoAsyncCallbackImpl> callback(new ScheduleStepIntoAsyncCallbackImpl(weakPtr(), callId, nextCallbackId()));
1192 270 : m_backend->scheduleStepIntoAsync(std::move(callback));
1193 180 : return (weak->get() && weak->get()->lastCallbackFallThrough()) ? DispatchResponse::kFallThrough : DispatchResponse::kAsync;
1194 : }
1195 :
1196 1608 : DispatchResponse::Status DispatcherImpl::resume(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1197 : {
1198 :
1199 1608 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1200 1608 : DispatchResponse response = m_backend->resume();
1201 1608 : if (weak->get())
1202 1608 : weak->get()->sendResponse(callId, response);
1203 3216 : return response.status();
1204 : }
1205 :
1206 0 : DispatchResponse::Status DispatcherImpl::searchInContent(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1207 : {
1208 : // Prepare input parameters.
1209 0 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1210 0 : errors->push();
1211 0 : protocol::Value* scriptIdValue = object ? object->get("scriptId") : nullptr;
1212 0 : errors->setName("scriptId");
1213 0 : String in_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
1214 0 : protocol::Value* queryValue = object ? object->get("query") : nullptr;
1215 0 : errors->setName("query");
1216 0 : String in_query = ValueConversions<String>::fromValue(queryValue, errors);
1217 0 : protocol::Value* caseSensitiveValue = object ? object->get("caseSensitive") : nullptr;
1218 : Maybe<bool> in_caseSensitive;
1219 0 : if (caseSensitiveValue) {
1220 0 : errors->setName("caseSensitive");
1221 0 : in_caseSensitive = ValueConversions<bool>::fromValue(caseSensitiveValue, errors);
1222 : }
1223 0 : protocol::Value* isRegexValue = object ? object->get("isRegex") : nullptr;
1224 : Maybe<bool> in_isRegex;
1225 0 : if (isRegexValue) {
1226 0 : errors->setName("isRegex");
1227 0 : in_isRegex = ValueConversions<bool>::fromValue(isRegexValue, errors);
1228 : }
1229 0 : errors->pop();
1230 0 : if (errors->hasErrors()) {
1231 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1232 0 : return DispatchResponse::kError;
1233 : }
1234 : // Declare output parameters.
1235 0 : std::unique_ptr<protocol::Array<protocol::Debugger::SearchMatch>> out_result;
1236 :
1237 0 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1238 0 : DispatchResponse response = m_backend->searchInContent(in_scriptId, in_query, std::move(in_caseSensitive), std::move(in_isRegex), &out_result);
1239 0 : if (response.status() == DispatchResponse::kFallThrough)
1240 : return response.status();
1241 0 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1242 0 : if (response.status() == DispatchResponse::kSuccess) {
1243 0 : result->setValue("result", ValueConversions<protocol::Array<protocol::Debugger::SearchMatch>>::toValue(out_result.get()));
1244 : }
1245 0 : if (weak->get())
1246 0 : weak->get()->sendResponse(callId, response, std::move(result));
1247 0 : return response.status();
1248 : }
1249 :
1250 44 : DispatchResponse::Status DispatcherImpl::setScriptSource(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1251 : {
1252 : // Prepare input parameters.
1253 132 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1254 44 : errors->push();
1255 88 : protocol::Value* scriptIdValue = object ? object->get("scriptId") : nullptr;
1256 88 : errors->setName("scriptId");
1257 44 : String in_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
1258 88 : protocol::Value* scriptSourceValue = object ? object->get("scriptSource") : nullptr;
1259 88 : errors->setName("scriptSource");
1260 44 : String in_scriptSource = ValueConversions<String>::fromValue(scriptSourceValue, errors);
1261 88 : protocol::Value* dryRunValue = object ? object->get("dryRun") : nullptr;
1262 : Maybe<bool> in_dryRun;
1263 44 : if (dryRunValue) {
1264 0 : errors->setName("dryRun");
1265 0 : in_dryRun = ValueConversions<bool>::fromValue(dryRunValue, errors);
1266 : }
1267 44 : errors->pop();
1268 44 : if (errors->hasErrors()) {
1269 28 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1270 14 : return DispatchResponse::kError;
1271 : }
1272 : // Declare output parameters.
1273 : Maybe<protocol::Array<protocol::Debugger::CallFrame>> out_callFrames;
1274 : Maybe<bool> out_stackChanged;
1275 : Maybe<protocol::Runtime::StackTrace> out_asyncStackTrace;
1276 : Maybe<protocol::Runtime::ExceptionDetails> out_exceptionDetails;
1277 :
1278 30 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1279 60 : DispatchResponse response = m_backend->setScriptSource(in_scriptId, in_scriptSource, std::move(in_dryRun), &out_callFrames, &out_stackChanged, &out_asyncStackTrace, &out_exceptionDetails);
1280 30 : if (response.status() == DispatchResponse::kFallThrough)
1281 : return response.status();
1282 30 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1283 30 : if (response.status() == DispatchResponse::kSuccess) {
1284 18 : if (out_callFrames.isJust())
1285 24 : result->setValue("callFrames", ValueConversions<protocol::Array<protocol::Debugger::CallFrame>>::toValue(out_callFrames.fromJust()));
1286 18 : if (out_stackChanged.isJust())
1287 30 : result->setValue("stackChanged", ValueConversions<bool>::toValue(out_stackChanged.fromJust()));
1288 18 : if (out_asyncStackTrace.isJust())
1289 0 : result->setValue("asyncStackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(out_asyncStackTrace.fromJust()));
1290 18 : if (out_exceptionDetails.isJust())
1291 48 : result->setValue("exceptionDetails", ValueConversions<protocol::Runtime::ExceptionDetails>::toValue(out_exceptionDetails.fromJust()));
1292 : }
1293 30 : if (weak->get())
1294 60 : weak->get()->sendResponse(callId, response, std::move(result));
1295 30 : return response.status();
1296 : }
1297 :
1298 160 : DispatchResponse::Status DispatcherImpl::restartFrame(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1299 : {
1300 : // Prepare input parameters.
1301 480 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1302 160 : errors->push();
1303 320 : protocol::Value* callFrameIdValue = object ? object->get("callFrameId") : nullptr;
1304 320 : errors->setName("callFrameId");
1305 160 : String in_callFrameId = ValueConversions<String>::fromValue(callFrameIdValue, errors);
1306 160 : errors->pop();
1307 160 : if (errors->hasErrors()) {
1308 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1309 0 : return DispatchResponse::kError;
1310 : }
1311 : // Declare output parameters.
1312 160 : std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>> out_callFrames;
1313 : Maybe<protocol::Runtime::StackTrace> out_asyncStackTrace;
1314 :
1315 160 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1316 160 : DispatchResponse response = m_backend->restartFrame(in_callFrameId, &out_callFrames, &out_asyncStackTrace);
1317 160 : if (response.status() == DispatchResponse::kFallThrough)
1318 : return response.status();
1319 160 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1320 160 : if (response.status() == DispatchResponse::kSuccess) {
1321 616 : result->setValue("callFrames", ValueConversions<protocol::Array<protocol::Debugger::CallFrame>>::toValue(out_callFrames.get()));
1322 154 : if (out_asyncStackTrace.isJust())
1323 0 : result->setValue("asyncStackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(out_asyncStackTrace.fromJust()));
1324 : }
1325 160 : if (weak->get())
1326 320 : weak->get()->sendResponse(callId, response, std::move(result));
1327 160 : return response.status();
1328 : }
1329 :
1330 854 : DispatchResponse::Status DispatcherImpl::getScriptSource(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1331 : {
1332 : // Prepare input parameters.
1333 2562 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1334 854 : errors->push();
1335 1708 : protocol::Value* scriptIdValue = object ? object->get("scriptId") : nullptr;
1336 1708 : errors->setName("scriptId");
1337 854 : String in_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
1338 854 : errors->pop();
1339 854 : if (errors->hasErrors()) {
1340 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1341 0 : return DispatchResponse::kError;
1342 : }
1343 : // Declare output parameters.
1344 : String out_scriptSource;
1345 :
1346 854 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1347 854 : DispatchResponse response = m_backend->getScriptSource(in_scriptId, &out_scriptSource);
1348 854 : if (response.status() == DispatchResponse::kFallThrough)
1349 : return response.status();
1350 854 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1351 854 : if (response.status() == DispatchResponse::kSuccess) {
1352 3416 : result->setValue("scriptSource", ValueConversions<String>::toValue(out_scriptSource));
1353 : }
1354 854 : if (weak->get())
1355 1708 : weak->get()->sendResponse(callId, response, std::move(result));
1356 854 : return response.status();
1357 : }
1358 :
1359 7088 : DispatchResponse::Status DispatcherImpl::setPauseOnExceptions(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1360 : {
1361 : // Prepare input parameters.
1362 21264 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1363 7088 : errors->push();
1364 14176 : protocol::Value* stateValue = object ? object->get("state") : nullptr;
1365 14176 : errors->setName("state");
1366 7088 : String in_state = ValueConversions<String>::fromValue(stateValue, errors);
1367 7088 : errors->pop();
1368 7088 : if (errors->hasErrors()) {
1369 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1370 0 : return DispatchResponse::kError;
1371 : }
1372 :
1373 7088 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1374 7088 : DispatchResponse response = m_backend->setPauseOnExceptions(in_state);
1375 7088 : if (weak->get())
1376 7088 : weak->get()->sendResponse(callId, response);
1377 7088 : return response.status();
1378 : }
1379 :
1380 14240 : DispatchResponse::Status DispatcherImpl::evaluateOnCallFrame(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1381 : {
1382 : // Prepare input parameters.
1383 42720 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1384 14240 : errors->push();
1385 28480 : protocol::Value* callFrameIdValue = object ? object->get("callFrameId") : nullptr;
1386 28480 : errors->setName("callFrameId");
1387 14240 : String in_callFrameId = ValueConversions<String>::fromValue(callFrameIdValue, errors);
1388 28480 : protocol::Value* expressionValue = object ? object->get("expression") : nullptr;
1389 28480 : errors->setName("expression");
1390 14240 : String in_expression = ValueConversions<String>::fromValue(expressionValue, errors);
1391 28480 : protocol::Value* objectGroupValue = object ? object->get("objectGroup") : nullptr;
1392 : Maybe<String> in_objectGroup;
1393 14240 : if (objectGroupValue) {
1394 0 : errors->setName("objectGroup");
1395 0 : in_objectGroup = ValueConversions<String>::fromValue(objectGroupValue, errors);
1396 : }
1397 28480 : protocol::Value* includeCommandLineAPIValue = object ? object->get("includeCommandLineAPI") : nullptr;
1398 : Maybe<bool> in_includeCommandLineAPI;
1399 14240 : if (includeCommandLineAPIValue) {
1400 0 : errors->setName("includeCommandLineAPI");
1401 0 : in_includeCommandLineAPI = ValueConversions<bool>::fromValue(includeCommandLineAPIValue, errors);
1402 : }
1403 28480 : protocol::Value* silentValue = object ? object->get("silent") : nullptr;
1404 : Maybe<bool> in_silent;
1405 14240 : if (silentValue) {
1406 0 : errors->setName("silent");
1407 0 : in_silent = ValueConversions<bool>::fromValue(silentValue, errors);
1408 : }
1409 28480 : protocol::Value* returnByValueValue = object ? object->get("returnByValue") : nullptr;
1410 : Maybe<bool> in_returnByValue;
1411 14240 : if (returnByValueValue) {
1412 0 : errors->setName("returnByValue");
1413 0 : in_returnByValue = ValueConversions<bool>::fromValue(returnByValueValue, errors);
1414 : }
1415 28480 : protocol::Value* generatePreviewValue = object ? object->get("generatePreview") : nullptr;
1416 : Maybe<bool> in_generatePreview;
1417 14240 : if (generatePreviewValue) {
1418 0 : errors->setName("generatePreview");
1419 0 : in_generatePreview = ValueConversions<bool>::fromValue(generatePreviewValue, errors);
1420 : }
1421 28480 : protocol::Value* throwOnSideEffectValue = object ? object->get("throwOnSideEffect") : nullptr;
1422 : Maybe<bool> in_throwOnSideEffect;
1423 14240 : if (throwOnSideEffectValue) {
1424 28332 : errors->setName("throwOnSideEffect");
1425 14166 : in_throwOnSideEffect = ValueConversions<bool>::fromValue(throwOnSideEffectValue, errors);
1426 : }
1427 14240 : errors->pop();
1428 14240 : if (errors->hasErrors()) {
1429 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1430 0 : return DispatchResponse::kError;
1431 : }
1432 : // Declare output parameters.
1433 14240 : std::unique_ptr<protocol::Runtime::RemoteObject> out_result;
1434 : Maybe<protocol::Runtime::ExceptionDetails> out_exceptionDetails;
1435 :
1436 14240 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1437 42720 : DispatchResponse response = m_backend->evaluateOnCallFrame(in_callFrameId, in_expression, std::move(in_objectGroup), std::move(in_includeCommandLineAPI), std::move(in_silent), std::move(in_returnByValue), std::move(in_generatePreview), std::move(in_throwOnSideEffect), &out_result, &out_exceptionDetails);
1438 14240 : if (response.status() == DispatchResponse::kFallThrough)
1439 : return response.status();
1440 14240 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1441 14240 : if (response.status() == DispatchResponse::kSuccess) {
1442 56876 : result->setValue("result", ValueConversions<protocol::Runtime::RemoteObject>::toValue(out_result.get()));
1443 14219 : if (out_exceptionDetails.isJust())
1444 5904 : result->setValue("exceptionDetails", ValueConversions<protocol::Runtime::ExceptionDetails>::toValue(out_exceptionDetails.fromJust()));
1445 : }
1446 14240 : if (weak->get())
1447 28480 : weak->get()->sendResponse(callId, response, std::move(result));
1448 14240 : return response.status();
1449 : }
1450 :
1451 176 : DispatchResponse::Status DispatcherImpl::setVariableValue(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1452 : {
1453 : // Prepare input parameters.
1454 528 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1455 176 : errors->push();
1456 352 : protocol::Value* scopeNumberValue = object ? object->get("scopeNumber") : nullptr;
1457 352 : errors->setName("scopeNumber");
1458 176 : int in_scopeNumber = ValueConversions<int>::fromValue(scopeNumberValue, errors);
1459 352 : protocol::Value* variableNameValue = object ? object->get("variableName") : nullptr;
1460 352 : errors->setName("variableName");
1461 176 : String in_variableName = ValueConversions<String>::fromValue(variableNameValue, errors);
1462 352 : protocol::Value* newValueValue = object ? object->get("newValue") : nullptr;
1463 352 : errors->setName("newValue");
1464 : std::unique_ptr<protocol::Runtime::CallArgument> in_newValue = ValueConversions<protocol::Runtime::CallArgument>::fromValue(newValueValue, errors);
1465 352 : protocol::Value* callFrameIdValue = object ? object->get("callFrameId") : nullptr;
1466 352 : errors->setName("callFrameId");
1467 176 : String in_callFrameId = ValueConversions<String>::fromValue(callFrameIdValue, errors);
1468 176 : errors->pop();
1469 176 : if (errors->hasErrors()) {
1470 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1471 0 : return DispatchResponse::kError;
1472 : }
1473 :
1474 176 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1475 528 : DispatchResponse response = m_backend->setVariableValue(in_scopeNumber, in_variableName, std::move(in_newValue), in_callFrameId);
1476 176 : if (weak->get())
1477 176 : weak->get()->sendResponse(callId, response);
1478 176 : return response.status();
1479 : }
1480 :
1481 198 : DispatchResponse::Status DispatcherImpl::setAsyncCallStackDepth(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1482 : {
1483 : // Prepare input parameters.
1484 594 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1485 198 : errors->push();
1486 396 : protocol::Value* maxDepthValue = object ? object->get("maxDepth") : nullptr;
1487 396 : errors->setName("maxDepth");
1488 198 : int in_maxDepth = ValueConversions<int>::fromValue(maxDepthValue, errors);
1489 198 : errors->pop();
1490 198 : if (errors->hasErrors()) {
1491 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1492 0 : return DispatchResponse::kError;
1493 : }
1494 :
1495 198 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1496 198 : DispatchResponse response = m_backend->setAsyncCallStackDepth(in_maxDepth);
1497 198 : if (weak->get())
1498 198 : weak->get()->sendResponse(callId, response);
1499 198 : return response.status();
1500 : }
1501 :
1502 56 : DispatchResponse::Status DispatcherImpl::setBlackboxPatterns(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1503 : {
1504 : // Prepare input parameters.
1505 168 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1506 56 : errors->push();
1507 112 : protocol::Value* patternsValue = object ? object->get("patterns") : nullptr;
1508 112 : errors->setName("patterns");
1509 : std::unique_ptr<protocol::Array<String>> in_patterns = ValueConversions<protocol::Array<String>>::fromValue(patternsValue, errors);
1510 56 : errors->pop();
1511 56 : if (errors->hasErrors()) {
1512 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1513 0 : return DispatchResponse::kError;
1514 : }
1515 :
1516 56 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1517 168 : DispatchResponse response = m_backend->setBlackboxPatterns(std::move(in_patterns));
1518 56 : if (weak->get())
1519 56 : weak->get()->sendResponse(callId, response);
1520 56 : return response.status();
1521 : }
1522 :
1523 66 : DispatchResponse::Status DispatcherImpl::setBlackboxedRanges(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1524 : {
1525 : // Prepare input parameters.
1526 198 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1527 66 : errors->push();
1528 132 : protocol::Value* scriptIdValue = object ? object->get("scriptId") : nullptr;
1529 132 : errors->setName("scriptId");
1530 66 : String in_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
1531 132 : protocol::Value* positionsValue = object ? object->get("positions") : nullptr;
1532 132 : errors->setName("positions");
1533 : std::unique_ptr<protocol::Array<protocol::Debugger::ScriptPosition>> in_positions = ValueConversions<protocol::Array<protocol::Debugger::ScriptPosition>>::fromValue(positionsValue, errors);
1534 66 : errors->pop();
1535 66 : if (errors->hasErrors()) {
1536 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1537 0 : return DispatchResponse::kError;
1538 : }
1539 :
1540 66 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1541 198 : DispatchResponse response = m_backend->setBlackboxedRanges(in_scriptId, std::move(in_positions));
1542 66 : if (weak->get())
1543 66 : weak->get()->sendResponse(callId, response);
1544 66 : return response.status();
1545 : }
1546 :
1547 : // static
1548 4573 : void Dispatcher::wire(UberDispatcher* dispatcher, Backend* backend)
1549 : {
1550 18292 : dispatcher->registerBackend("Debugger", std::unique_ptr<protocol::DispatcherBase>(new DispatcherImpl(dispatcher->channel(), backend, dispatcher->fallThroughForNotFound())));
1551 4573 : }
1552 :
1553 : } // Debugger
1554 : } // namespace v8_inspector
1555 : } // namespace protocol
|