1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_PLUGINS_PROTOCOL_MCP_RESOURCE_H
10#define LLDB_PLUGINS_PROTOCOL_MCP_RESOURCE_H
11
12#include "Protocol.h"
13#include "lldb/lldb-private.h"
14#include <vector>
15
16namespace lldb_private::mcp {
17
18class ResourceProvider {
19public:
20 ResourceProvider() = default;
21 virtual ~ResourceProvider() = default;
22
23 virtual std::vector<protocol::Resource> GetResources() const = 0;
24 virtual llvm::Expected<protocol::ResourceResult>
25 ReadResource(llvm::StringRef uri) const = 0;
26};
27
28class DebuggerResourceProvider : public ResourceProvider {
29public:
30 using ResourceProvider::ResourceProvider;
31 virtual ~DebuggerResourceProvider() = default;
32
33 virtual std::vector<protocol::Resource> GetResources() const override;
34 virtual llvm::Expected<protocol::ResourceResult>
35 ReadResource(llvm::StringRef uri) const override;
36
37private:
38 static protocol::Resource GetDebuggerResource(Debugger &debugger);
39 static protocol::Resource GetTargetResource(size_t target_idx,
40 Target &target);
41
42 static llvm::Expected<protocol::ResourceResult>
43 ReadDebuggerResource(llvm::StringRef uri, lldb::user_id_t debugger_id);
44 static llvm::Expected<protocol::ResourceResult>
45 ReadTargetResource(llvm::StringRef uri, lldb::user_id_t debugger_id,
46 size_t target_idx);
47};
48
49} // namespace lldb_private::mcp
50
51#endif
52

source code of lldb/source/Plugins/Protocol/MCP/Resource.h