Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lldb/tools/lldb-dap/Handler/RequestHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ class RequestHandler : public BaseRequestHandler {
}

Args arguments;
llvm::json::Path::Root root;
if (request.arguments && !fromJSON(request.arguments, arguments, root)) {
llvm::json::Path::Root root("arguments");
if (request.arguments && !fromJSON(*request.arguments, arguments, root)) {
std::string parse_failure;
llvm::raw_string_ostream OS(parse_failure);
root.printErrorContext(request.arguments, OS);
OS << "invalid arguments for request '" << request.command
<< "': " << llvm::toString(root.getError()) << "\n";
root.printErrorContext(*request.arguments, OS);

protocol::ErrorMessage error_message;
error_message.format = parse_failure;
Expand Down
2 changes: 1 addition & 1 deletion lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ bool fromJSON(json::Value const &Params, Response &R, json::Path P) {
return false;
}

return O.map("success", R.success) && O.mapOptional("message", R.message) &&
return O.map("success", R.success) && O.map("message", R.message) &&
mapRaw(Params, "body", R.body, P);
}

Expand Down
42 changes: 26 additions & 16 deletions lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ namespace lldb_dap::protocol {
bool fromJSON(const llvm::json::Value &Params, CancelArguments &CA,
llvm::json::Path P) {
llvm::json::ObjectMapper O(Params, P);
return O && O.mapOptional("requestId", CA.requestId) &&
O.mapOptional("progressId", CA.progressId);
return O && O.map("requestId", CA.requestId) &&
O.map("progressId", CA.progressId);
}

bool fromJSON(const json::Value &Params, DisconnectArguments &DA,
json::Path P) {
json::ObjectMapper O(Params, P);
return O && O.mapOptional("restart", DA.restart) &&
O.mapOptional("terminateDebuggee", DA.terminateDebuggee) &&
O.mapOptional("suspendDebuggee", DA.suspendDebuggee);
return O && O.map("restart", DA.restart) &&
O.map("terminateDebuggee", DA.terminateDebuggee) &&
O.map("suspendDebuggee", DA.suspendDebuggee);
}

bool fromJSON(const llvm::json::Value &Params, PathFormat &PF,
Expand Down Expand Up @@ -75,23 +75,33 @@ bool fromJSON(const llvm::json::Value &Params, InitializeRequestArguments &IRA,

const json::Object *O = Params.getAsObject();

for (auto &kv : ClientFeatureByKey)
if (std::optional<bool> v = O->getBoolean(kv.first()); v && *v)
for (auto &kv : ClientFeatureByKey) {
const json::Value *value_ref = O->get(kv.first());
if (!value_ref)
continue;

const std::optional<bool> value = value_ref->getAsBoolean();
if (!value) {
P.field(kv.first()).report("expected bool");
return false;
}

if (*value)
IRA.supportedFeatures.insert(kv.second);
}

return OM.mapOptional("adatperID", IRA.adatperID) &&
OM.mapOptional("clientID", IRA.clientID) &&
OM.mapOptional("clientName", IRA.clientName) &&
OM.mapOptional("locale", IRA.locale) &&
OM.mapOptional("linesStartAt1", IRA.linesStartAt1) &&
OM.mapOptional("columnsStartAt1", IRA.columnsStartAt1) &&
OM.mapOptional("pathFormat", IRA.pathFormat) &&
OM.mapOptional("$__lldb_sourceInitFile", IRA.lldbExtSourceInitFile);
return OM.map("adapterID", IRA.adapterID) &&
OM.map("clientID", IRA.clientID) &&
OM.map("clientName", IRA.clientName) && OM.map("locale", IRA.locale) &&
OM.map("linesStartAt1", IRA.linesStartAt1) &&
OM.map("columnsStartAt1", IRA.columnsStartAt1) &&
OM.map("pathFormat", IRA.pathFormat) &&
OM.map("$__lldb_sourceInitFile", IRA.lldbExtSourceInitFile);
}

bool fromJSON(const json::Value &Params, SourceArguments &SA, json::Path P) {
json::ObjectMapper O(Params, P);
return O && O.mapOptional("source", SA.source) &&
return O && O.map("source", SA.source) &&
O.map("sourceReference", SA.sourceReference);
}

Expand Down
4 changes: 2 additions & 2 deletions lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ enum PathFormat : unsigned { ePatFormatPath, ePathFormatURI };
/// Arguments for `initialize` request.
struct InitializeRequestArguments {
/// The ID of the debug adapter.
std::string adatperID;
std::string adapterID;

/// The ID of the client using this adapter.
std::optional<std::string> clientID;
Expand All @@ -113,7 +113,7 @@ struct InitializeRequestArguments {

/// Determines in what format paths are specified. The default is `path`,
/// which is the native format.
std::optional<PathFormat> pathFormat = ePatFormatPath;
PathFormat pathFormat = ePatFormatPath;

/// If true all line numbers are 1-based (default).
std::optional<bool> linesStartAt1;
Expand Down
6 changes: 3 additions & 3 deletions lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ bool fromJSON(const json::Value &Params, PresentationHint &PH, json::Path P) {

bool fromJSON(const json::Value &Params, Source &S, json::Path P) {
json::ObjectMapper O(Params, P);
return O && O.mapOptional("name", S.name) && O.mapOptional("path", S.path) &&
O.mapOptional("presentationHint", S.presentationHint) &&
O.mapOptional("sourceReference", S.sourceReference);
return O && O.map("name", S.name) && O.map("path", S.path) &&
O.map("presentationHint", S.presentationHint) &&
O.map("sourceReference", S.sourceReference);
}

json::Value toJSON(const ExceptionBreakpointsFilter &EBF) {
Expand Down
Loading