Skip to content

Commit e843559

Browse files
committed
requests serialization
1 parent 54782ac commit e843559

File tree

8 files changed

+99
-5
lines changed

8 files changed

+99
-5
lines changed

lldb/tools/lldb-dap/Handler/RequestHandler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "Protocol/ProtocolBase.h"
1616
#include "Protocol/ProtocolRequests.h"
1717
#include "Protocol/ProtocolTypes.h"
18-
#include "lldb/API/SBError.h"
1918
#include "llvm/ADT/DenseSet.h"
2019
#include "llvm/ADT/StringRef.h"
2120
#include "llvm/Support/Error.h"

lldb/tools/lldb-dap/Handler/SetFunctionBreakpointsRequestHandler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "DAP.h"
1010
#include "EventHelper.h"
11-
#include "JSONUtils.h"
1211
#include "RequestHandler.h"
1312

1413
namespace lldb_dap {

lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "DAP.h"
1010
#include "EventHelper.h"
11-
#include "JSONUtils.h"
1211
#include "RequestHandler.h"
1312

1413
namespace lldb_dap {

lldb/tools/lldb-dap/JSONUtils.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "JSONUtils.h"
10-
#include "BreakpointBase.h"
1110
#include "DAP.h"
1211
#include "ExceptionBreakpoint.h"
1312
#include "LLDBUtils.h"

lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,88 @@ bool fromJSON(const llvm::json::Value &Params, StepOutArguments &SOA,
301301
OM.mapOptional("granularity", SOA.granularity);
302302
}
303303

304+
bool fromJSON(const llvm::json::Value &Params, SetBreakpointsArguments &SBA,
305+
llvm::json::Path P) {
306+
json::ObjectMapper O(Params, P);
307+
return O && O.map("source", SBA.source) &&
308+
O.map("breakpoints", SBA.breakpoints) && O.map("lines", SBA.lines) &&
309+
O.map("sourceModified", SBA.sourceModified);
310+
}
311+
312+
llvm::json::Value toJSON(const SetBreakpointsResponseBody &SBR) {
313+
json::Object result;
314+
result["breakpoints"] = SBR.breakpoints;
315+
return result;
316+
}
317+
318+
bool fromJSON(const llvm::json::Value &Params,
319+
SetFunctionBreakpointsArguments &SFBA, llvm::json::Path P) {
320+
json::ObjectMapper O(Params, P);
321+
return O && O.map("breakpoints", SFBA.breakpoints);
322+
}
323+
324+
llvm::json::Value toJSON(const SetFunctionBreakpointsResponseBody &SFBR) {
325+
json::Object result;
326+
result["breakpoints"] = SFBR.breakpoints;
327+
return result;
328+
}
329+
330+
bool fromJSON(const llvm::json::Value &Params,
331+
SetExceptionBreakpointsArguments &SEBA, llvm::json::Path P) {
332+
json::ObjectMapper O(Params, P);
333+
return O && O.map("filters", SEBA.filters) &&
334+
O.map("filterOptions", SEBA.filterOptions) &&
335+
O.map("exceptionOptions", SEBA.exceptionOptions);
336+
}
337+
338+
llvm::json::Value toJSON(const SetExceptionBreakpointsResponseBody &SEBR) {
339+
json::Object result;
340+
result["breakpoints"] = SEBR.breakpoints;
341+
return result;
342+
}
343+
344+
bool fromJSON(const llvm::json::Value &Params,
345+
SetInstructionBreakpointsArguments &SIBA, llvm::json::Path P) {
346+
json::ObjectMapper O(Params, P);
347+
return O && O.map("breakpoints", SIBA.breakpoints);
348+
}
349+
350+
llvm::json::Value toJSON(const SetInstructionBreakpointsResponseBody &SIBR) {
351+
json::Object result;
352+
result["breakpoints"] = SIBR.breakpoints;
353+
return result;
354+
}
355+
356+
bool fromJSON(const llvm::json::Value &Params,
357+
DataBreakpointInfoArguments &DBIA, llvm::json::Path P) {
358+
json::ObjectMapper O(Params, P);
359+
return O && O.map("variablesReference", DBIA.variablesReference) &&
360+
O.map("name", DBIA.name) && O.map("frameId", DBIA.frameId) &&
361+
O.map("bytes", DBIA.bytes) && O.map("asAddress", DBIA.asAddress) &&
362+
O.map("mode", DBIA.mode);
363+
}
364+
365+
llvm::json::Value toJSON(const DataBreakpointInfoResponseBody &DBIRB) {
366+
json::Object result;
367+
result["dataId"] = DBIRB.dataId ? *DBIRB.dataId : llvm::json::Value(nullptr);
368+
result["description"] = DBIRB.description;
369+
if (DBIRB.accessTypes)
370+
result["accessTypes"] = *DBIRB.accessTypes;
371+
if (DBIRB.canPersist)
372+
result["canPersist"] = *DBIRB.canPersist;
373+
return result;
374+
}
375+
376+
bool fromJSON(const llvm::json::Value &Params,
377+
SetDataBreakpointsArguments &SDBA, llvm::json::Path P) {
378+
json::ObjectMapper O(Params, P);
379+
return O && O.map("breakpoints", SDBA.breakpoints);
380+
}
381+
382+
llvm::json::Value toJSON(const SetDataBreakpointsResponseBody &SDBR) {
383+
json::Object result;
384+
result["breakpoints"] = SDBR.breakpoints;
385+
return result;
386+
}
387+
304388
} // namespace lldb_dap::protocol

lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,18 @@ bool fromJSON(const llvm::json::Value &Params, DataBreakpointAccessType &DBAT,
393393
return true;
394394
}
395395

396+
llvm::json::Value toJSON(const DataBreakpointAccessType &DBAT) {
397+
switch (DBAT) {
398+
case eDataBreakpointAccessTypeRead:
399+
return "read";
400+
case eDataBreakpointAccessTypeWrite:
401+
return "write";
402+
case eDataBreakpointAccessTypeReadWrite:
403+
return "readWrite";
404+
}
405+
llvm_unreachable("unhandled data breakpoint access type.");
406+
}
407+
396408
bool fromJSON(const llvm::json::Value &Params, DataBreakpointInfo &DBI,
397409
llvm::json::Path P) {
398410
json::ObjectMapper O(Params, P);

lldb/tools/lldb-dap/Protocol/ProtocolTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ enum PresentationHint : unsigned {
273273
ePresentationHintEmphasize,
274274
ePresentationHintDeemphasize,
275275
};
276-
llvm::json::Value toJSON(const PresentationHint &);
277276

278277
/// A `Source` is a descriptor for source code. It is returned from the debug
279278
/// adapter as part of a `StackFrame` and it is used by clients when specifying
@@ -453,6 +452,7 @@ enum DataBreakpointAccessType : unsigned {
453452
};
454453
bool fromJSON(const llvm::json::Value &, DataBreakpointAccessType &,
455454
llvm::json::Path);
455+
llvm::json::Value toJSON(const DataBreakpointAccessType &);
456456

457457
/// Properties of a data breakpoint passed to the `setDataBreakpoints` request.
458458
struct DataBreakpointInfo {

lldb/tools/lldb-dap/Watchpoint.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ protocol::Breakpoint Watchpoint::ToProtocolBreakpoint() {
4646
} else {
4747
breakpoint.verified = true;
4848
}
49+
50+
return breakpoint;
4951
}
5052

5153
void Watchpoint::SetWatchpoint() {

0 commit comments

Comments
 (0)