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,
35 Status &error, 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 Status &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 bool m_send_error_strings = false; // If the client enables this then
61 // we will send error strings as well.
63 PacketResult Handle_QErrorStringEnable(StringExtractorGDBRemote &packet);
65 PacketResult SendErrorResponse(const Status &error);
67 PacketResult SendUnimplementedResponse(const char *packet);
69 PacketResult SendErrorResponse(uint8_t error);
71 PacketResult SendIllFormedResponse(const StringExtractorGDBRemote &packet,
72 const char *error_message);
74 PacketResult SendOKResponse();
77 DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationServer);
80 } // namespace process_gdb_remote
81 } // namespace lldb_private
83 #endif // liblldb_GDBRemoteCommunicationServer_h_