]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Process / gdb-remote / GDBRemoteCommunicationServer.h
1 //===-- GDBRemoteCommunicationServer.h --------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_GDBRemoteCommunicationServer_h_
11 #define liblldb_GDBRemoteCommunicationServer_h_
12
13 // C Includes
14 // C++ Includes
15 #include <functional>
16 #include <map>
17
18 // Other libraries and framework includes
19 // Project includes
20 #include "GDBRemoteCommunication.h"
21 #include "lldb/lldb-private-forward.h"
22
23 class StringExtractorGDBRemote;
24
25 namespace lldb_private {
26 namespace process_gdb_remote {
27
28 class ProcessGDBRemote;
29
30 class GDBRemoteCommunicationServer : public GDBRemoteCommunication {
31 public:
32   using PortMap = std::map<uint16_t, lldb::pid_t>;
33   using PacketHandler =
34       std::function<PacketResult(StringExtractorGDBRemote &packet,
35                                  Status &error, bool &interrupt, bool &quit)>;
36
37   GDBRemoteCommunicationServer(const char *comm_name,
38                                const char *listener_name);
39
40   ~GDBRemoteCommunicationServer() override;
41
42   void
43   RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type,
44                         PacketHandler handler);
45
46   PacketResult GetPacketAndSendResponse(Timeout<std::micro> timeout,
47                                         Status &error, bool &interrupt,
48                                         bool &quit);
49
50   // After connecting, do a little handshake with the client to make sure
51   // we are at least communicating
52   bool HandshakeWithClient();
53
54 protected:
55   std::map<StringExtractorGDBRemote::ServerPacketType, PacketHandler>
56       m_packet_handlers;
57   bool m_exit_now; // use in asynchronous handling to indicate process should
58                    // exit.
59
60   bool m_send_error_strings = false; // If the client enables this then
61                                      // we will send error strings as well.
62
63   PacketResult Handle_QErrorStringEnable(StringExtractorGDBRemote &packet);
64
65   PacketResult SendErrorResponse(const Status &error);
66
67   PacketResult SendUnimplementedResponse(const char *packet);
68
69   PacketResult SendErrorResponse(uint8_t error);
70
71   PacketResult SendIllFormedResponse(const StringExtractorGDBRemote &packet,
72                                      const char *error_message);
73
74   PacketResult SendOKResponse();
75
76 private:
77   DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationServer);
78 };
79
80 } // namespace process_gdb_remote
81 } // namespace lldb_private
82
83 #endif // liblldb_GDBRemoteCommunicationServer_h_