https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/142439
>From 69efc48d722d18600018f25db0f9ea46b9fd1d97 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike <yerimy...@gmail.com> Date: Wed, 28 May 2025 14:02:01 +0100 Subject: [PATCH 1/3] [lldb-dap] Use structured types for stepInTargets request --- lldb/tools/lldb-dap/Handler/RequestHandler.h | 16 +- .../Handler/StepInTargetsRequestHandler.cpp | 200 +++++++----------- .../lldb-dap/Protocol/ProtocolRequests.cpp | 9 + .../lldb-dap/Protocol/ProtocolRequests.h | 15 ++ .../tools/lldb-dap/Protocol/ProtocolTypes.cpp | 27 +++ lldb/tools/lldb-dap/Protocol/ProtocolTypes.h | 29 +++ lldb/unittests/DAP/ProtocolTypesTest.cpp | 20 ++ 7 files changed, 186 insertions(+), 130 deletions(-) diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h b/lldb/tools/lldb-dap/Handler/RequestHandler.h index 3a965bcc87a5e..559929ffb21e8 100644 --- a/lldb/tools/lldb-dap/Handler/RequestHandler.h +++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h @@ -356,7 +356,21 @@ class StepInRequestHandler : public RequestHandler<protocol::StepInArguments, llvm::Error Run(const protocol::StepInArguments &args) const override; }; -class StepInTargetsRequestHandler : public LegacyRequestHandler { +class StepInTargetsRequestHandler + : public RequestHandler< + protocol::StepInTargetsArguments, + llvm::Expected<protocol::StepInTargetsResponseBody>> { +public: + using RequestHandler::RequestHandler; + static llvm::StringLiteral GetCommand() { return "stepInTargets"; } + FeatureSet GetSupportedFeatures() const override { + return {protocol::eAdapterFeatureStepInTargetsRequest}; + } + llvm::Expected<protocol::StepInTargetsResponseBody> + Run(const protocol::StepInTargetsArguments &args) const override; +}; + +class StepInTargetsRequestHandler2 : public LegacyRequestHandler { public: using LegacyRequestHandler::LegacyRequestHandler; static llvm::StringLiteral GetCommand() { return "stepInTargets"; } diff --git a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp index 9b99791599f82..1a76371be2d58 100644 --- a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp @@ -7,143 +7,85 @@ //===----------------------------------------------------------------------===// #include "DAP.h" -#include "EventHelper.h" -#include "JSONUtils.h" +#include "Protocol/ProtocolRequests.h" #include "RequestHandler.h" #include "lldb/API/SBInstruction.h" +#include "lldb/lldb-defines.h" +using namespace lldb_dap::protocol; namespace lldb_dap { -// "StepInTargetsRequest": { -// "allOf": [ { "$ref": "#/definitions/Request" }, { -// "type": "object", -// "description": "This request retrieves the possible step-in targets for -// the specified stack frame.\nThese targets can be used in the `stepIn` -// request.\nClients should only call this request if the corresponding -// capability `supportsStepInTargetsRequest` is true.", "properties": { -// "command": { -// "type": "string", -// "enum": [ "stepInTargets" ] -// }, -// "arguments": { -// "$ref": "#/definitions/StepInTargetsArguments" -// } -// }, -// "required": [ "command", "arguments" ] -// }] -// }, -// "StepInTargetsArguments": { -// "type": "object", -// "description": "Arguments for `stepInTargets` request.", -// "properties": { -// "frameId": { -// "type": "integer", -// "description": "The stack frame for which to retrieve the possible -// step-in targets." -// } -// }, -// "required": [ "frameId" ] -// }, -// "StepInTargetsResponse": { -// "allOf": [ { "$ref": "#/definitions/Response" }, { -// "type": "object", -// "description": "Response to `stepInTargets` request.", -// "properties": { -// "body": { -// "type": "object", -// "properties": { -// "targets": { -// "type": "array", -// "items": { -// "$ref": "#/definitions/StepInTarget" -// }, -// "description": "The possible step-in targets of the specified -// source location." -// } -// }, -// "required": [ "targets" ] -// } -// }, -// "required": [ "body" ] -// }] -// } -void StepInTargetsRequestHandler::operator()( - const llvm::json::Object &request) const { - llvm::json::Object response; - FillResponse(request, response); - const auto *arguments = request.getObject("arguments"); - +// This request retrieves the possible step-in targets for the specified stack +// frame. +// These targets can be used in the `stepIn` request. +// Clients should only call this request if the corresponding capability +// `supportsStepInTargetsRequest` is true. +llvm::Expected<StepInTargetsResponseBody> +StepInTargetsRequestHandler::Run(const StepInTargetsArguments &args) const { dap.step_in_targets.clear(); - lldb::SBFrame frame = dap.GetLLDBFrame(*arguments); - if (frame.IsValid()) { - lldb::SBAddress pc_addr = frame.GetPCAddress(); - lldb::SBAddress line_end_addr = - pc_addr.GetLineEntry().GetSameLineContiguousAddressRangeEnd(true); - lldb::SBInstructionList insts = dap.target.ReadInstructions( - pc_addr, line_end_addr, /*flavor_string=*/nullptr); - - if (!insts.IsValid()) { - response["success"] = false; - response["message"] = "Failed to get instructions for frame."; - dap.SendJSON(llvm::json::Value(std::move(response))); - return; - } + const lldb::SBFrame frame = dap.GetLLDBFrame(args.frameId); + if (!frame.IsValid()) + return llvm::make_error<DAPError>("Failed to get frame for input frameId."); + + lldb::SBAddress pc_addr = frame.GetPCAddress(); + lldb::SBAddress line_end_addr = + pc_addr.GetLineEntry().GetSameLineContiguousAddressRangeEnd(true); + lldb::SBInstructionList insts = dap.target.ReadInstructions( + pc_addr, line_end_addr, /*flavor_string=*/nullptr); + + if (!insts.IsValid()) + return llvm::make_error<DAPError>("Failed to get instructions for frame."); + + StepInTargetsResponseBody body; + const size_t num_insts = insts.GetSize(); + for (size_t i = 0; i < num_insts; ++i) { + lldb::SBInstruction inst = insts.GetInstructionAtIndex(i); + if (!inst.IsValid()) + break; + + const lldb::addr_t inst_addr = inst.GetAddress().GetLoadAddress(dap.target); + if (inst_addr == LLDB_INVALID_ADDRESS) + break; + + // Note: currently only x86/x64 supports flow kind. + const lldb::InstructionControlFlowKind flow_kind = + inst.GetControlFlowKind(dap.target); + + if (flow_kind == lldb::eInstructionControlFlowKindCall) { + + const llvm::StringRef call_operand_name = inst.GetOperands(dap.target); + lldb::addr_t call_target_addr = LLDB_INVALID_ADDRESS; + if (call_operand_name.getAsInteger(0, call_target_addr)) + continue; + + const lldb::SBAddress call_target_load_addr = + dap.target.ResolveLoadAddress(call_target_addr); + if (!call_target_load_addr.IsValid()) + continue; + + // The existing ThreadPlanStepInRange only accept step in target + // function with debug info. + lldb::SBSymbolContext sc = dap.target.ResolveSymbolContextForAddress( + call_target_load_addr, lldb::eSymbolContextFunction); + + // The existing ThreadPlanStepInRange only accept step in target + // function with debug info. + llvm::StringRef step_in_target_name; + if (sc.IsValid() && sc.GetFunction().IsValid()) + step_in_target_name = sc.GetFunction().GetDisplayName(); + + // Skip call sites if we fail to resolve its symbol name. + if (step_in_target_name.empty()) + continue; - llvm::json::Array step_in_targets; - const auto num_insts = insts.GetSize(); - for (size_t i = 0; i < num_insts; ++i) { - lldb::SBInstruction inst = insts.GetInstructionAtIndex(i); - if (!inst.IsValid()) - break; - - lldb::addr_t inst_addr = inst.GetAddress().GetLoadAddress(dap.target); - - // Note: currently only x86/x64 supports flow kind. - lldb::InstructionControlFlowKind flow_kind = - inst.GetControlFlowKind(dap.target); - if (flow_kind == lldb::eInstructionControlFlowKindCall) { - // Use call site instruction address as id which is easy to debug. - llvm::json::Object step_in_target; - step_in_target["id"] = inst_addr; - - llvm::StringRef call_operand_name = inst.GetOperands(dap.target); - lldb::addr_t call_target_addr; - if (call_operand_name.getAsInteger(0, call_target_addr)) - continue; - - lldb::SBAddress call_target_load_addr = - dap.target.ResolveLoadAddress(call_target_addr); - if (!call_target_load_addr.IsValid()) - continue; - - // The existing ThreadPlanStepInRange only accept step in target - // function with debug info. - lldb::SBSymbolContext sc = dap.target.ResolveSymbolContextForAddress( - call_target_load_addr, lldb::eSymbolContextFunction); - - // The existing ThreadPlanStepInRange only accept step in target - // function with debug info. - std::string step_in_target_name; - if (sc.IsValid() && sc.GetFunction().IsValid()) - step_in_target_name = sc.GetFunction().GetDisplayName(); - - // Skip call sites if we fail to resolve its symbol name. - if (step_in_target_name.empty()) - continue; - - dap.step_in_targets.try_emplace(inst_addr, step_in_target_name); - step_in_target.try_emplace("label", step_in_target_name); - step_in_targets.emplace_back(std::move(step_in_target)); - } + StepInTarget target; + target.id = inst_addr; + target.label = step_in_target_name; + dap.step_in_targets.try_emplace(inst_addr, step_in_target_name); + body.targets.emplace_back(std::move(target)); } - llvm::json::Object body; - body.try_emplace("targets", std::move(step_in_targets)); - response.try_emplace("body", std::move(body)); - } else { - response["success"] = llvm::json::Value(false); - response["message"] = "Failed to get frame for input frameId."; } - dap.SendJSON(llvm::json::Value(std::move(response))); -} + return body; +}; } // namespace lldb_dap diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp index 4160077d419e1..a7f28fb566d3d 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp +++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp @@ -382,6 +382,15 @@ bool fromJSON(const llvm::json::Value &Params, StepInArguments &SIA, OM.mapOptional("granularity", SIA.granularity); } +bool fromJSON(const llvm::json::Value &Params, StepInTargetsArguments &SITA, + llvm::json::Path P) { + json::ObjectMapper OM(Params, P); + return OM && OM.map("frameId", SITA.frameId); +} +llvm::json::Value toJSON(const StepInTargetsResponseBody &SITR) { + return llvm::json::Object{{"targets", SITR.targets}}; +} + bool fromJSON(const llvm::json::Value &Params, StepOutArguments &SOA, llvm::json::Path P) { json::ObjectMapper OM(Params, P); diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h index 7c774e50d6e56..570a0b6d39682 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h +++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h @@ -523,6 +523,21 @@ bool fromJSON(const llvm::json::Value &, StepInArguments &, llvm::json::Path); /// body field is required. using StepInResponse = VoidResponse; +/// Arguments for `stepInTargets` request. +struct StepInTargetsArguments { + /// The stack frame for which to retrieve the possible step-in targets. + uint64_t frameId = LLDB_INVALID_FRAME_ID; +}; +bool fromJSON(const llvm::json::Value &, StepInTargetsArguments &, + llvm::json::Path); + +/// Response to `stepInTargets` request. +struct StepInTargetsResponseBody { + /// The possible step-in targets of the specified source location. + std::vector<StepInTarget> targets; +}; +llvm::json::Value toJSON(const StepInTargetsResponseBody &); + /// Arguments for `stepOut` request. struct StepOutArguments { /// Specifies the thread for which to resume execution for one step-out (of diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp index 3b297a0bd431f..440613b201c42 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp +++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp @@ -582,6 +582,33 @@ llvm::json::Value toJSON(const SteppingGranularity &SG) { llvm_unreachable("unhandled stepping granularity."); } +bool fromJSON(const llvm::json::Value &Params, StepInTarget &SIT, + llvm::json::Path P) { + json::ObjectMapper O(Params, P); + return O && O.map("id", SIT.id) && O.map("label", SIT.label) && + O.mapOptional("line", SIT.line) && + O.mapOptional("column", SIT.column) && + O.mapOptional("endLine", SIT.endLine) && + O.mapOptional("endColumn", SIT.endColumn); +} + +llvm::json::Value toJSON(const StepInTarget &SIT) { + json::Object target; + + target.insert({"id", SIT.id}); + target.insert({"label", SIT.label}); + if (SIT.line) + target.insert({"line", SIT.line}); + if (SIT.column) + target.insert({"column", SIT.column}); + if (SIT.endLine) + target.insert({"endLine", SIT.endLine}); + if (SIT.endColumn) + target.insert({"endColumn", SIT.endColumn}); + + return target; +} + bool fromJSON(const llvm::json::Value &Params, ValueFormat &VF, llvm::json::Path P) { json::ObjectMapper O(Params, P); diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h index f5e21c96fe17f..edaca049a6ffa 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h +++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h @@ -24,6 +24,7 @@ #include "llvm/ADT/DenseSet.h" #include "llvm/Support/JSON.h" #include <cstdint> +#include <limits> #include <optional> #include <string> @@ -414,6 +415,34 @@ bool fromJSON(const llvm::json::Value &, SteppingGranularity &, llvm::json::Path); llvm::json::Value toJSON(const SteppingGranularity &); +/// A `StepInTarget` can be used in the `stepIn` request and determines into +/// which single target the `stepIn` request should step. +struct StepInTarget { + /// Unique identifier for a step-in target. + uint64_t id = std::numeric_limits<uint64_t>::max(); + + /// The name of the step-in target (shown in the UI). + std::string label; + + /// The line of the step-in target. + std::optional<uint64_t> line; + + /// Start position of the range covered by the step in target. It is measured + /// in UTF-16 code units and the client capability `columnsStartAt1` + /// determines whether it is 0- or 1-based. + std::optional<uint64_t> column; + + /// The end line of the range covered by the step-in target. + std::optional<uint64_t> endLine; + + /// End position of the range covered by the step in target. It is measured in + /// UTF-16 code units and the client capability `columnsStartAt1` determines + /// whether it is 0- or 1-based. + std::optional<uint64_t> endColumn; +}; +bool fromJSON(const llvm::json::Value &, StepInTarget &, llvm::json::Path); +llvm::json::Value toJSON(const StepInTarget &); + /// Provides formatting information for a value. struct ValueFormat { /// Display the value in hex. diff --git a/lldb/unittests/DAP/ProtocolTypesTest.cpp b/lldb/unittests/DAP/ProtocolTypesTest.cpp index 41703f4a071fb..5949abcb717d6 100644 --- a/lldb/unittests/DAP/ProtocolTypesTest.cpp +++ b/lldb/unittests/DAP/ProtocolTypesTest.cpp @@ -602,3 +602,23 @@ TEST(ProtocolTypesTest, DisassembledInstruction) { EXPECT_EQ(instruction.presentationHint, deserialized_instruction->presentationHint); } + +TEST(ProtocolTypesTest, StepInTarget) { + StepInTarget target; + target.id = 230; + target.label = "the_function_name"; + target.line = 2; + target.column = 320; + target.endLine = 32; + target.endColumn = 23; + + llvm::Expected<StepInTarget> deserialized_target = roundtrip(target); + ASSERT_THAT_EXPECTED(deserialized_target, llvm::Succeeded()); + + EXPECT_EQ(target.id, deserialized_target->id); + EXPECT_EQ(target.label, deserialized_target->label); + EXPECT_EQ(target.line, deserialized_target->line); + EXPECT_EQ(target.column, deserialized_target->column); + EXPECT_EQ(target.endLine, deserialized_target->endLine); + EXPECT_EQ(target.endColumn, deserialized_target->endColumn); +} \ No newline at end of file >From 8db9cedd09542379e9eb4b1e953dfd5d7714426b Mon Sep 17 00:00:00 2001 From: Ebuka Ezike <yerimy...@gmail.com> Date: Tue, 3 Jun 2025 15:35:12 +0100 Subject: [PATCH 2/3] [lldb-dap] add review changes. --- .../test/tools/lldb-dap/dap_server.py | 7 +++-- .../stepInTargets/TestDAP_stepInTargets.py | 28 +++++++++++++++++++ lldb/tools/lldb-dap/EventHelper.cpp | 17 +++++++++++ lldb/tools/lldb-dap/EventHelper.h | 2 ++ .../lldb-dap/Handler/AttachRequestHandler.cpp | 1 + .../lldb-dap/Handler/LaunchRequestHandler.cpp | 1 + .../tools/lldb-dap/Protocol/ProtocolTypes.cpp | 4 +-- lldb/tools/lldb-dap/Protocol/ProtocolTypes.h | 2 +- 8 files changed, 56 insertions(+), 6 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 6b41aef2bb5b8..f1e3cab06ccde 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -153,7 +153,7 @@ def __init__( self.recv_thread = threading.Thread(target=self._read_packet_thread) self.process_event_body = None self.exit_status: Optional[int] = None - self.initialize_body = None + self.initialize_body: dict[str, Any] = {} self.progress_events: list[Event] = [] self.reverse_requests = [] self.sequence = 1 @@ -300,6 +300,9 @@ def _handle_recv_packet(self, packet: Optional[ProtocolMessage]) -> bool: elif event == "breakpoint": # Breakpoint events are sent when a breakpoint is resolved self._update_verified_breakpoints([body["breakpoint"]]) + elif event == "capabilities": + # update the capabilities with new ones from the event. + self.initialize_body.update(body["capabilities"]) elif packet_type == "response": if packet["command"] == "disconnect": @@ -494,7 +497,7 @@ def get_initialize_value(self, key): """ if self.initialize_body and key in self.initialize_body: return self.initialize_body[key] - return None + raise ValueError(f"no value for key: {key} in {self.initialize_body}") def get_threads(self): if self.threads is None: diff --git a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py index 07acfe07c9ffc..d71f094e08d8a 100644 --- a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py +++ b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py @@ -78,3 +78,31 @@ def test_basic(self): leaf_frame = self.dap_server.get_stackFrame() self.assertIsNotNone(leaf_frame, "expect a leaf frame") self.assertEqual(step_in_targets[1]["label"], leaf_frame["name"]) + + def test_dynamic_capability(self): + program = self.getBuildArtifact("a.out") + self.build_and_launch(program) + source = "main.cpp" + bp_lines = [line_number(source, "// set breakpoint here")] + breakpoint_ids = self.set_source_breakpoints(source, bp_lines) + self.assertEqual( + len(breakpoint_ids), len(bp_lines), "expect correct number of breakpoints" + ) + is_supported = self.dap_server.get_initialize_value( + "supportsStepInTargetsRequest" + ) + arch: str = self.getArchitecture() + if arch.startswith("x86"): + self.assertTrue( + is_supported, + f"expect capability `stepInTarget` is supported with architecture {arch}", + ) + else: + self.assertFalse( + is_supported, + f"expect capability `stepInTarget` is not supported with architecture {arch}", + ) + + # clear breakpoints. + self.set_source_breakpoints(source, []) + self.continue_to_exit() diff --git a/lldb/tools/lldb-dap/EventHelper.cpp b/lldb/tools/lldb-dap/EventHelper.cpp index c698084836e2f..d9438182a9978 100644 --- a/lldb/tools/lldb-dap/EventHelper.cpp +++ b/lldb/tools/lldb-dap/EventHelper.cpp @@ -33,6 +33,23 @@ static void SendThreadExitedEvent(DAP &dap, lldb::tid_t tid) { dap.SendJSON(llvm::json::Value(std::move(event))); } +void SendAdditionalCapabilities(DAP &dap) { + if (dap.target.IsValid()) { + // FIXME: stepInTargets request is only supported by the x86 architecture + // remove when `lldb::InstructionControlFlowKind` is supported by other + // architectures + const llvm::StringRef target_triple = dap.target.GetTriple(); + if (!target_triple.starts_with("x86")) { + llvm::json::Object event(CreateEventObject("capabilities")); + llvm::json::Object capabilities{{"supportsStepInTargetsRequest", false}}; + + llvm::json::Object body; + body.try_emplace("capabilities", std::move(capabilities)); + event.try_emplace("body", std::move(body)); + dap.SendJSON(llvm::json::Value(std::move(event))); + } + } +} // "ProcessEvent": { // "allOf": [ // { "$ref": "#/definitions/Event" }, diff --git a/lldb/tools/lldb-dap/EventHelper.h b/lldb/tools/lldb-dap/EventHelper.h index 90b009c73089e..c0d33fa6f764b 100644 --- a/lldb/tools/lldb-dap/EventHelper.h +++ b/lldb/tools/lldb-dap/EventHelper.h @@ -16,6 +16,8 @@ struct DAP; enum LaunchMethod { Launch, Attach, AttachForSuspendedLaunch }; +void SendAdditionalCapabilities(DAP &dap); + void SendProcessEvent(DAP &dap, LaunchMethod launch_method); void SendThreadStoppedEvent(DAP &dap); diff --git a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp index 371349a26866e..308cc06371152 100644 --- a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp @@ -141,6 +141,7 @@ Error AttachRequestHandler::Run(const AttachRequestArguments &args) const { void AttachRequestHandler::PostRun() const { dap.SendJSON(CreateEventObject("initialized")); + SendAdditionalCapabilities(dap); } } // namespace lldb_dap diff --git a/lldb/tools/lldb-dap/Handler/LaunchRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/LaunchRequestHandler.cpp index 1d7b4b7009462..0ae89b6b09d4c 100644 --- a/lldb/tools/lldb-dap/Handler/LaunchRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/LaunchRequestHandler.cpp @@ -68,6 +68,7 @@ Error LaunchRequestHandler::Run(const LaunchRequestArguments &arguments) const { void LaunchRequestHandler::PostRun() const { dap.SendJSON(CreateEventObject("initialized")); + SendAdditionalCapabilities(dap); } } // namespace lldb_dap diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp index 440613b201c42..3b843c75891b3 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp +++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp @@ -593,10 +593,8 @@ bool fromJSON(const llvm::json::Value &Params, StepInTarget &SIT, } llvm::json::Value toJSON(const StepInTarget &SIT) { - json::Object target; + json::Object target{{"id", SIT.id}, {"label", SIT.label}}; - target.insert({"id", SIT.id}); - target.insert({"label", SIT.label}); if (SIT.line) target.insert({"line", SIT.line}); if (SIT.column) diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h index edaca049a6ffa..92b02903140b8 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h +++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h @@ -419,7 +419,7 @@ llvm::json::Value toJSON(const SteppingGranularity &); /// which single target the `stepIn` request should step. struct StepInTarget { /// Unique identifier for a step-in target. - uint64_t id = std::numeric_limits<uint64_t>::max(); + uint64_t id = LLDB_INVALID_ADDRESS; /// The name of the step-in target (shown in the UI). std::string label; >From dea97f225f5f1be2b3b6e1c1a604106af8d09c6b Mon Sep 17 00:00:00 2001 From: Ebuka Ezike <yerimy...@gmail.com> Date: Tue, 3 Jun 2025 15:47:51 +0100 Subject: [PATCH 3/3] [lldb-dap] rename to `supported_capability`. --- .../API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py index d71f094e08d8a..bbabbdc253a7c 100644 --- a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py +++ b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py @@ -79,7 +79,7 @@ def test_basic(self): self.assertIsNotNone(leaf_frame, "expect a leaf frame") self.assertEqual(step_in_targets[1]["label"], leaf_frame["name"]) - def test_dynamic_capability(self): + def test_supported_capability(self): program = self.getBuildArtifact("a.out") self.build_and_launch(program) source = "main.cpp" _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits