LLDB mainline
ProtocolServerMCP.h
Go to the documentation of this file.
1//===- ProtocolServerMCP.h ------------------------------------------------===//
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_PROTOCOLSERVERMCP_H
10#define LLDB_PLUGINS_PROTOCOL_MCP_PROTOCOLSERVERMCP_H
11
13#include "lldb/Host/MainLoop.h"
14#include "lldb/Host/Socket.h"
17#include <thread>
18
20
22public:
24 virtual ~ProtocolServerMCP() override;
25
26 virtual llvm::Error Start(ProtocolServer::Connection connection) override;
27 virtual llvm::Error Stop() override;
28
29 static void Initialize();
30 static void Terminate();
31
32 static llvm::StringRef GetPluginNameStatic() { return "MCP"; }
33 static llvm::StringRef GetPluginDescriptionStatic();
34
36
37 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
38
39 Socket *GetSocket() const override { return m_listener.get(); }
40
41protected:
42 // This adds tools and resource providers that
43 // are specific to this server. Overridable by the unit tests.
44 virtual void Extend(lldb_protocol::mcp::Server &server) const;
45
46private:
47 void AcceptCallback(std::unique_ptr<Socket> socket);
48
49 bool m_running = false;
50
53 std::thread m_loop_thread;
54 std::mutex m_mutex;
55
56 std::unique_ptr<Socket> m_listener;
57
58 std::vector<MainLoopBase::ReadHandleUP> m_listen_handlers;
59 std::vector<std::unique_ptr<lldb_protocol::mcp::Server>> m_instances;
60};
61} // namespace lldb_private::mcp
62
63#endif
A file utility class.
Definition: FileSpec.h:57
std::unique_ptr< Socket > m_listener
virtual void Extend(lldb_protocol::mcp::Server &server) const
virtual llvm::Error Start(ProtocolServer::Connection connection) override
Socket * GetSocket() const override
std::vector< MainLoopBase::ReadHandleUP > m_listen_handlers
std::vector< std::unique_ptr< lldb_protocol::mcp::Server > > m_instances
static lldb::ProtocolServerUP CreateInstance()
virtual llvm::Error Stop() override
llvm::StringRef GetPluginName() override
void AcceptCallback(std::unique_ptr< Socket > socket)
static llvm::StringRef GetPluginNameStatic()
static llvm::StringRef GetPluginDescriptionStatic()
std::unique_ptr< lldb_private::ProtocolServer > ProtocolServerUP
Definition: lldb-forward.h:395