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_
16 #include "GDBRemoteCommunication.h"
17 #include "lldb/lldb-private-forward.h"
19 class StringExtractorGDBRemote;
21 namespace lldb_private {
22 namespace process_gdb_remote {
24 class ProcessGDBRemote;
26 class GDBRemoteCommunicationServer : public GDBRemoteCommunication {
28 using PortMap = std::map<uint16_t, lldb::pid_t>;
30 std::function<PacketResult(StringExtractorGDBRemote &packet,
31 Status &error, bool &interrupt, bool &quit)>;
33 GDBRemoteCommunicationServer(const char *comm_name,
34 const char *listener_name);
36 ~GDBRemoteCommunicationServer() override;
39 RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type,
40 PacketHandler handler);
42 PacketResult GetPacketAndSendResponse(Timeout<std::micro> timeout,
43 Status &error, bool &interrupt,
46 // After connecting, do a little handshake with the client to make sure
47 // we are at least communicating
48 bool HandshakeWithClient();
51 std::map<StringExtractorGDBRemote::ServerPacketType, PacketHandler>
53 bool m_exit_now; // use in asynchronous handling to indicate process should
56 bool m_send_error_strings = false; // If the client enables this then
57 // we will send error strings as well.
59 PacketResult Handle_QErrorStringEnable(StringExtractorGDBRemote &packet);
61 PacketResult SendErrorResponse(const Status &error);
63 PacketResult SendUnimplementedResponse(const char *packet);
65 PacketResult SendErrorResponse(uint8_t error);
67 PacketResult SendIllFormedResponse(const StringExtractorGDBRemote &packet,
68 const char *error_message);
70 PacketResult SendOKResponse();
73 DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationServer);
76 } // namespace process_gdb_remote
77 } // namespace lldb_private
79 #endif // liblldb_GDBRemoteCommunicationServer_h_