================ @@ -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))); + }; ---------------- da-viper wrote:
The new protocol currently does not implement StoppedEvent. Not sure If I should implement it in this PR also. It may take longer since @clayborg is proposing adding a new SB Public API function. Also the current new protocol does not take into account if we need to send an event after sending a response. Currently it will require repeating the `operator()(const protocol::Request &request)` code for any request that needs to send an event after a response such as stepIn, StepOut and Next https://github.com/llvm/llvm-project/pull/130503 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits