Greg Clayton | 61d043b | 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 |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 17 | #include "lldb/Target/Process.h" |
| 18 | |
Greg Clayton | 61d043b | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 19 | #include "GDBRemoteCommunication.h" |
| 20 | |
| 21 | class ProcessGDBRemote; |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 22 | class StringExtractorGDBRemote; |
Greg Clayton | 61d043b | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 23 | |
| 24 | class GDBRemoteCommunicationServer : public GDBRemoteCommunication |
| 25 | { |
| 26 | public: |
| 27 | enum |
| 28 | { |
| 29 | eBroadcastBitRunPacketSent = kLoUserBroadcastBit |
| 30 | }; |
| 31 | //------------------------------------------------------------------ |
| 32 | // Constructors and Destructors |
| 33 | //------------------------------------------------------------------ |
Greg Clayton | b72d0f0 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 34 | GDBRemoteCommunicationServer(bool is_platform); |
Greg Clayton | 61d043b | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 35 | |
| 36 | virtual |
| 37 | ~GDBRemoteCommunicationServer(); |
| 38 | |
| 39 | bool |
Greg Clayton | cb8977d | 2011-03-23 00:09:55 +0000 | [diff] [blame] | 40 | GetPacketAndSendResponse (const lldb_private::TimeValue* timeout_ptr, |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 41 | lldb_private::Error &error, |
Greg Clayton | cb8977d | 2011-03-23 00:09:55 +0000 | [diff] [blame] | 42 | bool &interrupt, |
| 43 | bool &quit); |
Greg Clayton | 61d043b | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 44 | |
| 45 | virtual bool |
| 46 | GetThreadSuffixSupported () |
| 47 | { |
| 48 | return true; |
| 49 | } |
| 50 | |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 51 | // After connecting, do a little handshake with the client to make sure |
| 52 | // we are at least communicating |
| 53 | bool |
| 54 | HandshakeWithClient (lldb_private::Error *error_ptr); |
Greg Clayton | 61d043b | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 55 | |
Greg Clayton | b72d0f0 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 56 | // Set both ports to zero to let the platform automatically bind to |
| 57 | // a port chosen by the OS. |
| 58 | void |
| 59 | SetPortRange (uint16_t lo_port_num, uint16_t hi_port_num) |
| 60 | { |
| 61 | m_lo_port_num = lo_port_num; |
| 62 | m_hi_port_num = hi_port_num; |
| 63 | } |
| 64 | |
Greg Clayton | 61d043b | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 65 | protected: |
Greg Clayton | b72d0f0 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 66 | //typedef std::map<uint16_t, lldb::pid_t> PortToPIDMap; |
| 67 | |
Greg Clayton | 61d043b | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 68 | lldb::thread_t m_async_thread; |
Greg Clayton | b72d0f0 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 69 | lldb_private::ProcessLaunchInfo m_process_launch_info; |
| 70 | lldb_private::Error m_process_launch_error; |
| 71 | lldb_private::ProcessInstanceInfoList m_proc_infos; |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 72 | uint32_t m_proc_infos_index; |
Greg Clayton | b72d0f0 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 73 | uint16_t m_lo_port_num; |
| 74 | uint16_t m_hi_port_num; |
| 75 | //PortToPIDMap m_port_to_pid_map; |
Greg Clayton | 61d043b | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 76 | |
| 77 | size_t |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 78 | SendUnimplementedResponse (const char *packet); |
| 79 | |
| 80 | size_t |
| 81 | SendErrorResponse (uint8_t error); |
Greg Clayton | 61d043b | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 82 | |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 83 | size_t |
| 84 | SendOKResponse (); |
Greg Clayton | 61d043b | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 85 | |
| 86 | bool |
Greg Clayton | b72d0f0 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 87 | Handle_A (StringExtractorGDBRemote &packet); |
| 88 | |
| 89 | bool |
| 90 | Handle_qLaunchSuccess (StringExtractorGDBRemote &packet); |
| 91 | |
| 92 | bool |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 93 | Handle_qHostInfo (StringExtractorGDBRemote &packet); |
| 94 | |
| 95 | bool |
Greg Clayton | b72d0f0 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 96 | Handle_qLaunchGDBServer (StringExtractorGDBRemote &packet); |
| 97 | |
| 98 | bool |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 99 | Handle_qProcessInfoPID (StringExtractorGDBRemote &packet); |
| 100 | |
| 101 | bool |
| 102 | Handle_qfProcessInfo (StringExtractorGDBRemote &packet); |
| 103 | |
| 104 | bool |
| 105 | Handle_qsProcessInfo (StringExtractorGDBRemote &packet); |
| 106 | |
Greg Clayton | b72d0f0 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 107 | bool |
| 108 | Handle_qC (StringExtractorGDBRemote &packet); |
| 109 | |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 110 | bool |
| 111 | Handle_qUserName (StringExtractorGDBRemote &packet); |
| 112 | |
| 113 | bool |
| 114 | Handle_qGroupName (StringExtractorGDBRemote &packet); |
Greg Clayton | 61d043b | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 115 | |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 116 | bool |
Greg Clayton | 06d7cc8 | 2011-04-04 18:18:57 +0000 | [diff] [blame] | 117 | Handle_qSpeedTest (StringExtractorGDBRemote &packet); |
| 118 | |
| 119 | bool |
Greg Clayton | b72d0f0 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 120 | Handle_QEnvironment (StringExtractorGDBRemote &packet); |
| 121 | |
| 122 | bool |
| 123 | Handle_QSetDisableASLR (StringExtractorGDBRemote &packet); |
| 124 | |
| 125 | bool |
| 126 | Handle_QSetWorkingDir (StringExtractorGDBRemote &packet); |
| 127 | |
| 128 | bool |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 129 | Handle_QStartNoAckMode (StringExtractorGDBRemote &packet); |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 130 | |
Greg Clayton | b72d0f0 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 131 | bool |
| 132 | Handle_QSetSTDIN (StringExtractorGDBRemote &packet); |
| 133 | |
| 134 | bool |
| 135 | Handle_QSetSTDOUT (StringExtractorGDBRemote &packet); |
| 136 | |
| 137 | bool |
| 138 | Handle_QSetSTDERR (StringExtractorGDBRemote &packet); |
| 139 | |
Greg Clayton | 61d043b | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 140 | private: |
| 141 | //------------------------------------------------------------------ |
| 142 | // For GDBRemoteCommunicationServer only |
| 143 | //------------------------------------------------------------------ |
| 144 | DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationServer); |
| 145 | }; |
| 146 | |
| 147 | #endif // liblldb_GDBRemoteCommunicationServer_h_ |