Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 1 | //===-- GDBRemoteCommunicationServerCommon.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_GDBRemoteCommunicationServerCommon_h_ |
| 11 | #define liblldb_GDBRemoteCommunicationServerCommon_h_ |
| 12 | |
| 13 | // C Includes |
| 14 | // C++ Includes |
| 15 | #include <set> |
| 16 | |
| 17 | // Other libraries and framework includes |
| 18 | #include "lldb/lldb-private-forward.h" |
| 19 | #include "lldb/Host/Mutex.h" |
| 20 | #include "lldb/Target/Process.h" |
| 21 | |
| 22 | // Project includes |
| 23 | #include "GDBRemoteCommunicationServer.h" |
| 24 | #include "GDBRemoteCommunicationServerCommon.h" |
| 25 | |
| 26 | class ProcessGDBRemote; |
| 27 | class StringExtractorGDBRemote; |
| 28 | |
| 29 | class GDBRemoteCommunicationServerCommon : |
| 30 | public GDBRemoteCommunicationServer |
| 31 | { |
| 32 | public: |
| 33 | GDBRemoteCommunicationServerCommon(const char *comm_name, const char *listener_name); |
| 34 | |
| 35 | virtual |
| 36 | ~GDBRemoteCommunicationServerCommon(); |
| 37 | |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 38 | protected: |
| 39 | std::set<lldb::pid_t> m_spawned_pids; |
| 40 | lldb_private::Mutex m_spawned_pids_mutex; |
| 41 | lldb_private::ProcessLaunchInfo m_process_launch_info; |
| 42 | lldb_private::Error m_process_launch_error; |
| 43 | lldb_private::ProcessInstanceInfoList m_proc_infos; |
| 44 | uint32_t m_proc_infos_index; |
| 45 | bool m_thread_suffix_supported; |
| 46 | bool m_list_threads_in_stop_reply; |
| 47 | |
| 48 | PacketResult |
| 49 | Handle_A (StringExtractorGDBRemote &packet); |
| 50 | |
| 51 | PacketResult |
| 52 | Handle_qHostInfo (StringExtractorGDBRemote &packet); |
| 53 | |
| 54 | PacketResult |
| 55 | Handle_qProcessInfoPID (StringExtractorGDBRemote &packet); |
| 56 | |
| 57 | PacketResult |
| 58 | Handle_qfProcessInfo (StringExtractorGDBRemote &packet); |
| 59 | |
| 60 | PacketResult |
| 61 | Handle_qsProcessInfo (StringExtractorGDBRemote &packet); |
| 62 | |
| 63 | PacketResult |
| 64 | Handle_qUserName (StringExtractorGDBRemote &packet); |
| 65 | |
| 66 | PacketResult |
| 67 | Handle_qGroupName (StringExtractorGDBRemote &packet); |
| 68 | |
| 69 | PacketResult |
| 70 | Handle_qSpeedTest (StringExtractorGDBRemote &packet); |
| 71 | |
| 72 | PacketResult |
| 73 | Handle_qKillSpawnedProcess (StringExtractorGDBRemote &packet); |
| 74 | |
| 75 | PacketResult |
| 76 | Handle_vFile_Open (StringExtractorGDBRemote &packet); |
| 77 | |
| 78 | PacketResult |
| 79 | Handle_vFile_Close (StringExtractorGDBRemote &packet); |
| 80 | |
| 81 | PacketResult |
| 82 | Handle_vFile_pRead (StringExtractorGDBRemote &packet); |
| 83 | |
| 84 | PacketResult |
| 85 | Handle_vFile_pWrite (StringExtractorGDBRemote &packet); |
| 86 | |
| 87 | PacketResult |
| 88 | Handle_vFile_Size (StringExtractorGDBRemote &packet); |
| 89 | |
| 90 | PacketResult |
| 91 | Handle_vFile_Mode (StringExtractorGDBRemote &packet); |
| 92 | |
| 93 | PacketResult |
| 94 | Handle_vFile_Exists (StringExtractorGDBRemote &packet); |
| 95 | |
| 96 | PacketResult |
| 97 | Handle_vFile_symlink (StringExtractorGDBRemote &packet); |
| 98 | |
| 99 | PacketResult |
| 100 | Handle_vFile_unlink (StringExtractorGDBRemote &packet); |
| 101 | |
| 102 | PacketResult |
| 103 | Handle_vFile_Stat (StringExtractorGDBRemote &packet); |
| 104 | |
| 105 | PacketResult |
| 106 | Handle_vFile_MD5 (StringExtractorGDBRemote &packet); |
| 107 | |
| 108 | PacketResult |
Oleksiy Vyalov | 6801be3 | 2015-02-25 22:15:44 +0000 | [diff] [blame] | 109 | Handle_qModuleInfo (StringExtractorGDBRemote &packet); |
| 110 | |
| 111 | PacketResult |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 112 | Handle_qPlatform_shell (StringExtractorGDBRemote &packet); |
| 113 | |
| 114 | PacketResult |
| 115 | Handle_qPlatform_mkdir (StringExtractorGDBRemote &packet); |
| 116 | |
| 117 | PacketResult |
| 118 | Handle_qPlatform_chmod (StringExtractorGDBRemote &packet); |
| 119 | |
| 120 | PacketResult |
| 121 | Handle_qSupported (StringExtractorGDBRemote &packet); |
| 122 | |
| 123 | PacketResult |
| 124 | Handle_QThreadSuffixSupported (StringExtractorGDBRemote &packet); |
| 125 | |
| 126 | PacketResult |
| 127 | Handle_QListThreadsInStopReply (StringExtractorGDBRemote &packet); |
| 128 | |
| 129 | PacketResult |
| 130 | Handle_QSetDetachOnError (StringExtractorGDBRemote &packet); |
| 131 | |
| 132 | PacketResult |
| 133 | Handle_QStartNoAckMode (StringExtractorGDBRemote &packet); |
| 134 | |
| 135 | PacketResult |
| 136 | Handle_QSetSTDIN (StringExtractorGDBRemote &packet); |
| 137 | |
| 138 | PacketResult |
| 139 | Handle_QSetSTDOUT (StringExtractorGDBRemote &packet); |
| 140 | |
| 141 | PacketResult |
| 142 | Handle_QSetSTDERR (StringExtractorGDBRemote &packet); |
| 143 | |
| 144 | PacketResult |
| 145 | Handle_qLaunchSuccess (StringExtractorGDBRemote &packet); |
| 146 | |
| 147 | PacketResult |
| 148 | Handle_QEnvironment (StringExtractorGDBRemote &packet); |
| 149 | |
| 150 | PacketResult |
| 151 | Handle_QLaunchArch (StringExtractorGDBRemote &packet); |
| 152 | |
| 153 | bool |
| 154 | KillSpawnedProcess (lldb::pid_t pid); |
| 155 | |
| 156 | static void |
| 157 | CreateProcessInfoResponse (const lldb_private::ProcessInstanceInfo &proc_info, |
| 158 | lldb_private::StreamString &response); |
| 159 | |
| 160 | static void |
| 161 | CreateProcessInfoResponse_DebugServerStyle (const lldb_private::ProcessInstanceInfo &proc_info, |
| 162 | lldb_private::StreamString &response); |
| 163 | |
| 164 | template <typename T> |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 165 | void |
Tamas Berghammer | 81e9239 | 2015-02-18 11:37:46 +0000 | [diff] [blame] | 166 | RegisterMemberFunctionHandler (StringExtractorGDBRemote::ServerPacketType packet_type, |
| 167 | PacketResult (T::*handler) (StringExtractorGDBRemote& packet)) |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 168 | { |
| 169 | RegisterPacketHandler(packet_type, |
| 170 | [this, handler] (StringExtractorGDBRemote packet, |
| 171 | lldb_private::Error &error, |
| 172 | bool &interrupt, |
| 173 | bool &quit) |
| 174 | { |
| 175 | return (static_cast<T*>(this)->*handler) (packet); |
| 176 | }); |
| 177 | } |
Tamas Berghammer | 7cb18bf | 2015-03-24 11:15:23 +0000 | [diff] [blame^] | 178 | |
| 179 | bool |
| 180 | GetThreadSuffixSupported () override |
| 181 | { |
| 182 | return true; |
| 183 | } |
| 184 | |
| 185 | //------------------------------------------------------------------ |
| 186 | /// Launch a process with the current launch settings. |
| 187 | /// |
| 188 | /// This method supports running an lldb-gdbserver or similar |
| 189 | /// server in a situation where the startup code has been provided |
| 190 | /// with all the information for a child process to be launched. |
| 191 | /// |
| 192 | /// @return |
| 193 | /// An Error object indicating the success or failure of the |
| 194 | /// launch. |
| 195 | //------------------------------------------------------------------ |
| 196 | virtual lldb_private::Error |
| 197 | LaunchProcess () = 0; |
| 198 | |
| 199 | virtual lldb_private::FileSpec |
| 200 | FindModuleFile (const std::string& module_path, const lldb_private::ArchSpec& arch); |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 201 | }; |
| 202 | |
| 203 | #endif // liblldb_GDBRemoteCommunicationServerCommon_h_ |