Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 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 | // Other libraries and framework includes |
| 16 | // Project includes |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 17 | #include "lldb/lldb-private-forward.h" |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 18 | #include "GDBRemoteCommunication.h" |
| 19 | |
| 20 | class ProcessGDBRemote; |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 21 | class StringExtractorGDBRemote; |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 22 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 23 | class GDBRemoteCommunicationServer : |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 24 | public GDBRemoteCommunication |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 25 | { |
| 26 | public: |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 27 | 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 Clayton | 29b8fc4 | 2013-11-21 01:44:58 +0000 | [diff] [blame] | 32 | |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 33 | GDBRemoteCommunicationServer(const char *comm_name, |
| 34 | const char *listener_name); |
Todd Fiala | b8b49ec | 2014-01-28 00:34:23 +0000 | [diff] [blame] | 35 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 36 | virtual |
| 37 | ~GDBRemoteCommunicationServer(); |
| 38 | |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 39 | void RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type, |
| 40 | PacketHandler handler); |
| 41 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 42 | PacketResult |
Greg Clayton | 73bf5db | 2011-06-17 01:22:15 +0000 | [diff] [blame] | 43 | GetPacketAndSendResponse (uint32_t timeout_usec, |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 44 | lldb_private::Error &error, |
Greg Clayton | d314e81 | 2011-03-23 00:09:55 +0000 | [diff] [blame] | 45 | bool &interrupt, |
| 46 | bool &quit); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 47 | |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 48 | // 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 Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 52 | |
| 53 | protected: |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 54 | std::map<StringExtractorGDBRemote::ServerPacketType, PacketHandler> m_packet_handlers; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 55 | bool m_exit_now; // use in asynchronous handling to indicate process should exit. |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 56 | |
Greg Clayton | 3dedae1 | 2013-12-06 21:45:27 +0000 | [diff] [blame] | 57 | PacketResult |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 58 | SendUnimplementedResponse (const char *packet); |
| 59 | |
Greg Clayton | 3dedae1 | 2013-12-06 21:45:27 +0000 | [diff] [blame] | 60 | PacketResult |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 61 | SendErrorResponse (uint8_t error); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 62 | |
Greg Clayton | 3dedae1 | 2013-12-06 21:45:27 +0000 | [diff] [blame] | 63 | PacketResult |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 64 | SendIllFormedResponse (const StringExtractorGDBRemote &packet, const char *error_message); |
| 65 | |
| 66 | PacketResult |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 67 | SendOKResponse (); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 68 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 69 | private: |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 70 | //------------------------------------------------------------------ |
| 71 | // For GDBRemoteCommunicationServer only |
| 72 | //------------------------------------------------------------------ |
| 73 | DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationServer); |
| 74 | }; |
| 75 | |
| 76 | #endif // liblldb_GDBRemoteCommunicationServer_h_ |