[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)
John Harrison via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 20 10:14:32 PDT 2025
================
@@ -0,0 +1,118 @@
+//===-- GoToRequestHandler.cpp --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "DAP.h"
+#include "EventHelper.h"
+#include "JSONUtils.h"
+
+namespace lldb_dap {
+
+/// Creates an \p StoppedEvent with the reason \a goto
+static void SendThreadGotoEvent(DAP &dap, lldb::tid_t thread_id) {
+ llvm::json::Object event(CreateEventObject("stopped"));
+ llvm::json::Object body;
+ body.try_emplace("reason", "goto");
+ body.try_emplace("description", "Paused on Jump To Cursor");
+ body.try_emplace("threadId", thread_id);
+ body.try_emplace("preserveFocusHint", false);
+ body.try_emplace("allThreadsStopped", true);
+
+ event.try_emplace("body", std::move(body));
+ dap.SendJSON(llvm::json::Value(std::move(event)));
+}
+
+// "GotoRequest": {
+// "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "The request sets the location where the debuggee will
+// continue to run.\nThis makes it possible to skip the execution of code or
+// to execute code again.\nThe code between the current location and the
+// goto target is not executed but skipped.\nThe debug adapter first sends
+// the response and then a `stopped` event with reason `goto`.\nClients
+// should only call this request if the corresponding capability
+// `supportsGotoTargetsRequest` is true (because only then goto targets
+// exist that can be passed as arguments).",
+//. "properties": {
+// "command": {
+// "type": "string",
+// "enum": [ "goto" ]
+// },
+// "arguments": {
+// "$ref": "#/definitions/GotoArguments"
+// }
+// },
+// "required": [ "command", "arguments" ]
+// }]
+// }
+// "GotoArguments": {
+// "type": "object",
+// "description": "Arguments for `goto` request.",
+// "properties": {
+// "threadId": {
+// "type": "integer",
+// "description": "Set the goto target for this thread."
+// },
+// "targetId": {
+// "type": "integer",
+// "description": "The location where the debuggee will continue to run."
+// }
+// },
+// "required": [ "threadId", "targetId" ]
+// }
+// "GotoResponse": {
+// "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `goto` request. This is just an
+// acknowledgement, so no body field is required."
+// }]
+// }
+void GoToRequestHandler::operator()(const llvm::json::Object &request) const {
+ llvm::json::Object response;
+ FillResponse(request, response);
+
+ auto SendError = [&](auto &&message) {
+ response["success"] = false;
+ response["message"] = message;
+ dap.SendJSON(llvm::json::Value(std::move(response)));
+ };
----------------
ashgti wrote:
I had been meaning to follow up on this with a `DAPError` class, I sent #132255 to implement that.
Also, as vogelsgesang said, I wouldn't block this PR on using that once #132255 is in, that should help clean up the code a bit.
https://github.com/llvm/llvm-project/pull/130503
More information about the lldb-commits
mailing list