1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
//===-- ProtocolEvents.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "Protocol/ProtocolEvents.h"
#include "JSONUtils.h"
#include "llvm/Support/JSON.h"
using namespace llvm;
namespace lldb_dap::protocol {
json::Value toJSON(const CapabilitiesEventBody &CEB) {
return json::Object{{"capabilities", CEB.capabilities}};
}
json::Value toJSON(const ModuleEventBody::Reason &MEBR) {
switch (MEBR) {
case ModuleEventBody::eReasonNew:
return "new";
case ModuleEventBody::eReasonChanged:
return "changed";
case ModuleEventBody::eReasonRemoved:
return "removed";
}
llvm_unreachable("unhandled module event reason!.");
}
json::Value toJSON(const ModuleEventBody &MEB) {
return json::Object{{"reason", MEB.reason}, {"module", MEB.module}};
}
llvm::json::Value toJSON(const InvalidatedEventBody::Area &IEBA) {
switch (IEBA) {
case InvalidatedEventBody::eAreaAll:
return "all";
case InvalidatedEventBody::eAreaStacks:
return "stacks";
case InvalidatedEventBody::eAreaThreads:
return "threads";
case InvalidatedEventBody::eAreaVariables:
return "variables";
}
llvm_unreachable("unhandled invalidated event area!.");
}
llvm::json::Value toJSON(const InvalidatedEventBody &IEB) {
json::Object Result{{"areas", IEB.areas}};
if (IEB.threadId)
Result.insert({"threadID", IEB.threadId});
if (IEB.stackFrameId)
Result.insert({"stackFrameId", IEB.stackFrameId});
return Result;
}
llvm::json::Value toJSON(const MemoryEventBody &MEB) {
return json::Object{
{"memoryReference", EncodeMemoryReference(MEB.memoryReference)},
{"offset", MEB.offset},
{"count", MEB.count}};
}
} // namespace lldb_dap::protocol
|