Skip to content

Commit 3aea6b6

Browse files
committed
Sending extra capabilities event together
1 parent f0fc40c commit 3aea6b6

File tree

6 files changed

+28
-27
lines changed

6 files changed

+28
-27
lines changed

lldb/include/lldb/API/SBSymbol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class LLDB_API SBSymbol {
8585

8686
SymbolType GetType();
8787

88-
/// Get the ID of this symbol, usually the original symbol table index. .
88+
/// Get the ID of this symbol, usually the original symbol table index.
8989
///
9090
/// \returns
9191
/// Returns the ID of this symbol.

lldb/test/API/tools/lldb-dap/moduleSymbols/TestDAP_moduleSymbols.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class TestDAP_moduleSymbols(lldbdap_testcase.DAPTestCaseBase):
99
def test_moduleSymbols(self):
1010
"""
11-
Test that the stack frame without a module still has assembly source.
11+
Test that the moduleSymbols request returns correct symbols from the module.
1212
"""
1313
program = self.getBuildArtifact("a.out")
1414
self.build_and_launch(program)

lldb/tools/lldb-dap/EventHelper.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,37 @@ static void SendThreadExitedEvent(DAP &dap, lldb::tid_t tid) {
3838
dap.SendJSON(llvm::json::Value(std::move(event)));
3939
}
4040

41-
void SendTargetBasedCapabilities(DAP &dap) {
41+
/// Get capabilities based on the configured target.
42+
static llvm::DenseSet<AdapterFeature> GetTargetBasedCapabilities(DAP &dap) {
43+
llvm::DenseSet<AdapterFeature> capabilities;
4244
if (!dap.target.IsValid())
43-
return;
44-
45-
protocol::CapabilitiesEventBody body;
45+
return capabilities;
4646

4747
const llvm::StringRef target_triple = dap.target.GetTriple();
4848
if (target_triple.starts_with("x86"))
49-
body.capabilities.supportedFeatures.insert(
50-
protocol::eAdapterFeatureStepInTargetsRequest);
49+
capabilities.insert(protocol::eAdapterFeatureStepInTargetsRequest);
5150

5251
// We only support restarting launch requests not attach requests.
5352
if (dap.last_launch_request)
54-
body.capabilities.supportedFeatures.insert(
55-
protocol::eAdapterFeatureRestartRequest);
53+
capabilities.insert(protocol::eAdapterFeatureRestartRequest);
5654

57-
// Only notify the client if supportedFeatures changed.
58-
if (!body.capabilities.supportedFeatures.empty())
59-
dap.Send(protocol::Event{"capabilities", body});
55+
return capabilities;
6056
}
6157

62-
void SendCustomCapabilities(DAP &dap) {
58+
void SendExtraCapabilities(DAP &dap) {
59+
protocol::Capabilities capabilities = dap.GetCustomCapabilities();
60+
llvm::DenseSet<AdapterFeature> target_capabilities =
61+
GetTargetBasedCapabilities(dap);
62+
63+
capabilities.supportedFeatures.insert(target_capabilities.begin(),
64+
target_capabilities.end());
65+
6366
protocol::CapabilitiesEventBody body;
64-
body.capabilities = dap.GetCustomCapabilities();
67+
body.capabilities = std::move(capabilities);
6568

66-
// Notify the client about the custom capabilities.
67-
dap.Send(protocol::Event{"capabilities", body});
69+
// Only notify the client if supportedFeatures changed.
70+
if (!body.capabilities.supportedFeatures.empty())
71+
dap.Send(protocol::Event{"capabilities", std::move(body)});
6872
}
6973

7074
// "ProcessEvent": {

lldb/tools/lldb-dap/EventHelper.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@ struct DAP;
1717

1818
enum LaunchMethod { Launch, Attach, AttachForSuspendedLaunch };
1919

20-
/// Update capabilities based on the configured target.
21-
void SendTargetBasedCapabilities(DAP &dap);
22-
23-
/// Send lldb-dap custom capabilities.
24-
void SendCustomCapabilities(DAP &dap);
20+
/// Sends target based capabilities and lldb-dap custom capabilities.
21+
void SendExtraCapabilities(DAP &dap);
2522

2623
void SendProcessEvent(DAP &dap, LaunchMethod launch_method);
2724

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "DAP.h"
1010
#include "EventHelper.h"
1111
#include "LLDBUtils.h"
12+
#include "Protocol/ProtocolEvents.h"
1213
#include "Protocol/ProtocolRequests.h"
1314
#include "ProtocolUtils.h"
1415
#include "RequestHandler.h"
@@ -44,11 +45,10 @@ ConfigurationDoneRequestHandler::Run(const ConfigurationDoneArguments &) const {
4445
// Waiting until 'configurationDone' to send target based capabilities in case
4546
// the launch or attach scripts adjust the target. The initial dummy target
4647
// may have different capabilities than the final target.
47-
SendTargetBasedCapabilities(dap);
4848

49-
/// Send custom capabilities to the client.
50-
/// This is consumed by the lldb-dap specific editor extension.
51-
SendCustomCapabilities(dap);
49+
/// Also send here custom capabilities to the client, which is consumed by the
50+
/// lldb-dap specific editor extension.
51+
SendExtraCapabilities(dap);
5252

5353
// Clients can request a baseline of currently existing threads after
5454
// we acknowledge the configurationDone request.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- ModuleSymbolsRequestHandler.cpp -----------------------------===//
1+
//===----------------------------------------------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

0 commit comments

Comments
 (0)