1 //===-- PlatformRemoteGDBServer.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_PlatformRemoteGDBServer_h_ 11 #define liblldb_PlatformRemoteGDBServer_h_ 12 13 // C Includes 14 // C++ Includes 15 #include <string> 16 17 // Other libraries and framework includes 18 // Project includes 19 #include "lldb/Target/Platform.h" 20 #include "../../Process/gdb-remote/GDBRemoteCommunicationClient.h" 21 22 class PlatformRemoteGDBServer : public lldb_private::Platform 23 { 24 public: 25 26 static void 27 Initialize (); 28 29 static void 30 Terminate (); 31 32 static lldb_private::Platform* 33 CreateInstance (bool force, const lldb_private::ArchSpec *arch); 34 35 static lldb_private::ConstString 36 GetPluginNameStatic(); 37 38 static const char * 39 GetDescriptionStatic(); 40 41 42 PlatformRemoteGDBServer (); 43 44 virtual 45 ~PlatformRemoteGDBServer(); 46 47 //------------------------------------------------------------ 48 // lldb_private::PluginInterface functions 49 //------------------------------------------------------------ 50 virtual lldb_private::ConstString 51 GetPluginName() 52 { 53 return GetPluginNameStatic(); 54 } 55 56 virtual uint32_t 57 GetPluginVersion() 58 { 59 return 1; 60 } 61 62 63 //------------------------------------------------------------ 64 // lldb_private::Platform functions 65 //------------------------------------------------------------ 66 virtual lldb_private::Error 67 ResolveExecutable (const lldb_private::FileSpec &exe_file, 68 const lldb_private::ArchSpec &arch, 69 lldb::ModuleSP &module_sp, 70 const lldb_private::FileSpecList *module_search_paths_ptr); 71 72 virtual const char * 73 GetDescription (); 74 75 virtual lldb_private::Error 76 GetFile (const lldb_private::FileSpec &platform_file, 77 const lldb_private::UUID *uuid_ptr, 78 lldb_private::FileSpec &local_file); 79 80 virtual bool 81 GetProcessInfo (lldb::pid_t pid, 82 lldb_private::ProcessInstanceInfo &proc_info); 83 84 virtual uint32_t 85 FindProcesses (const lldb_private::ProcessInstanceInfoMatch &match_info, 86 lldb_private::ProcessInstanceInfoList &process_infos); 87 88 virtual lldb_private::Error 89 LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info); 90 91 virtual lldb::ProcessSP 92 Attach (lldb_private::ProcessAttachInfo &attach_info, 93 lldb_private::Debugger &debugger, 94 lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one 95 lldb_private::Listener &listener, 96 lldb_private::Error &error); 97 98 virtual bool 99 GetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch); 100 101 virtual size_t 102 GetSoftwareBreakpointTrapOpcode (lldb_private::Target &target, 103 lldb_private::BreakpointSite *bp_site); 104 105 virtual bool 106 GetRemoteOSVersion (); 107 108 virtual bool 109 GetRemoteOSBuildString (std::string &s); 110 111 virtual bool 112 GetRemoteOSKernelDescription (std::string &s); 113 114 // Remote Platform subclasses need to override this function 115 virtual lldb_private::ArchSpec 116 GetRemoteSystemArchitecture (); 117 118 // Remote subclasses should override this and return a valid instance 119 // name if connected. 120 virtual const char * 121 GetHostname (); 122 123 virtual const char * 124 GetUserName (uint32_t uid); 125 126 virtual const char * 127 GetGroupName (uint32_t gid); 128 129 virtual bool 130 IsConnected () const; 131 132 virtual lldb_private::Error 133 ConnectRemote (lldb_private::Args& args); 134 135 virtual lldb_private::Error 136 DisconnectRemote (); 137 138 virtual uint32_t 139 MakeDirectory (const std::string &path, 140 mode_t mode); 141 142 virtual lldb::user_id_t 143 OpenFile (const lldb_private::FileSpec& file_spec, 144 uint32_t flags, 145 mode_t mode, 146 lldb_private::Error &error); 147 148 virtual bool 149 CloseFile (lldb::user_id_t fd, 150 lldb_private::Error &error); 151 152 virtual uint64_t 153 ReadFile (lldb::user_id_t fd, 154 uint64_t offset, 155 void *data_ptr, 156 uint64_t len, 157 lldb_private::Error &error); 158 159 virtual uint64_t 160 WriteFile (lldb::user_id_t fd, 161 uint64_t offset, 162 const void* data, 163 uint64_t len, 164 lldb_private::Error &error); 165 166 virtual lldb::user_id_t 167 GetFileSize (const lldb_private::FileSpec& file_spec); 168 169 virtual lldb_private::Error 170 PutFile (const lldb_private::FileSpec& source, 171 const lldb_private::FileSpec& destination, 172 uint32_t uid = UINT32_MAX, 173 uint32_t gid = UINT32_MAX); 174 175 virtual bool 176 GetFileExists (const lldb_private::FileSpec& file_spec); 177 178 virtual uint32_t 179 GetFilePermissions (const lldb_private::FileSpec &file_spec, 180 lldb_private::Error &error); 181 182 virtual lldb_private::Error 183 RunShellCommand (const char *command, // Shouldn't be NULL 184 const char *working_dir, // Pass NULL to use the current working directory 185 int *status_ptr, // Pass NULL if you don't want the process exit status 186 int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit 187 std::string *command_output, // Pass NULL if you don't want the command output 188 uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish 189 190 protected: 191 GDBRemoteCommunicationClient m_gdb_client; 192 std::string m_platform_description; // After we connect we can get a more complete description of what we are connected to 193 194 private: 195 DISALLOW_COPY_AND_ASSIGN (PlatformRemoteGDBServer); 196 197 }; 198 199 #endif // liblldb_PlatformRemoteGDBServer_h_ 200