
Completes the work started in #128262. This PR removes the old way of register request handlers with callbacks and makes the operator const.
60 lines
1.8 KiB
C++
60 lines
1.8 KiB
C++
//===-- ModulesRequestHandler.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"
|
|
#include "RequestHandler.h"
|
|
|
|
namespace lldb_dap {
|
|
|
|
// "modulesRequest": {
|
|
// "allOf": [ { "$ref": "#/definitions/Request" }, {
|
|
// "type": "object",
|
|
// "description": "Modules request; value of command field is
|
|
// 'modules'.",
|
|
// "properties": {
|
|
// "command": {
|
|
// "type": "string",
|
|
// "enum": [ "modules" ]
|
|
// },
|
|
// },
|
|
// "required": [ "command" ]
|
|
// }]
|
|
// },
|
|
// "modulesResponse": {
|
|
// "allOf": [ { "$ref": "#/definitions/Response" }, {
|
|
// "type": "object",
|
|
// "description": "Response to 'modules' request.",
|
|
// "properties": {
|
|
// "body": {
|
|
// "description": "Response to 'modules' request. Array of
|
|
// module objects."
|
|
// }
|
|
// }
|
|
// }]
|
|
// }
|
|
void ModulesRequestHandler::operator()(
|
|
const llvm::json::Object &request) const {
|
|
llvm::json::Object response;
|
|
FillResponse(request, response);
|
|
|
|
llvm::json::Array modules;
|
|
for (size_t i = 0; i < dap.target.GetNumModules(); i++) {
|
|
lldb::SBModule module = dap.target.GetModuleAtIndex(i);
|
|
modules.emplace_back(CreateModule(dap.target, module));
|
|
}
|
|
|
|
llvm::json::Object body;
|
|
body.try_emplace("modules", std::move(modules));
|
|
response.try_emplace("body", std::move(body));
|
|
dap.SendJSON(llvm::json::Value(std::move(response)));
|
|
}
|
|
|
|
} // namespace lldb_dap
|