blob: a123e806a4ea03471977bb372f8ae5190e9611fd [file] [log] [blame]
Greg Clayton576d8832011-03-22 04:00:09 +00001//===-- 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// Other libraries and framework includes
16// Project includes
Todd Fialaaf245d12014-06-30 21:05:18 +000017#include "lldb/lldb-private-forward.h"
Greg Clayton576d8832011-03-22 04:00:09 +000018#include "GDBRemoteCommunication.h"
19
20class ProcessGDBRemote;
Greg Clayton32e0a752011-03-30 18:16:51 +000021class StringExtractorGDBRemote;
Greg Clayton576d8832011-03-22 04:00:09 +000022
Todd Fialaaf245d12014-06-30 21:05:18 +000023class GDBRemoteCommunicationServer :
Tamas Berghammere13c2732015-02-11 10:29:30 +000024 public GDBRemoteCommunication
Greg Clayton576d8832011-03-22 04:00:09 +000025{
26public:
Tamas Berghammere13c2732015-02-11 10:29:30 +000027 using PortMap = std::map<uint16_t, lldb::pid_t>;
28 using PacketHandler = std::function<PacketResult(StringExtractorGDBRemote &packet,
29 lldb_private::Error &error,
30 bool &interrupt,
31 bool &quit)>;
Greg Clayton29b8fc42013-11-21 01:44:58 +000032
Tamas Berghammere13c2732015-02-11 10:29:30 +000033 GDBRemoteCommunicationServer(const char *comm_name,
34 const char *listener_name);
Todd Fialab8b49ec2014-01-28 00:34:23 +000035
Greg Clayton576d8832011-03-22 04:00:09 +000036 virtual
37 ~GDBRemoteCommunicationServer();
38
Tamas Berghammere13c2732015-02-11 10:29:30 +000039 void RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type,
40 PacketHandler handler);
41
Todd Fialaaf245d12014-06-30 21:05:18 +000042 PacketResult
Greg Clayton73bf5db2011-06-17 01:22:15 +000043 GetPacketAndSendResponse (uint32_t timeout_usec,
Greg Clayton1cb64962011-03-24 04:28:38 +000044 lldb_private::Error &error,
Greg Claytond314e812011-03-23 00:09:55 +000045 bool &interrupt,
46 bool &quit);
Greg Clayton576d8832011-03-22 04:00:09 +000047
Greg Clayton1cb64962011-03-24 04:28:38 +000048 // After connecting, do a little handshake with the client to make sure
49 // we are at least communicating
50 bool
51 HandshakeWithClient (lldb_private::Error *error_ptr);
Greg Clayton576d8832011-03-22 04:00:09 +000052
53protected:
Tamas Berghammere13c2732015-02-11 10:29:30 +000054 std::map<StringExtractorGDBRemote::ServerPacketType, PacketHandler> m_packet_handlers;
Todd Fialaaf245d12014-06-30 21:05:18 +000055 bool m_exit_now; // use in asynchronous handling to indicate process should exit.
Greg Clayton576d8832011-03-22 04:00:09 +000056
Greg Clayton3dedae12013-12-06 21:45:27 +000057 PacketResult
Greg Clayton32e0a752011-03-30 18:16:51 +000058 SendUnimplementedResponse (const char *packet);
59
Greg Clayton3dedae12013-12-06 21:45:27 +000060 PacketResult
Greg Clayton32e0a752011-03-30 18:16:51 +000061 SendErrorResponse (uint8_t error);
Greg Clayton576d8832011-03-22 04:00:09 +000062
Greg Clayton3dedae12013-12-06 21:45:27 +000063 PacketResult
Todd Fialaaf245d12014-06-30 21:05:18 +000064 SendIllFormedResponse (const StringExtractorGDBRemote &packet, const char *error_message);
65
66 PacketResult
Greg Clayton1cb64962011-03-24 04:28:38 +000067 SendOKResponse ();
Greg Clayton576d8832011-03-22 04:00:09 +000068
Greg Clayton576d8832011-03-22 04:00:09 +000069private:
Greg Clayton576d8832011-03-22 04:00:09 +000070 //------------------------------------------------------------------
71 // For GDBRemoteCommunicationServer only
72 //------------------------------------------------------------------
73 DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationServer);
74};
75
76#endif // liblldb_GDBRemoteCommunicationServer_h_