1 //===-- GDBRemoteCommunicationServer.h --------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_GDBRemoteCommunicationServer_h_
11 #define liblldb_GDBRemoteCommunicationServer_h_
18 // Other libraries and framework includes
20 #include "GDBRemoteCommunication.h"
21 #include "lldb/lldb-private-forward.h"
23 class StringExtractorGDBRemote;
25 namespace lldb_private {
26 namespace process_gdb_remote {
28 class ProcessGDBRemote;
30 class GDBRemoteCommunicationServer : public GDBRemoteCommunication {
32 using PortMap = std::map<uint16_t, lldb::pid_t>;
34 std::function<PacketResult(StringExtractorGDBRemote &packet, Error &error,
35 bool &interrupt, bool &quit)>;
37 GDBRemoteCommunicationServer(const char *comm_name,
38 const char *listener_name);
40 ~GDBRemoteCommunicationServer() override;
43 RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type,
44 PacketHandler handler);
46 PacketResult GetPacketAndSendResponse(Timeout<std::micro> timeout,
47 Error &error, bool &interrupt,
50 // After connecting, do a little handshake with the client to make sure
51 // we are at least communicating
52 bool HandshakeWithClient();
55 std::map<StringExtractorGDBRemote::ServerPacketType, PacketHandler>
57 bool m_exit_now; // use in asynchronous handling to indicate process should
60 PacketResult SendUnimplementedResponse(const char *packet);
62 PacketResult SendErrorResponse(uint8_t error);
64 PacketResult SendIllFormedResponse(const StringExtractorGDBRemote &packet,
65 const char *error_message);
67 PacketResult SendOKResponse();
70 DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationServer);
73 } // namespace process_gdb_remote
74 } // namespace lldb_private
76 #endif // liblldb_GDBRemoteCommunicationServer_h_