aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Protocol/MCP/Resource.h
blob: 0c6576602905e5f52dc3aa05c4f21d75db1afe78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef LLDB_PLUGINS_PROTOCOL_MCP_RESOURCE_H
#define LLDB_PLUGINS_PROTOCOL_MCP_RESOURCE_H

#include "lldb/Protocol/MCP/Protocol.h"
#include "lldb/Protocol/MCP/Resource.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include <cstddef>
#include <vector>

namespace lldb_private::mcp {

class DebuggerResourceProvider : public lldb_protocol::mcp::ResourceProvider {
public:
  using ResourceProvider::ResourceProvider;
  virtual ~DebuggerResourceProvider() = default;

  std::vector<lldb_protocol::mcp::Resource> GetResources() const override;
  llvm::Expected<lldb_protocol::mcp::ReadResourceResult>
  ReadResource(llvm::StringRef uri) const override;

private:
  static lldb_protocol::mcp::Resource GetDebuggerResource(Debugger &debugger);
  static lldb_protocol::mcp::Resource GetTargetResource(size_t target_idx,
                                                        Target &target);

  static llvm::Expected<lldb_protocol::mcp::ReadResourceResult>
  ReadDebuggerResource(llvm::StringRef uri, lldb::user_id_t debugger_id);
  static llvm::Expected<lldb_protocol::mcp::ReadResourceResult>
  ReadTargetResource(llvm::StringRef uri, lldb::user_id_t debugger_id,
                     size_t target_idx);
};

} // namespace lldb_private::mcp

#endif