@@ -165,6 +165,32 @@ json::Value toJSON(const ChecksumAlgorithm &CA) {
165
165
llvm_unreachable (" unhandled checksum algorithm." );
166
166
}
167
167
168
+ bool fromJSON (const llvm::json::Value &Params, ChecksumAlgorithm &CA,
169
+ llvm::json::Path P) {
170
+ auto rawAlgorithm = Params.getAsString ();
171
+ if (!rawAlgorithm) {
172
+ P.report (" expected a string" );
173
+ return false ;
174
+ }
175
+
176
+ std::optional<ChecksumAlgorithm> algorithm =
177
+ llvm::StringSwitch<std::optional<ChecksumAlgorithm>>(*rawAlgorithm)
178
+ .Case (" MD5" , eChecksumAlgorithmMD5)
179
+ .Case (" SHA1" , eChecksumAlgorithmSHA1)
180
+ .Case (" SHA256" , eChecksumAlgorithmSHA256)
181
+ .Case (" timestamp" , eChecksumAlgorithmTimestamp)
182
+ .Default (std::nullopt);
183
+
184
+ if (!algorithm) {
185
+ P.report (
186
+ " unexpected value, expected 'MD5', 'SHA1', 'SHA256', or 'timestamp'" );
187
+ return false ;
188
+ }
189
+
190
+ CA = *algorithm;
191
+ return true ;
192
+ }
193
+
168
194
json::Value toJSON (const BreakpointModeApplicability &BMA) {
169
195
switch (BMA) {
170
196
case eBreakpointModeApplicabilitySource:
@@ -304,6 +330,84 @@ static llvm::StringLiteral ToString(AdapterFeature feature) {
304
330
llvm_unreachable (" unhandled adapter feature." );
305
331
}
306
332
333
+ llvm::json::Value toJSON (const AdapterFeature &feature) {
334
+ return ToString (feature);
335
+ }
336
+
337
+ bool fromJSON (const llvm::json::Value &Params, AdapterFeature &feature,
338
+ llvm::json::Path P) {
339
+ auto rawFeature = Params.getAsString ();
340
+ if (!rawFeature) {
341
+ P.report (" expected a string" );
342
+ return false ;
343
+ }
344
+
345
+ std::optional<AdapterFeature> parsedFeature =
346
+ llvm::StringSwitch<std::optional<AdapterFeature>>(*rawFeature)
347
+ .Case (" supportsANSIStyling" , eAdapterFeatureANSIStyling)
348
+ .Case (" supportsBreakpointLocationsRequest" ,
349
+ eAdapterFeatureBreakpointLocationsRequest)
350
+ .Case (" supportsCancelRequest" , eAdapterFeatureCancelRequest)
351
+ .Case (" supportsClipboardContext" , eAdapterFeatureClipboardContext)
352
+ .Case (" supportsCompletionsRequest" , eAdapterFeatureCompletionsRequest)
353
+ .Case (" supportsConditionalBreakpoints" ,
354
+ eAdapterFeatureConditionalBreakpoints)
355
+ .Case (" supportsConfigurationDoneRequest" ,
356
+ eAdapterFeatureConfigurationDoneRequest)
357
+ .Case (" supportsDataBreakpointBytes" ,
358
+ eAdapterFeatureDataBreakpointBytes)
359
+ .Case (" supportsDataBreakpoints" , eAdapterFeatureDataBreakpoints)
360
+ .Case (" supportsDelayedStackTraceLoading" ,
361
+ eAdapterFeatureDelayedStackTraceLoading)
362
+ .Case (" supportsDisassembleRequest" , eAdapterFeatureDisassembleRequest)
363
+ .Case (" supportsEvaluateForHovers" , eAdapterFeatureEvaluateForHovers)
364
+ .Case (" supportsExceptionFilterOptions" ,
365
+ eAdapterFeatureExceptionFilterOptions)
366
+ .Case (" supportsExceptionInfoRequest" ,
367
+ eAdapterFeatureExceptionInfoRequest)
368
+ .Case (" supportsExceptionOptions" , eAdapterFeatureExceptionOptions)
369
+ .Case (" supportsFunctionBreakpoints" ,
370
+ eAdapterFeatureFunctionBreakpoints)
371
+ .Case (" supportsGotoTargetsRequest" , eAdapterFeatureGotoTargetsRequest)
372
+ .Case (" supportsHitConditionalBreakpoints" ,
373
+ eAdapterFeatureHitConditionalBreakpoints)
374
+ .Case (" supportsInstructionBreakpoints" ,
375
+ eAdapterFeatureInstructionBreakpoints)
376
+ .Case (" supportsLoadedSourcesRequest" ,
377
+ eAdapterFeatureLoadedSourcesRequest)
378
+ .Case (" supportsLogPoints" , eAdapterFeatureLogPoints)
379
+ .Case (" supportsModulesRequest" , eAdapterFeatureModulesRequest)
380
+ .Case (" supportsReadMemoryRequest" , eAdapterFeatureReadMemoryRequest)
381
+ .Case (" supportsRestartFrame" , eAdapterFeatureRestartFrame)
382
+ .Case (" supportsRestartRequest" , eAdapterFeatureRestartRequest)
383
+ .Case (" supportsSetExpression" , eAdapterFeatureSetExpression)
384
+ .Case (" supportsSetVariable" , eAdapterFeatureSetVariable)
385
+ .Case (" supportsSingleThreadExecutionRequests" ,
386
+ eAdapterFeatureSingleThreadExecutionRequests)
387
+ .Case (" supportsStepBack" , eAdapterFeatureStepBack)
388
+ .Case (" supportsStepInTargetsRequest" ,
389
+ eAdapterFeatureStepInTargetsRequest)
390
+ .Case (" supportsSteppingGranularity" ,
391
+ eAdapterFeatureSteppingGranularity)
392
+ .Case (" supportsTerminateRequest" , eAdapterFeatureTerminateRequest)
393
+ .Case (" supportsTerminateThreadsRequest" ,
394
+ eAdapterFeatureTerminateThreadsRequest)
395
+ .Case (" supportSuspendDebuggee" , eAdapterFeatureSuspendDebuggee)
396
+ .Case (" supportsValueFormattingOptions" ,
397
+ eAdapterFeatureValueFormattingOptions)
398
+ .Case (" supportsWriteMemoryRequest" , eAdapterFeatureWriteMemoryRequest)
399
+ .Case (" supportTerminateDebuggee" , eAdapterFeatureTerminateDebuggee)
400
+ .Default (std::nullopt);
401
+
402
+ if (!parsedFeature) {
403
+ P.report (" unexpected value for AdapterFeature" );
404
+ return false ;
405
+ }
406
+
407
+ feature = *parsedFeature;
408
+ return true ;
409
+ }
410
+
307
411
json::Value toJSON (const Capabilities &C) {
308
412
json::Object result;
309
413
@@ -331,6 +435,32 @@ json::Value toJSON(const Capabilities &C) {
331
435
return result;
332
436
}
333
437
438
+ bool fromJSON (const llvm::json::Value &Params, Capabilities &C,
439
+ llvm::json::Path P) {
440
+ auto *Object = Params.getAsObject ();
441
+ if (!Object) {
442
+ P.report (" expected an object" );
443
+ return false ;
444
+ }
445
+ // Check for the presence of supported features.
446
+ for (unsigned i = eAdapterFeatureFirst; i <= eAdapterFeatureLast; ++i) {
447
+ AdapterFeature feature = static_cast <AdapterFeature>(i);
448
+ if (Object->getBoolean (ToString (feature)))
449
+ C.supportedFeatures .insert (feature);
450
+ }
451
+ llvm::json::ObjectMapper O (Params, P);
452
+ return O &&
453
+ O.mapOptional (" exceptionBreakpointFilters" ,
454
+ C.exceptionBreakpointFilters ) &&
455
+ O.mapOptional (" completionTriggerCharacters" ,
456
+ C.completionTriggerCharacters ) &&
457
+ O.mapOptional (" additionalModuleColumns" , C.additionalModuleColumns ) &&
458
+ O.mapOptional (" supportedChecksumAlgorithms" ,
459
+ C.supportedChecksumAlgorithms ) &&
460
+ O.mapOptional (" breakpointModes" , C.breakpointModes ) &&
461
+ O.mapOptional (" $__lldb_version" , C.lldbExtVersion );
462
+ }
463
+
334
464
bool fromJSON (const llvm::json::Value &Params, SteppingGranularity &SG,
335
465
llvm::json::Path P) {
336
466
auto raw_granularity = Params.getAsString ();
0 commit comments