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
2 changes: 1 addition & 1 deletion lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ llvm::Expected<InitializeResponse> InitializeRequestHandler::Run(
const InitializeRequestArguments &arguments) const {
// Store initialization arguments for later use in Launch/Attach.
dap.clientFeatures = arguments.supportedFeatures;
dap.sourceInitFile = arguments.lldbExtSourceInitFile.value_or(true);
dap.sourceInitFile = arguments.lldbExtSourceInitFile;

return dap.GetCapabilities();
}
11 changes: 6 additions & 5 deletions lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,13 @@ bool fromJSON(const json::Value &Params, InitializeRequestArguments &IRA,
}

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.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.map("$__lldb_sourceInitFile", IRA.lldbExtSourceInitFile);
OM.mapOptional("$__lldb_sourceInitFile", IRA.lldbExtSourceInitFile);
}

bool fromJSON(const json::Value &Params, Configuration &C, json::Path P) {
Expand Down
12 changes: 6 additions & 6 deletions lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,23 @@ struct InitializeRequestArguments {
std::string adapterID;

/// The ID of the client using this adapter.
std::optional<std::string> clientID;
std::string clientID;

/// The human-readable name of the client using this adapter.
std::optional<std::string> clientName;
std::string clientName;

/// The ISO-639 locale of the client using this adapter, e.g. en-US or de-CH.
std::optional<std::string> locale;
std::string locale;

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

/// If true all line numbers are 1-based (default).
std::optional<bool> linesStartAt1;
bool linesStartAt1 = true;

/// If true all column numbers are 1-based (default).
std::optional<bool> columnsStartAt1;
bool columnsStartAt1 = true;

/// The set of supported features reported by the client.
llvm::DenseSet<ClientFeature> supportedFeatures;
Expand All @@ -133,7 +133,7 @@ struct InitializeRequestArguments {
/// @{

/// Source init files when initializing lldb::SBDebugger.
std::optional<bool> lldbExtSourceInitFile;
bool lldbExtSourceInitFile = true;

/// @}
};
Expand Down
66 changes: 65 additions & 1 deletion lldb/unittests/DAP/ProtocolRequestsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ TEST(ProtocolRequestsTest, EvaluateArguments) {
EXPECT_EQ(expected->expression, "hello world");
EXPECT_EQ(expected->context, eEvaluateContextRepl);

// Check required keys;
// Check required keys.
EXPECT_THAT_EXPECTED(parse<EvaluateArguments>(R"({})"),
FailedWithMessage("missing value at (root).expression"));
}
Expand Down Expand Up @@ -118,3 +118,67 @@ TEST(ProtocolRequestsTest, EvaluateResponseBody) {
ASSERT_THAT_EXPECTED(expected_opt, llvm::Succeeded());
EXPECT_EQ(PrettyPrint(*expected_opt), PrettyPrint(body));
}

TEST(ProtocolRequestsTest, InitializeRequestArguments) {
llvm::Expected<InitializeRequestArguments> expected =
parse<InitializeRequestArguments>(R"({"adapterID": "myid"})");
ASSERT_THAT_EXPECTED(expected, llvm::Succeeded());
EXPECT_EQ(expected->adapterID, "myid");

// Check optional keys.
expected = parse<InitializeRequestArguments>(R"({
"adapterID": "myid",
"clientID": "myclientid",
"clientName": "lldb-dap-unit-tests",
"locale": "en-US",
"linesStartAt1": true,
"columnsStartAt1": true,
"pathFormat": "uri",
"supportsVariableType": true,
"supportsVariablePaging": true,
"supportsRunInTerminalRequest": true,
"supportsMemoryReferences": true,
"supportsProgressReporting": true,
"supportsInvalidatedEvent": true,
"supportsMemoryEvent": true,
"supportsArgsCanBeInterpretedByShell": true,
"supportsStartDebuggingRequest": true,
"supportsANSIStyling": true
})");
ASSERT_THAT_EXPECTED(expected, llvm::Succeeded());
EXPECT_EQ(expected->adapterID, "myid");
EXPECT_EQ(expected->clientID, "myclientid");
EXPECT_EQ(expected->clientName, "lldb-dap-unit-tests");
EXPECT_EQ(expected->locale, "en-US");
EXPECT_EQ(expected->linesStartAt1, true);
EXPECT_EQ(expected->columnsStartAt1, true);
EXPECT_EQ(expected->pathFormat, ePathFormatURI);
EXPECT_EQ(expected->supportedFeatures.contains(eClientFeatureVariableType),
true);
EXPECT_EQ(
expected->supportedFeatures.contains(eClientFeatureRunInTerminalRequest),
true);
EXPECT_EQ(
expected->supportedFeatures.contains(eClientFeatureMemoryReferences),
true);
EXPECT_EQ(
expected->supportedFeatures.contains(eClientFeatureProgressReporting),
true);
EXPECT_EQ(
expected->supportedFeatures.contains(eClientFeatureInvalidatedEvent),
true);
EXPECT_EQ(expected->supportedFeatures.contains(eClientFeatureMemoryEvent),
true);
EXPECT_EQ(expected->supportedFeatures.contains(
eClientFeatureArgsCanBeInterpretedByShell),
true);
EXPECT_EQ(
expected->supportedFeatures.contains(eClientFeatureStartDebuggingRequest),
true);
EXPECT_EQ(expected->supportedFeatures.contains(eClientFeatureANSIStyling),
true);

// Check required keys.
EXPECT_THAT_EXPECTED(parse<InitializeRequestArguments>(R"({})"),
FailedWithMessage("missing value at (root).adapterID"));
}
Loading