LLDB  mainline
GDBRemoteCommunicationServer.h
Go to the documentation of this file.
1 //===-- GDBRemoteCommunicationServer.h --------------------------*- C++ -*-===//
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 liblldb_GDBRemoteCommunicationServer_h_
10 #define liblldb_GDBRemoteCommunicationServer_h_
11 
12 #include <functional>
13 #include <map>
14 
15 #include "GDBRemoteCommunication.h"
17 
19 
20 namespace lldb_private {
21 namespace process_gdb_remote {
22 
23 class ProcessGDBRemote;
24 
26 public:
27  using PortMap = std::map<uint16_t, lldb::pid_t>;
28  using PacketHandler =
29  std::function<PacketResult(StringExtractorGDBRemote &packet,
30  Status &error, bool &interrupt, bool &quit)>;
31 
32  GDBRemoteCommunicationServer(const char *comm_name,
33  const char *listener_name);
34 
36 
37  void
39  PacketHandler handler);
40 
42  Status &error, bool &interrupt,
43  bool &quit);
44 
45  // After connecting, do a little handshake with the client to make sure
46  // we are at least communicating
47  bool HandshakeWithClient();
48 
49 protected:
50  std::map<StringExtractorGDBRemote::ServerPacketType, PacketHandler>
52  bool m_exit_now; // use in asynchronous handling to indicate process should
53  // exit.
54 
55  bool m_send_error_strings = false; // If the client enables this then
56  // we will send error strings as well.
57 
59 
61 
62  PacketResult SendUnimplementedResponse(const char *packet);
63 
64  PacketResult SendErrorResponse(uint8_t error);
65 
67  const char *error_message);
68 
70 
71 private:
72  DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationServer);
73 };
74 
75 } // namespace process_gdb_remote
76 } // namespace lldb_private
77 
78 #endif // liblldb_GDBRemoteCommunicationServer_h_
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
GDBRemoteCommunicationServer(const char *comm_name, const char *listener_name)
std::map< StringExtractorGDBRemote::ServerPacketType, PacketHandler > m_packet_handlers
PacketResult SendIllFormedResponse(const StringExtractorGDBRemote &packet, const char *error_message)
void RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type, PacketHandler handler)
PacketResult Handle_QErrorStringEnable(StringExtractorGDBRemote &packet)
PacketResult GetPacketAndSendResponse(Timeout< std::micro > timeout, Status &error, bool &interrupt, bool &quit)
std::function< PacketResult(StringExtractorGDBRemote &packet, Status &error, bool &interrupt, bool &quit)> PacketHandler
An error handling class.
Definition: Status.h:44