-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[lldb-dap] Migrate pause request to structured types #171096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-lldb Author: Sergei Druzhkov (DrSergei) ChangesThis patch migrates Full diff: https://github.com/llvm/llvm-project/pull/171096.diff 5 Files Affected:
diff --git a/lldb/tools/lldb-dap/Handler/PauseRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/PauseRequestHandler.cpp
index 99917b2e28223..1589c7c1142e9 100644
--- a/lldb/tools/lldb-dap/Handler/PauseRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/PauseRequestHandler.cpp
@@ -8,53 +8,19 @@
#include "DAP.h"
#include "EventHelper.h"
-#include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
#include "RequestHandler.h"
namespace lldb_dap {
-// "PauseRequest": {
-// "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Pause request; value of command field is 'pause'. The
-// request suspenses the debuggee. The debug adapter first sends the
-// PauseResponse and then a StoppedEvent (event type 'pause') after the
-// thread has been paused successfully.", "properties": {
-// "command": {
-// "type": "string",
-// "enum": [ "pause" ]
-// },
-// "arguments": {
-// "$ref": "#/definitions/PauseArguments"
-// }
-// },
-// "required": [ "command", "arguments" ]
-// }]
-// },
-// "PauseArguments": {
-// "type": "object",
-// "description": "Arguments for 'pause' request.",
-// "properties": {
-// "threadId": {
-// "type": "integer",
-// "description": "Pause execution for this thread."
-// }
-// },
-// "required": [ "threadId" ]
-// },
-// "PauseResponse": {
-// "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to 'pause' request. This is just an
-// acknowledgement, so no body field is required."
-// }]
-// }
-void PauseRequestHandler::operator()(const llvm::json::Object &request) const {
- llvm::json::Object response;
- FillResponse(request, response);
+/// The request suspenses the debuggee. The debug adapter first sends the
+/// PauseResponse and then a StoppedEvent (event type 'pause') after the thread
+/// has been paused successfully.
+llvm::Error
+PauseRequestHandler::Run(const protocol::PauseArguments &args) const {
lldb::SBProcess process = dap.target.GetProcess();
lldb::SBError error = process.Stop();
- dap.SendJSON(llvm::json::Value(std::move(response)));
+ return llvm::Error::success();
}
} // namespace lldb_dap
diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index 5d235352b7738..fdce33de3f680 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -492,11 +492,12 @@ class ModulesRequestHandler final
Run(const std::optional<protocol::ModulesArguments> &args) const override;
};
-class PauseRequestHandler : public LegacyRequestHandler {
+class PauseRequestHandler
+ : public RequestHandler<protocol::PauseArguments, protocol::PauseResponse> {
public:
- using LegacyRequestHandler::LegacyRequestHandler;
+ using RequestHandler::RequestHandler;
static llvm::StringLiteral GetCommand() { return "pause"; }
- void operator()(const llvm::json::Object &request) const override;
+ llvm::Error Run(const protocol::PauseArguments &args) const override;
};
class ScopesRequestHandler final
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
index 0a1d580bffd68..95ecc7e4e7e40 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
@@ -695,4 +695,10 @@ llvm::json::Value toJSON(const EvaluateResponseBody &Body) {
return result;
}
+bool fromJSON(const llvm::json::Value &Params, PauseArguments &Args,
+ llvm::json::Path Path) {
+ json::ObjectMapper O(Params, Path);
+ return O && O.map("threadId", Args.threadId);
+}
+
} // namespace lldb_dap::protocol
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
index 6a85033ae7ef2..dc84e90ae03b4 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
@@ -1184,6 +1184,17 @@ struct EvaluateResponseBody {
};
llvm::json::Value toJSON(const EvaluateResponseBody &);
+/// Arguments for `pause` request.
+struct PauseArguments {
+ /// Pause execution for this thread.
+ lldb::tid_t threadId = LLDB_INVALID_THREAD_ID;
+};
+bool fromJSON(const llvm::json::Value &, PauseArguments &, llvm::json::Path);
+
+/// Response to `pause` request. This is just an acknowledgement, so no body
+/// field is required.
+using PauseResponse = VoidResponse;
+
} // namespace lldb_dap::protocol
#endif
diff --git a/lldb/unittests/DAP/ProtocolRequestsTest.cpp b/lldb/unittests/DAP/ProtocolRequestsTest.cpp
index a74c369924b8e..c830690a8e4fe 100644
--- a/lldb/unittests/DAP/ProtocolRequestsTest.cpp
+++ b/lldb/unittests/DAP/ProtocolRequestsTest.cpp
@@ -182,3 +182,14 @@ TEST(ProtocolRequestsTest, InitializeRequestArguments) {
EXPECT_THAT_EXPECTED(parse<InitializeRequestArguments>(R"({})"),
FailedWithMessage("missing value at (root).adapterID"));
}
+
+TEST(ProtocolRequestsTest, PauseRequestArguments) {
+ llvm::Expected<PauseArguments> expected =
+ parse<PauseArguments>(R"({"threadId": 123})");
+ ASSERT_THAT_EXPECTED(expected, llvm::Succeeded());
+ EXPECT_EQ(expected->threadId, 123U);
+
+ // Check required keys.
+ EXPECT_THAT_EXPECTED(parse<PauseArguments>(R"({})"),
+ FailedWithMessage("missing value at (root).threadId"));
+}
|
da-viper
reviewed
Dec 8, 2025
da-viper
approved these changes
Dec 8, 2025
ashgti
approved these changes
Dec 8, 2025
JDevlieghere
approved these changes
Dec 8, 2025
honeygoyal
pushed a commit
to honeygoyal/llvm-project
that referenced
this pull request
Dec 9, 2025
This patch migrates `pause` request into structured types and adds test for it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch migrates
pauserequest into structured types and adds test for it.