1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "tooling/base/pt_params.h"
17
18 namespace panda::ecmascript::tooling {
Create(const PtJson & params)19 std::unique_ptr<EnableParams> EnableParams::Create(const PtJson ¶ms)
20 {
21 auto paramsObject = std::make_unique<EnableParams>();
22 std::string error;
23 Result ret;
24
25 double maxScriptsCacheSize;
26 ret = params.GetDouble("maxScriptsCacheSize", &maxScriptsCacheSize);
27 if (ret == Result::SUCCESS) {
28 paramsObject->maxScriptsCacheSize_ = maxScriptsCacheSize;
29 } else if (ret == Result::TYPE_ERROR) {
30 error += "Wrong type of 'maxScriptsCacheSize';";
31 }
32
33 if (!error.empty()) {
34 LOG_DEBUGGER(ERROR) << "EnableParams::Create " << error;
35 return nullptr;
36 }
37
38 return paramsObject;
39 }
40
Create(const PtJson & params)41 std::unique_ptr<EvaluateOnCallFrameParams> EvaluateOnCallFrameParams::Create(const PtJson ¶ms)
42 {
43 auto paramsObject = std::make_unique<EvaluateOnCallFrameParams>();
44 std::string error;
45 Result ret;
46
47 std::string callFrameId;
48 ret = params.GetString("callFrameId", &callFrameId);
49 if (ret == Result::SUCCESS) {
50 if (!ToolchainUtils::StrToInt32(callFrameId, paramsObject->callFrameId_)) {
51 error += "Failed to convert 'callFrameId' from string to int;";
52 }
53 } else {
54 error += "Unknown or wrong type of 'callFrameId';";
55 }
56 std::string expression;
57 ret = params.GetString("expression", &expression);
58 if (ret == Result::SUCCESS) {
59 paramsObject->expression_ = std::move(expression);
60 } else {
61 error += "Unknown or wrong type of 'expression';";
62 }
63 std::string objectGroup;
64 ret = params.GetString("objectGroup", &objectGroup);
65 if (ret == Result::SUCCESS) {
66 paramsObject->objectGroup_ = std::move(objectGroup);
67 } else if (ret == Result::TYPE_ERROR) {
68 error += "Wrong type of 'objectGroup';";
69 }
70 bool includeCommandLineAPI = false;
71 ret = params.GetBool("includeCommandLineAPI", &includeCommandLineAPI);
72 if (ret == Result::SUCCESS) {
73 paramsObject->includeCommandLineAPI_ = includeCommandLineAPI;
74 } else if (ret == Result::TYPE_ERROR) {
75 error += "Wrong type of 'includeCommandLineAPI';";
76 }
77 bool silent = false;
78 ret = params.GetBool("silent", &silent);
79 if (ret == Result::SUCCESS) {
80 paramsObject->silent_ = silent;
81 } else if (ret == Result::TYPE_ERROR) {
82 error += "Wrong type of 'silent';";
83 }
84 bool returnByValue = false;
85 ret = params.GetBool("returnByValue", &returnByValue);
86 if (ret == Result::SUCCESS) {
87 paramsObject->returnByValue_ = returnByValue;
88 } else if (ret == Result::TYPE_ERROR) {
89 error += "Wrong type of 'returnByValue';";
90 }
91 bool generatePreview = false;
92 ret = params.GetBool("generatePreview", &generatePreview);
93 if (ret == Result::SUCCESS) {
94 paramsObject->generatePreview_ = generatePreview;
95 } else if (ret == Result::TYPE_ERROR) {
96 error += "Wrong type of 'generatePreview';";
97 }
98 bool throwOnSideEffect = false;
99 ret = params.GetBool("throwOnSideEffect", &throwOnSideEffect);
100 if (ret == Result::SUCCESS) {
101 paramsObject->throwOnSideEffect_ = throwOnSideEffect;
102 } else if (ret == Result::TYPE_ERROR) {
103 error += "Wrong type of 'throwOnSideEffect';";
104 }
105
106 if (!error.empty()) {
107 LOG_DEBUGGER(ERROR) << "EvaluateOnCallFrameParams::Create " << error;
108 return nullptr;
109 }
110 return paramsObject;
111 }
112
Create(const PtJson & params)113 std::unique_ptr<ContinueToLocationParams> ContinueToLocationParams::Create(const PtJson ¶ms)
114 {
115 auto paramsObject = std::make_unique<ContinueToLocationParams>();
116 std::string error;
117 Result ret;
118
119 std::unique_ptr<PtJson> position;
120 ret = params.GetObject("location", &position);
121 if (ret == Result::SUCCESS) {
122 std::unique_ptr<Location> location = Location::Create(*position);
123 if (location == nullptr) {
124 error += "'location' is invalid;";
125 } else {
126 paramsObject->location_= std::move(location);
127 }
128 } else {
129 error += "Unknown or wrong type of 'location';";
130 }
131
132 std::string targetCallFrames;
133 ret = params.GetString("targetCallFrames", &targetCallFrames);
134 if (ret == Result::SUCCESS) {
135 paramsObject->targetCallFrames_ = std::move(targetCallFrames);
136 } else {
137 error += "Unknown 'targetCallFrames';";
138 }
139
140 if (!error.empty()) {
141 LOG_DEBUGGER(ERROR) << "ContinueToLocationParams::Create " << error;
142 return nullptr;
143 }
144
145 return paramsObject;
146 }
147
148
Create(const PtJson & params)149 std::unique_ptr<GetPossibleBreakpointsParams> GetPossibleBreakpointsParams::Create(const PtJson ¶ms)
150 {
151 auto paramsObject = std::make_unique<GetPossibleBreakpointsParams>();
152 std::string error;
153 Result ret;
154
155 std::unique_ptr<PtJson> start;
156 ret = params.GetObject("start", &start);
157 if (ret == Result::SUCCESS) {
158 std::unique_ptr<Location> location = Location::Create(*start);
159 if (location == nullptr) {
160 error += "'start' is invalid;";
161 } else {
162 paramsObject->start_ = std::move(location);
163 }
164 } else {
165 error += "Unknown or wrong type of 'start';";
166 }
167 std::unique_ptr<PtJson> end;
168 ret = params.GetObject("end", &end);
169 if (ret == Result::SUCCESS) {
170 std::unique_ptr<Location> location = Location::Create(*end);
171 if (location == nullptr) {
172 error += "'end' is invalid;";
173 } else {
174 paramsObject->end_ = std::move(location);
175 }
176 } else if (ret == Result::TYPE_ERROR) {
177 error += "Wrong type of 'end';";
178 }
179 bool restrictToFunction = false;
180 ret = params.GetBool("restrictToFunction", &restrictToFunction);
181 if (ret == Result::SUCCESS) {
182 paramsObject->restrictToFunction_ = restrictToFunction;
183 } else if (ret == Result::TYPE_ERROR) {
184 error += "Wrong type of 'restrictToFunction';";
185 }
186
187 if (!error.empty()) {
188 LOG_DEBUGGER(ERROR) << "GetPossibleBreakpointsParams::Create " << error;
189 return nullptr;
190 }
191
192 return paramsObject;
193 }
194
Create(const PtJson & params)195 std::unique_ptr<GetScriptSourceParams> GetScriptSourceParams::Create(const PtJson ¶ms)
196 {
197 auto paramsObject = std::make_unique<GetScriptSourceParams>();
198 std::string error;
199 Result ret;
200
201 std::string scriptId;
202 ret = params.GetString("scriptId", &scriptId);
203 if (ret == Result::SUCCESS) {
204 if (!ToolchainUtils::StrToInt32(scriptId, paramsObject->scriptId_)) {
205 error += "Failed to convert 'scriptId' from string to int;";
206 }
207 } else {
208 error += "Unknown or wrong type of'scriptId';";
209 }
210
211 if (!error.empty()) {
212 LOG_DEBUGGER(ERROR) << "GetScriptSourceParams::Create " << error;
213 return nullptr;
214 }
215
216 return paramsObject;
217 }
218
Create(const PtJson & params)219 std::unique_ptr<RemoveBreakpointParams> RemoveBreakpointParams::Create(const PtJson ¶ms)
220 {
221 auto paramsObject = std::make_unique<RemoveBreakpointParams>();
222 std::string error;
223 Result ret;
224
225 std::string breakpointId;
226 ret = params.GetString("breakpointId", &breakpointId);
227 if (ret == Result::SUCCESS) {
228 paramsObject->breakpointId_ = std::move(breakpointId);
229 } else {
230 error += "Unknown or wrong type of 'breakpointId';";
231 }
232
233 if (!error.empty()) {
234 LOG_DEBUGGER(ERROR) << "RemoveBreakpointParams::Create " << error;
235 return nullptr;
236 }
237
238 return paramsObject;
239 }
240
Create(const PtJson & params)241 std::unique_ptr<RemoveBreakpointsByUrlParams> RemoveBreakpointsByUrlParams::Create(const PtJson ¶ms)
242 {
243 auto paramsObject = std::make_unique<RemoveBreakpointsByUrlParams>();
244 std::string error;
245 Result ret;
246
247 std::string url;
248 ret = params.GetString("url", &url);
249 if (ret == Result::SUCCESS) {
250 paramsObject->url_ = std::move(url);
251 } else {
252 error += "Wrong or unknown type of 'url'";
253 }
254
255 if (!error.empty()) {
256 LOG_DEBUGGER(ERROR) << "RemoveBreakpointByUrlParams::Create " << error;
257 return nullptr;
258 }
259
260 return paramsObject;
261 }
262
Create(const PtJson & params)263 std::unique_ptr<ResumeParams> ResumeParams::Create(const PtJson ¶ms)
264 {
265 auto paramsObject = std::make_unique<ResumeParams>();
266 std::string error;
267 Result ret;
268
269 bool terminateOnResume = false;
270 ret = params.GetBool("terminateOnResume", &terminateOnResume);
271 if (ret == Result::SUCCESS) {
272 paramsObject->terminateOnResume_ = terminateOnResume;
273 } else if (ret == Result::TYPE_ERROR) {
274 error += "Wrong type of 'terminateOnResume';";
275 }
276
277 if (!error.empty()) {
278 LOG_DEBUGGER(ERROR) << "ResumeParams::Create " << error;
279 return nullptr;
280 }
281
282 return paramsObject;
283 }
284
Create(const PtJson & params)285 std::unique_ptr<SetAsyncCallStackDepthParams> SetAsyncCallStackDepthParams::Create(const PtJson ¶ms)
286 {
287 auto paramsObject = std::make_unique<SetAsyncCallStackDepthParams>();
288 std::string error;
289 Result ret;
290
291 int32_t maxDepth;
292 ret = params.GetInt("maxDepth", &maxDepth);
293 if (ret == Result::SUCCESS) {
294 paramsObject->maxDepth_ = maxDepth;
295 } else {
296 error += "Unknown or wrong type of 'maxDepth';";
297 }
298
299 if (!error.empty()) {
300 LOG_DEBUGGER(ERROR) << "SetAsyncCallStackDepthParams::Create " << error;
301 return nullptr;
302 }
303
304 return paramsObject;
305 }
306
Create(const PtJson & params)307 std::unique_ptr<SetBlackboxPatternsParams> SetBlackboxPatternsParams::Create(const PtJson ¶ms)
308 {
309 auto paramsObject = std::make_unique<SetBlackboxPatternsParams>();
310 std::string error;
311 Result ret;
312
313 std::unique_ptr<PtJson> patterns;
314 ret = params.GetArray("patterns", &patterns);
315 if (ret == Result::SUCCESS) {
316 int32_t len = patterns->GetSize();
317 for (int32_t i = 0; i < len; ++i) {
318 std::unique_ptr<PtJson> item = patterns->Get(i);
319 if (item->IsString()) {
320 paramsObject->patterns_.emplace_back(item->GetString());
321 } else {
322 error += "'patterns' items should be a String;";
323 }
324 }
325 } else {
326 error += "Unknown or wrong type of 'patterns';";
327 }
328
329 if (!error.empty()) {
330 LOG_DEBUGGER(ERROR) << "SetBlackboxPatternsParams::Create " << error;
331 return nullptr;
332 }
333
334 return paramsObject;
335 }
336
Create(const PtJson & params)337 std::unique_ptr<SetBreakpointByUrlParams> SetBreakpointByUrlParams::Create(const PtJson ¶ms)
338 {
339 auto paramsObject = std::make_unique<SetBreakpointByUrlParams>();
340 std::string error;
341 Result ret;
342
343 int32_t lineNumber;
344 ret = params.GetInt("lineNumber", &lineNumber);
345 if (ret == Result::SUCCESS) {
346 paramsObject->lineNumber_ = lineNumber;
347 } else {
348 error += "Unknown or wrong type of 'lineNumber';";
349 }
350 std::string url;
351 ret = params.GetString("url", &url);
352 if (ret == Result::SUCCESS) {
353 paramsObject->url_ = std::move(url);
354 } else if (ret == Result::TYPE_ERROR) {
355 error += "Wrong type of 'url';";
356 }
357 std::string urlRegex;
358 ret = params.GetString("urlRegex", &urlRegex);
359 if (ret == Result::SUCCESS) {
360 paramsObject->urlRegex_ = std::move(urlRegex);
361 } else if (ret == Result::TYPE_ERROR) {
362 error += "Wrong type of 'urlRegex';";
363 }
364 std::string scriptHash;
365 ret = params.GetString("scriptHash", &scriptHash);
366 if (ret == Result::SUCCESS) {
367 paramsObject->scriptHash_ = std::move(scriptHash);
368 } else if (ret == Result::TYPE_ERROR) {
369 error += "Wrong type of 'scriptHash';";
370 }
371 int32_t columnNumber;
372 ret = params.GetInt("columnNumber", &columnNumber);
373 if (ret == Result::SUCCESS) {
374 paramsObject->columnNumber_ = columnNumber;
375 } else if (ret == Result::TYPE_ERROR) {
376 error += "Wrong type of 'columnNumber';";
377 }
378 std::string condition;
379 ret = params.GetString("condition", &condition);
380 if (ret == Result::SUCCESS) {
381 paramsObject->condition_ = std::move(condition);
382 } else if (ret == Result::TYPE_ERROR) {
383 error += "Wrong type of 'condition';";
384 }
385 if (!error.empty()) {
386 LOG_DEBUGGER(ERROR) << "SetBreakpointByUrlParams::Create " << error;
387 return nullptr;
388 }
389
390 return paramsObject;
391 }
392
Create(const PtJson & params)393 std::unique_ptr<SetBreakpointsActiveParams> SetBreakpointsActiveParams::Create(const PtJson ¶ms)
394 {
395 auto paramsObject = std::make_unique<SetBreakpointsActiveParams>();
396 std::string error;
397 Result ret;
398
399 bool breakpointsState;
400 ret = params.GetBool("active", &breakpointsState);
401 if (ret == Result::SUCCESS) {
402 paramsObject->breakpointsState_ = std::move(breakpointsState);
403 } else {
404 error += "Unknown or wrong type of 'active';";
405 }
406 if (!error.empty()) {
407 LOG_DEBUGGER(ERROR) << "SetBreakpointsActiveParams::Create " << error;
408 return nullptr;
409 }
410
411 return paramsObject;
412 }
413
Create(const PtJson & params)414 std::unique_ptr<SetSkipAllPausesParams> SetSkipAllPausesParams::Create(const PtJson ¶ms)
415 {
416 auto paramsObject = std::make_unique<SetSkipAllPausesParams>();
417 std::string error;
418 Result ret;
419
420 bool skipAllPausesState;
421 ret = params.GetBool("skip", &skipAllPausesState);
422 if (ret == Result::SUCCESS) {
423 paramsObject->skipAllPausesState_ = std::move(skipAllPausesState);
424 } else {
425 error += "Unknown or wrong type of 'skip';";
426 }
427 if (!error.empty()) {
428 LOG_DEBUGGER(ERROR) << "SetSkipAllPausesParams::Create " << error;
429 return nullptr;
430 }
431
432 return paramsObject;
433 }
434
Create(const PtJson & params)435 std::unique_ptr<GetPossibleAndSetBreakpointParams> GetPossibleAndSetBreakpointParams::Create(const PtJson ¶ms)
436 {
437 auto paramsObject = std::make_unique<GetPossibleAndSetBreakpointParams>();
438 std::string error;
439 Result ret;
440
441 std::unique_ptr<PtJson> breakpoints;
442 ret = params.GetArray("locations", &breakpoints);
443 if (ret == Result::SUCCESS) {
444 int32_t length = breakpoints->GetSize();
445 std::vector<std::unique_ptr<BreakpointInfo>> breakpointList;
446 for (int32_t i = 0; i < length; i++) {
447 std::unique_ptr<BreakpointInfo> info = BreakpointInfo::Create(*breakpoints->Get(i));
448 if (info == nullptr) {
449 error += "'breakpoints' items BreakpointInfo is invaild;";
450 break;
451 } else {
452 breakpointList.emplace_back(std::move(info));
453 }
454 }
455 if (!breakpointList.empty()) {
456 paramsObject->breakpointsList_ = std::move(breakpointList);
457 }
458 } else if (ret == Result::TYPE_ERROR) {
459 error += "Wrong type of 'breakpoints';";
460 }
461
462 if (!error.empty()) {
463 LOG_DEBUGGER(ERROR) << "GetPossibleAndSetBreakpointParams::Create " << error;
464 return nullptr;
465 }
466
467 return paramsObject;
468 }
469
Create(const PtJson & params)470 std::unique_ptr<SetPauseOnExceptionsParams> SetPauseOnExceptionsParams::Create(const PtJson ¶ms)
471 {
472 auto paramsObject = std::make_unique<SetPauseOnExceptionsParams>();
473 std::string error;
474 Result ret;
475
476 std::string state;
477 ret = params.GetString("state", &state);
478 if (ret == Result::SUCCESS) {
479 paramsObject->StoreState(state);
480 } else {
481 error += "Unknown or wrong type of'state';";
482 }
483
484 if (!error.empty()) {
485 LOG_DEBUGGER(ERROR) << "SetPauseOnExceptionsParams::Create " << error;
486 return nullptr;
487 }
488
489 return paramsObject;
490 }
491
Create(const PtJson & params)492 std::unique_ptr<StepIntoParams> StepIntoParams::Create(const PtJson ¶ms)
493 {
494 auto paramsObject = std::make_unique<StepIntoParams>();
495 std::string error;
496 Result ret;
497
498 bool breakOnAsyncCall = false;
499 ret = params.GetBool("breakOnAsyncCall", &breakOnAsyncCall);
500 if (ret == Result::SUCCESS) {
501 paramsObject->breakOnAsyncCall_ = breakOnAsyncCall;
502 } else if (ret == Result::TYPE_ERROR) {
503 error += "Wrong type of 'breakOnAsyncCall';";
504 }
505 std::unique_ptr<PtJson> skipList;
506 ret = params.GetArray("skipList", &skipList);
507 if (ret == Result::SUCCESS) {
508 int32_t len = skipList->GetSize();
509 std::list<std::unique_ptr<LocationRange>> listLocation;
510 for (int32_t i = 0; i < len; ++i) {
511 std::unique_ptr<LocationRange> obj = LocationRange::Create(*skipList->Get(i));
512 if (obj == nullptr) {
513 error += "'skipList' items LocationRange is invalid;";
514 break;
515 } else {
516 listLocation.emplace_back(std::move(obj));
517 }
518 }
519 if (listLocation.size()) {
520 paramsObject->skipList_ = std::move(listLocation);
521 }
522 } else if (ret == Result::TYPE_ERROR) {
523 error += "Wrong type of 'skipList';";
524 }
525
526 if (!error.empty()) {
527 LOG_DEBUGGER(ERROR) << "StepIntoParams::Create " << error;
528 return nullptr;
529 }
530
531 return paramsObject;
532 }
533
Create(const PtJson & params)534 std::unique_ptr<SmartStepIntoParams> SmartStepIntoParams::Create(const PtJson ¶ms)
535 {
536 auto paramsObject = std::make_unique<SmartStepIntoParams>();
537 auto sbpObject = std::make_unique<SetBreakpointByUrlParams>();
538 PtJson ptJson(params.GetJson());
539 AddRequireParams(ptJson);
540 if (!(sbpObject = SetBreakpointByUrlParams::Create(ptJson))) {
541 return nullptr;
542 }
543 paramsObject->sbpParams_ = std::move(sbpObject);
544 return paramsObject;
545 }
546
AddRequireParams(PtJson & params)547 void SmartStepIntoParams::AddRequireParams(PtJson ¶ms)
548 {
549 if (!params.Contains("urlRegex")) {
550 params.Add("urlRegex", "");
551 }
552 if (!params.Contains("scriptHash")) {
553 params.Add("scriptHash", "");
554 }
555 if (!params.Contains("columnNumber")) {
556 params.Add("columnNumber", 0);
557 }
558 if (!params.Contains("condition")) {
559 params.Add("condition", "");
560 }
561 }
562
Create(const PtJson & params)563 std::unique_ptr<StepOverParams> StepOverParams::Create(const PtJson ¶ms)
564 {
565 auto paramsObject = std::make_unique<StepOverParams>();
566 std::string error;
567 Result ret;
568
569 std::unique_ptr<PtJson> skipList;
570 ret = params.GetArray("skipList", &skipList);
571 if (ret == Result::SUCCESS) {
572 int32_t len = skipList->GetSize();
573 std::list<std::unique_ptr<LocationRange>> listLocation;
574 for (int32_t i = 0; i < len; ++i) {
575 std::unique_ptr<LocationRange> obj = LocationRange::Create(*skipList->Get(i));
576 if (obj == nullptr) {
577 error += "'skipList' items LocationRange is invalid;";
578 break;
579 } else {
580 listLocation.emplace_back(std::move(obj));
581 }
582 }
583 if (listLocation.size()) {
584 paramsObject->skipList_ = std::move(listLocation);
585 }
586 } else if (ret == Result::TYPE_ERROR) {
587 error += "Wrong type of 'skipList';";
588 }
589
590 if (!error.empty()) {
591 LOG_DEBUGGER(ERROR) << "StepOverParams::Create " << error;
592 return nullptr;
593 }
594
595 return paramsObject;
596 }
597
Create(const PtJson & params)598 std::unique_ptr<DropFrameParams> DropFrameParams::Create(const PtJson ¶ms)
599 {
600 auto paramsObject = std::make_unique<DropFrameParams>();
601 std::string error;
602 Result ret;
603
604 uint32_t droppedDepth = 0;
605 ret = params.GetUInt("droppedDepth", &droppedDepth);
606 if (ret == Result::SUCCESS) {
607 paramsObject->droppedDepth_ = droppedDepth;
608 } else if (ret == Result::TYPE_ERROR) {
609 error += "Wrong type of 'droppedDepth';";
610 }
611
612 if (!error.empty()) {
613 LOG_DEBUGGER(ERROR) << "DropFrameParams::Create " << error;
614 return nullptr;
615 }
616
617 return paramsObject;
618 }
619
Create(const PtJson & params)620 std::unique_ptr<SetNativeRangeParams> SetNativeRangeParams::Create(const PtJson ¶ms)
621 {
622 auto paramsObject = std::make_unique<SetNativeRangeParams>();
623 std::string error;
624 Result ret;
625
626 std::unique_ptr<PtJson> nativeRange;
627 ret = params.GetArray("nativeRange", &nativeRange);
628 if (ret == Result::SUCCESS) {
629 int32_t len = nativeRange->GetSize();
630 std::vector<NativeRange> vectorNativeRange;
631 for (int32_t i = 0; i < len; ++i) {
632 std::unique_ptr<NativeRange> obj = NativeRange::Create(*nativeRange->Get(i));
633 if (obj == nullptr) {
634 error += "'nativeRange' is invalid;";
635 break;
636 } else {
637 vectorNativeRange.emplace_back(std::move(*obj));
638 }
639 }
640 if (vectorNativeRange.size()) {
641 paramsObject->nativeRange_ = std::move(vectorNativeRange);
642 }
643 } else if (ret == Result::TYPE_ERROR) {
644 error += "Unknown 'nativeRange';";
645 }
646
647 if (!error.empty()) {
648 LOG_DEBUGGER(ERROR) << "SetNativeRangeParams::Create " << error;
649 return nullptr;
650 }
651
652 return paramsObject;
653 }
654
Create(const PtJson & params)655 std::unique_ptr<SetMixedDebugParams> SetMixedDebugParams::Create(const PtJson ¶ms)
656 {
657 auto paramsObject = std::make_unique<SetMixedDebugParams>();
658 std::string error;
659 Result ret;
660
661 bool enabled = false;
662 ret = params.GetBool("enabled", &enabled);
663 if (ret == Result::SUCCESS) {
664 paramsObject->enabled_ = enabled;
665 } else if (ret == Result::TYPE_ERROR) {
666 error += "Wrong type of 'enabled';";
667 }
668
669 bool mixedStackEnabled = false;
670 ret = params.GetBool("mixedStackEnabled", &mixedStackEnabled);
671 if (ret == Result::SUCCESS) {
672 paramsObject->mixedStackEnabled_ = mixedStackEnabled;
673 } else if (ret == Result::TYPE_ERROR) {
674 error += "Wrong type of 'enabled';";
675 }
676
677 if (!error.empty()) {
678 LOG_DEBUGGER(ERROR) << "SetMixedDebugParams::Create " << error;
679 return nullptr;
680 }
681
682 return paramsObject;
683 }
684
Create(const PtJson & params)685 std::unique_ptr<ResetSingleStepperParams> ResetSingleStepperParams::Create(const PtJson ¶ms)
686 {
687 auto paramsObject = std::make_unique<ResetSingleStepperParams>();
688 std::string error;
689 Result ret;
690
691 bool resetSingleStepper = false;
692 ret = params.GetBool("resetSingleStepper", &resetSingleStepper);
693 if (ret == Result::SUCCESS) {
694 paramsObject->resetSingleStepper_ = resetSingleStepper;
695 } else if (ret == Result::TYPE_ERROR) {
696 error += "Wrong type of 'resetSingleStepper';";
697 }
698
699 if (!error.empty()) {
700 LOG_DEBUGGER(ERROR) << "ResetSingleStepperParams::Create " << error;
701 return nullptr;
702 }
703
704 return paramsObject;
705 }
706
Create(const PtJson & params)707 std::unique_ptr<ReplyNativeCallingParams> ReplyNativeCallingParams::Create(const PtJson ¶ms)
708 {
709 auto paramsObject = std::make_unique<ReplyNativeCallingParams>();
710 std::string error;
711 Result ret;
712
713 bool userCode = false;
714 ret = params.GetBool("userCode", &userCode);
715 if (ret == Result::SUCCESS) {
716 paramsObject->userCode_ = userCode;
717 } else if (ret == Result::TYPE_ERROR) {
718 error += "Wrong type of 'userCode';";
719 }
720
721 if (!error.empty()) {
722 LOG_DEBUGGER(ERROR) << "ReplyNativeCallingParams::Create " << error;
723 return nullptr;
724 }
725
726 return paramsObject;
727 }
728
Create(const PtJson & params)729 std::unique_ptr<GetPropertiesParams> GetPropertiesParams::Create(const PtJson ¶ms)
730 {
731 auto paramsObject = std::make_unique<GetPropertiesParams>();
732 std::string error;
733 Result ret;
734
735 std::string objectId;
736 ret = params.GetString("objectId", &objectId);
737 if (ret == Result::SUCCESS) {
738 if (!ToolchainUtils::StrToInt32(objectId, paramsObject->objectId_)) {
739 error += "Failed to convert 'objectId' from string to int;";
740 }
741 } else {
742 error += "Unknown or wrong type of 'objectId';";
743 }
744 bool ownProperties = false;
745 ret = params.GetBool("ownProperties", &ownProperties);
746 if (ret == Result::SUCCESS) {
747 paramsObject->ownProperties_ = ownProperties;
748 } else if (ret == Result::TYPE_ERROR) {
749 error += "Wrong type of 'ownProperties';";
750 }
751 bool accessorPropertiesOnly = false;
752 ret = params.GetBool("accessorPropertiesOnly", &accessorPropertiesOnly);
753 if (ret == Result::SUCCESS) {
754 paramsObject->accessorPropertiesOnly_ = accessorPropertiesOnly;
755 } else if (ret == Result::TYPE_ERROR) {
756 error += "Wrong type of 'accessorPropertiesOnly';";
757 }
758 bool generatePreview = false;
759 ret = params.GetBool("generatePreview", &generatePreview);
760 if (ret == Result::SUCCESS) {
761 paramsObject->generatePreview_ = generatePreview;
762 } else if (ret == Result::TYPE_ERROR) {
763 error += "Wrong type of 'generatePreview';";
764 }
765 if (!error.empty()) {
766 LOG_DEBUGGER(ERROR) << "GetPropertiesParams::Create " << error;
767 return nullptr;
768 }
769
770 return paramsObject;
771 }
772
Create(const PtJson & params)773 std::unique_ptr<CallFunctionOnParams> CallFunctionOnParams::Create(const PtJson ¶ms)
774 {
775 auto paramsObject = std::make_unique<CallFunctionOnParams>();
776 std::string error;
777 Result ret;
778
779 // paramsObject->callFrameId_
780 std::string callFrameId;
781 ret = params.GetString("callFrameId", &callFrameId);
782 if (ret == Result::SUCCESS) {
783 if (!ToolchainUtils::StrToInt32(callFrameId, paramsObject->callFrameId_)) {
784 error += "Failed to convert 'callFrameId' from string to int;";
785 }
786 } else {
787 error += "Unknown or wrong type of 'callFrameId';";
788 }
789 // paramsObject->functionDeclaration_
790 std::string functionDeclaration;
791 ret = params.GetString("functionDeclaration", &functionDeclaration);
792 if (ret == Result::SUCCESS) {
793 paramsObject->functionDeclaration_ = std::move(functionDeclaration);
794 } else {
795 error += "Unknown or wrong type of 'functionDeclaration';";
796 }
797 // paramsObject->objectId_
798 std::string objectId;
799 ret = params.GetString("objectId", &objectId);
800 if (ret == Result::SUCCESS) {
801 if (!ToolchainUtils::StrToInt32(objectId, paramsObject->objectId_)) {
802 error += "Failed to convert 'objectId' from string to int;";
803 }
804 } else if (ret == Result::TYPE_ERROR) {
805 error += "Wrong type of 'objectId';";
806 }
807 // paramsObject->arguments_
808 std::unique_ptr<PtJson> arguments;
809 ret = params.GetArray("arguments", &arguments);
810 if (ret == Result::SUCCESS) {
811 int32_t len = arguments->GetSize();
812 std::vector<std::unique_ptr<CallArgument>> callArgument;
813 for (int32_t i = 0; i < len; ++i) {
814 std::unique_ptr<CallArgument> obj = CallArgument::Create(*arguments->Get(i));
815 if (obj == nullptr) {
816 error += "'arguments' items CallArgument is invaild;";
817 break;
818 } else {
819 callArgument.emplace_back(std::move(obj));
820 }
821 }
822 if (callArgument.size()) {
823 paramsObject->arguments_ = std::move(callArgument);
824 }
825 } else if (ret == Result::TYPE_ERROR) {
826 error += "Wrong type of 'arguments';";
827 }
828 // paramsObject->silent_
829 bool silent = false;
830 ret = params.GetBool("silent", &silent);
831 if (ret == Result::SUCCESS) {
832 paramsObject->silent_ = silent;
833 } else if (ret == Result::TYPE_ERROR) {
834 error += "Wrong type of 'silent';";
835 }
836 // paramsObject->returnByValue_
837 bool returnByValue = false;
838 ret = params.GetBool("returnByValue", &returnByValue);
839 if (ret == Result::SUCCESS) {
840 paramsObject->returnByValue_ = returnByValue;
841 } else if (ret == Result::TYPE_ERROR) {
842 error += "Wrong type of 'returnByValue';";
843 }
844 // paramsObject->generatePreview_
845 bool generatePreview = false;
846 ret = params.GetBool("generatePreview", &generatePreview);
847 if (ret == Result::SUCCESS) {
848 paramsObject->generatePreview_ = generatePreview;
849 } else if (ret == Result::TYPE_ERROR) {
850 error += "Wrong type of 'generatePreview';";
851 }
852 // paramsObject->userGesture_
853 bool userGesture = false;
854 ret = params.GetBool("userGesture", &userGesture);
855 if (ret == Result::SUCCESS) {
856 paramsObject->userGesture_ = userGesture;
857 } else if (ret == Result::TYPE_ERROR) {
858 error += "Wrong type of 'userGesture';";
859 }
860 // paramsObject->awaitPromise_
861 bool awaitPromise = false;
862 ret = params.GetBool("awaitPromise", &awaitPromise);
863 if (ret == Result::SUCCESS) {
864 paramsObject->awaitPromise_ = awaitPromise;
865 } else if (ret == Result::TYPE_ERROR) {
866 error += "Wrong type of 'awaitPromise';";
867 }
868 // paramsObject->executionContextId_
869 int32_t executionContextId;
870 ret = params.GetInt("executionContextId", &executionContextId);
871 if (ret == Result::SUCCESS) {
872 paramsObject->executionContextId_ = executionContextId;
873 } else if (ret == Result::TYPE_ERROR) {
874 error += "Wrong type of 'executionContextId';";
875 }
876 // paramsObject->objectGroup_
877 std::string objectGroup;
878 ret = params.GetString("objectGroup", &objectGroup);
879 if (ret == Result::SUCCESS) {
880 paramsObject->objectGroup_ = std::move(objectGroup);
881 } else if (ret == Result::TYPE_ERROR) {
882 error += "Wrong type of 'objectGroup';";
883 }
884 // paramsObject->throwOnSideEffect_
885 bool throwOnSideEffect = false;
886 ret = params.GetBool("throwOnSideEffect", &throwOnSideEffect);
887 if (ret == Result::SUCCESS) {
888 paramsObject->throwOnSideEffect_ = throwOnSideEffect;
889 } else if (ret == Result::TYPE_ERROR) {
890 error += "Wrong type of 'throwOnSideEffect';";
891 }
892
893 // Check whether the error is empty.
894 if (!error.empty()) {
895 LOG_DEBUGGER(ERROR) << "CallFunctionOnParams::Create " << error;
896 return nullptr;
897 }
898
899 return paramsObject;
900 }
901
Create(const PtJson & params)902 std::unique_ptr<StartSamplingParams> StartSamplingParams::Create(const PtJson ¶ms)
903 {
904 auto paramsObject = std::make_unique<StartSamplingParams>();
905 std::string error;
906 Result ret;
907
908 double samplingInterval;
909 ret = params.GetDouble("samplingInterval", &samplingInterval);
910 if (ret == Result::SUCCESS) {
911 if (samplingInterval <= 0) {
912 error += "Invalid SamplingInterval";
913 } else {
914 paramsObject->samplingInterval_ = samplingInterval;
915 }
916 } else if (ret == Result::TYPE_ERROR) {
917 error += "Wrong type of 'samplingInterval';";
918 }
919
920 if (!error.empty()) {
921 LOG_DEBUGGER(ERROR) << "StartSamplingParams::Create " << error;
922 return nullptr;
923 }
924 return paramsObject;
925 }
926
Create(const PtJson & params)927 std::unique_ptr<StartTrackingHeapObjectsParams> StartTrackingHeapObjectsParams::Create(const PtJson ¶ms)
928 {
929 auto paramsObject = std::make_unique<StartTrackingHeapObjectsParams>();
930 std::string error;
931 Result ret;
932
933 bool trackAllocations = false;
934 ret = params.GetBool("trackAllocations", &trackAllocations);
935 if (ret == Result::SUCCESS) {
936 paramsObject->trackAllocations_ = trackAllocations;
937 } else if (ret == Result::TYPE_ERROR) {
938 error += "Wrong type of 'trackAllocations';";
939 }
940
941 if (!error.empty()) {
942 LOG_DEBUGGER(ERROR) << "StartTrackingHeapObjectsParams::Create " << error;
943 return nullptr;
944 }
945 return paramsObject;
946 }
947
Create(const PtJson & params)948 std::unique_ptr<StopTrackingHeapObjectsParams> StopTrackingHeapObjectsParams::Create(const PtJson ¶ms)
949 {
950 auto paramsObject = std::make_unique<StopTrackingHeapObjectsParams>();
951 std::string error;
952 Result ret;
953
954 bool reportProgress = false;
955 ret = params.GetBool("reportProgress", &reportProgress);
956 if (ret == Result::SUCCESS) {
957 paramsObject->reportProgress_ = reportProgress;
958 } else if (ret == Result::TYPE_ERROR) {
959 error += "Wrong type of 'reportProgress';";
960 }
961
962 bool treatGlobalObjectsAsRoots = false;
963 ret = params.GetBool("treatGlobalObjectsAsRoots", &treatGlobalObjectsAsRoots);
964 if (ret == Result::SUCCESS) {
965 paramsObject->treatGlobalObjectsAsRoots_ = treatGlobalObjectsAsRoots;
966 } else if (ret == Result::TYPE_ERROR) {
967 error += "Wrong type of 'treatGlobalObjectsAsRoots';";
968 }
969
970 bool captureNumericValue = false;
971 ret = params.GetBool("captureNumericValue", &captureNumericValue);
972 if (ret == Result::SUCCESS) {
973 paramsObject->captureNumericValue_ = captureNumericValue;
974 } else if (ret == Result::TYPE_ERROR) {
975 error += "Wrong type of 'captureNumericValue';";
976 }
977
978 if (!error.empty()) {
979 LOG_DEBUGGER(ERROR) << "StopTrackingHeapObjectsParams::Create " << error;
980 return nullptr;
981 }
982 return paramsObject;
983 }
984
Create(const PtJson & params)985 std::unique_ptr<AddInspectedHeapObjectParams> AddInspectedHeapObjectParams::Create(const PtJson ¶ms)
986 {
987 auto paramsObject = std::make_unique<AddInspectedHeapObjectParams>();
988 std::string error;
989 Result ret;
990
991 std::string heapObjectId;
992 ret = params.GetString("heapObjectId", &heapObjectId);
993 if (ret == Result::SUCCESS) {
994 if (!ToolchainUtils::StrToInt32(heapObjectId, paramsObject->heapObjectId_)) {
995 error += "Failed to convert 'heapObjectId' from string to int;";
996 }
997 } else {
998 error += "Unknown or wrong type of 'heapObjectId';";
999 }
1000
1001 if (!error.empty()) {
1002 LOG_DEBUGGER(ERROR) << "AddInspectedHeapObjectParams::Create " << error;
1003 return nullptr;
1004 }
1005 return paramsObject;
1006 }
1007
Create(const PtJson & params)1008 std::unique_ptr<GetHeapObjectIdParams> GetHeapObjectIdParams::Create(const PtJson ¶ms)
1009 {
1010 auto paramsObject = std::make_unique<GetHeapObjectIdParams>();
1011 std::string error;
1012 Result ret;
1013
1014 std::string objectId;
1015 ret = params.GetString("objectId", &objectId);
1016 if (ret == Result::SUCCESS) {
1017 if (!ToolchainUtils::StrToInt32(objectId, paramsObject->objectId_)) {
1018 error += "Failed to convert 'objectId' from string to int;";
1019 }
1020 } else if (ret == Result::TYPE_ERROR) {
1021 error += "Wrong type of 'objectId';";
1022 }
1023
1024 if (!error.empty()) {
1025 LOG_DEBUGGER(ERROR) << "GetHeapObjectIdParams::Create " << error;
1026 return nullptr;
1027 }
1028 return paramsObject;
1029 }
1030
Create(const PtJson & params)1031 std::unique_ptr<GetObjectByHeapObjectIdParams> GetObjectByHeapObjectIdParams::Create(const PtJson ¶ms)
1032 {
1033 auto paramsObject = std::make_unique<GetObjectByHeapObjectIdParams>();
1034 std::string error;
1035 Result ret;
1036
1037 std::string objectId;
1038 ret = params.GetString("objectId", &objectId);
1039 if (ret == Result::SUCCESS) {
1040 if (!ToolchainUtils::StrToInt32(objectId, paramsObject->objectId_)) {
1041 error += "Failed to convert 'objectId' from string to int;";
1042 }
1043 } else if (ret == Result::TYPE_ERROR) {
1044 error += "Wrong type of 'objectId';";
1045 }
1046
1047 std::string objectGroup;
1048 ret = params.GetString("objectGroup", &objectGroup);
1049 if (ret == Result::SUCCESS) {
1050 paramsObject->objectGroup_ = std::move(objectGroup);
1051 } else if (ret == Result::TYPE_ERROR) {
1052 error += "Wrong type of 'objectGroup';";
1053 }
1054
1055 if (!error.empty()) {
1056 LOG_DEBUGGER(ERROR) << "GetObjectByHeapObjectIdParams::Create " << error;
1057 return nullptr;
1058 }
1059 return paramsObject;
1060 }
1061
Create(const PtJson & params)1062 std::unique_ptr<StartPreciseCoverageParams> StartPreciseCoverageParams::Create(const PtJson ¶ms)
1063 {
1064 auto paramsObject = std::make_unique<StartPreciseCoverageParams>();
1065 std::string error;
1066 Result ret;
1067
1068 bool callCount = false;
1069 ret = params.GetBool("callCount", &callCount);
1070 if (ret == Result::SUCCESS) {
1071 paramsObject->callCount_ = callCount;
1072 } else if (ret == Result::TYPE_ERROR) {
1073 error += "Wrong type of 'callCount';";
1074 }
1075
1076 bool detailed = false;
1077 ret = params.GetBool("detailed", &detailed);
1078 if (ret == Result::SUCCESS) {
1079 paramsObject->detailed_ = detailed;
1080 } else if (ret == Result::TYPE_ERROR) {
1081 error += "Wrong type of 'detailed';";
1082 }
1083
1084 bool allowTriggeredUpdates = false;
1085 ret = params.GetBool("allowTriggeredUpdates", &allowTriggeredUpdates);
1086 if (ret == Result::SUCCESS) {
1087 paramsObject->allowTriggeredUpdates_ = allowTriggeredUpdates;
1088 } else if (ret == Result::TYPE_ERROR) {
1089 error += "Wrong type of 'allowTriggeredUpdates';";
1090 }
1091
1092 if (!error.empty()) {
1093 LOG_DEBUGGER(ERROR) << "StartPreciseCoverageParams::Create " << error;
1094 return nullptr;
1095 }
1096 return paramsObject;
1097 }
1098
Create(const PtJson & params)1099 std::unique_ptr<SetSamplingIntervalParams> SetSamplingIntervalParams::Create(const PtJson ¶ms)
1100 {
1101 auto paramsObject = std::make_unique<SetSamplingIntervalParams>();
1102 std::string error;
1103 Result ret;
1104
1105 int32_t interval = 0;
1106 ret = params.GetInt("interval", &interval);
1107 if (ret == Result::SUCCESS) {
1108 paramsObject->interval_ = interval;
1109 } else {
1110 error += "Unknown or wrong type of 'interval';";
1111 }
1112
1113 if (!error.empty()) {
1114 LOG_DEBUGGER(ERROR) << "SetSamplingIntervalParams::Create " << error;
1115 return nullptr;
1116 }
1117 return paramsObject;
1118 }
1119
Create(const PtJson & params)1120 std::unique_ptr<RecordClockSyncMarkerParams> RecordClockSyncMarkerParams::Create(const PtJson ¶ms)
1121 {
1122 std::string error;
1123 auto recordClockSyncMarkerParams = std::make_unique<RecordClockSyncMarkerParams>();
1124 Result ret;
1125
1126 std::string syncId;
1127 ret = params.GetString("syncId", &syncId);
1128 if (ret == Result::SUCCESS) {
1129 recordClockSyncMarkerParams->syncId_ = syncId;
1130 } else {
1131 error += "Unknown or wrong type of 'syncId';";
1132 }
1133
1134 if (!error.empty()) {
1135 LOG_DEBUGGER(ERROR) << "RecordClockSyncMarkerParams::Create " << error;
1136 return nullptr;
1137 }
1138
1139 return recordClockSyncMarkerParams;
1140 }
1141
Create(const PtJson & params)1142 std::unique_ptr<RequestMemoryDumpParams> RequestMemoryDumpParams::Create(const PtJson ¶ms)
1143 {
1144 std::string error;
1145 auto requestMemoryDumpParams = std::make_unique<RequestMemoryDumpParams>();
1146 Result ret;
1147
1148 bool deterministic = false;
1149 ret = params.GetBool("deterministic", &deterministic);
1150 if (ret == Result::SUCCESS) {
1151 requestMemoryDumpParams->deterministic_ = deterministic;
1152 } else if (ret == Result::TYPE_ERROR) {
1153 error += "Wrong type of 'deterministic';";
1154 }
1155
1156 std::string levelOfDetail;
1157 ret = params.GetString("levelOfDetail", &levelOfDetail);
1158 if (ret == Result::SUCCESS) {
1159 if (MemoryDumpLevelOfDetailValues::Valid(levelOfDetail)) {
1160 requestMemoryDumpParams->levelOfDetail_ = std::move(levelOfDetail);
1161 } else {
1162 error += "'levelOfDetail' is invalid;";
1163 }
1164 } else if (ret == Result::TYPE_ERROR) {
1165 error += "Wrong type of 'levelOfDetail';";
1166 }
1167
1168 if (!error.empty()) {
1169 LOG_DEBUGGER(ERROR) << "RequestMemoryDumpParams::Create " << error;
1170 return nullptr;
1171 }
1172
1173 return requestMemoryDumpParams;
1174 }
1175
Create(const PtJson & params)1176 std::unique_ptr<StartParams> StartParams::Create(const PtJson ¶ms)
1177 {
1178 std::string error;
1179 auto startParams = std::make_unique<StartParams>();
1180 Result ret;
1181
1182 std::string categories;
1183 ret = params.GetString("categories", &categories);
1184 if (ret == Result::SUCCESS) {
1185 startParams->categories_ = std::move(categories);
1186 } else if (ret == Result::TYPE_ERROR) {
1187 error += "Wrong type of 'categories';";
1188 }
1189
1190 std::string options;
1191 ret = params.GetString("options", &options);
1192 if (ret == Result::SUCCESS) {
1193 startParams->options_ = std::move(options);
1194 } else if (ret == Result::TYPE_ERROR) {
1195 error += "Wrong type of 'options';";
1196 }
1197
1198 int32_t bufferUsageReportingInterval = 0;
1199 ret = params.GetInt("bufferUsageReportingInterval", &bufferUsageReportingInterval);
1200 if (ret == Result::SUCCESS) {
1201 startParams->bufferUsageReportingInterval_ = bufferUsageReportingInterval;
1202 } else if (ret == Result::TYPE_ERROR) {
1203 error += "Wrong type of 'bufferUsageReportingInterval';";
1204 }
1205
1206 std::string transferMode;
1207 ret = params.GetString("transferMode", &transferMode);
1208 if (ret == Result::SUCCESS) {
1209 if (StartParams::TransferModeValues::Valid(transferMode)) {
1210 startParams->transferMode_ = std::move(transferMode);
1211 } else {
1212 error += "'transferMode' is invalid;";
1213 }
1214 } else if (ret == Result::TYPE_ERROR) {
1215 error += "Wrong type of 'transferMode';";
1216 }
1217
1218 std::string streamFormat;
1219 ret = params.GetString("streamFormat", &streamFormat);
1220 if (ret == Result::SUCCESS) {
1221 if (StreamFormatValues::Valid(streamFormat)) {
1222 startParams->streamFormat_ = std::move(streamFormat);
1223 } else {
1224 error += "'streamFormat' is invalid;";
1225 }
1226 } else if (ret == Result::TYPE_ERROR) {
1227 error += "Wrong type of 'streamFormat';";
1228 }
1229
1230 std::string streamCompression;
1231 ret = params.GetString("streamCompression", &streamCompression);
1232 if (ret == Result::SUCCESS) {
1233 if (StreamCompressionValues::Valid(streamCompression)) {
1234 startParams->streamCompression_ = std::move(streamCompression);
1235 } else {
1236 error += "'streamCompression' is invalid;";
1237 }
1238 } else if (ret == Result::TYPE_ERROR) {
1239 error += "Wrong type of 'streamCompression';";
1240 }
1241
1242 std::unique_ptr<PtJson> traceConfig;
1243 ret = params.GetObject("traceConfig", &traceConfig);
1244 if (ret == Result::SUCCESS) {
1245 std::unique_ptr<TraceConfig> pTraceConfig = TraceConfig::Create(*traceConfig);
1246 if (pTraceConfig == nullptr) {
1247 error += "'traceConfig' format is invalid;";
1248 } else {
1249 startParams->traceConfig_ = std::move(pTraceConfig);
1250 }
1251 } else if (ret == Result::TYPE_ERROR) {
1252 error += "Wrong type of 'traceConfig';";
1253 }
1254
1255 std::string perfettoConfig;
1256 ret = params.GetString("perfettoConfig", &perfettoConfig);
1257 if (ret == Result::SUCCESS) {
1258 startParams->perfettoConfig_ = std::move(perfettoConfig);
1259 } else if (ret == Result::TYPE_ERROR) {
1260 error += "Wrong type of 'perfettoConfig';";
1261 }
1262
1263 std::string tracingBackend;
1264 ret = params.GetString("tracingBackend", &tracingBackend);
1265 if (ret == Result::SUCCESS) {
1266 if (TracingBackendValues::Valid(tracingBackend)) {
1267 startParams->tracingBackend_ = std::move(tracingBackend);
1268 } else {
1269 error += "'tracingBackend' is invalid;";
1270 }
1271 } else if (ret == Result::TYPE_ERROR) {
1272 error += "Wrong type of 'tracingBackend';";
1273 }
1274
1275 if (!error.empty()) {
1276 LOG_DEBUGGER(ERROR) << "StartParams::Create " << error;
1277 return nullptr;
1278 }
1279
1280 return startParams;
1281 }
1282
Create(const PtJson & params)1283 std::unique_ptr<SeriliazationTimeoutCheckEnableParams> SeriliazationTimeoutCheckEnableParams::Create
1284 (const PtJson ¶ms)
1285 {
1286 auto paramsObject = std::make_unique<SeriliazationTimeoutCheckEnableParams>();
1287 std::string error;
1288 Result ret;
1289
1290 int32_t threshold = 0;
1291 ret = params.GetInt("threshold", &threshold);
1292 if (ret == Result::SUCCESS) {
1293 paramsObject->threshold_ = threshold;
1294 } else {
1295 error += "Unknown or wrong type of 'threshold';";
1296 }
1297
1298 if (!error.empty()) {
1299 LOG_DEBUGGER(ERROR) << "SeriliazationTimeoutCheckEnableParams::Create " << error;
1300 return nullptr;
1301 }
1302 return paramsObject;
1303 }
1304 } // namespace panda::ecmascript::tooling
1305