PlatformRemoteGDBServer.h revision 269024
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 22class PlatformRemoteGDBServer : public lldb_private::Platform 23{ 24public: 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 GetFileWithUUID (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 DebugProcess (lldb_private::ProcessLaunchInfo &launch_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 lldb::ProcessSP 99 Attach (lldb_private::ProcessAttachInfo &attach_info, 100 lldb_private::Debugger &debugger, 101 lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one 102 lldb_private::Listener &listener, 103 lldb_private::Error &error); 104 105 virtual bool 106 GetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch); 107 108 virtual size_t 109 GetSoftwareBreakpointTrapOpcode (lldb_private::Target &target, 110 lldb_private::BreakpointSite *bp_site); 111 112 virtual bool 113 GetRemoteOSVersion (); 114 115 virtual bool 116 GetRemoteOSBuildString (std::string &s); 117 118 virtual bool 119 GetRemoteOSKernelDescription (std::string &s); 120 121 // Remote Platform subclasses need to override this function 122 virtual lldb_private::ArchSpec 123 GetRemoteSystemArchitecture (); 124 125 virtual lldb_private::ConstString 126 GetRemoteWorkingDirectory(); 127 128 virtual bool 129 SetRemoteWorkingDirectory(const lldb_private::ConstString &path); 130 131 132 // Remote subclasses should override this and return a valid instance 133 // name if connected. 134 virtual const char * 135 GetHostname (); 136 137 virtual const char * 138 GetUserName (uint32_t uid); 139 140 virtual const char * 141 GetGroupName (uint32_t gid); 142 143 virtual bool 144 IsConnected () const; 145 146 virtual lldb_private::Error 147 ConnectRemote (lldb_private::Args& args); 148 149 virtual lldb_private::Error 150 DisconnectRemote (); 151 152 virtual lldb_private::Error 153 MakeDirectory (const char *path, uint32_t file_permissions); 154 155 virtual lldb_private::Error 156 GetFilePermissions (const char *path, uint32_t &file_permissions); 157 158 virtual lldb_private::Error 159 SetFilePermissions (const char *path, uint32_t file_permissions); 160 161 162 virtual lldb::user_id_t 163 OpenFile (const lldb_private::FileSpec& file_spec, 164 uint32_t flags, 165 uint32_t mode, 166 lldb_private::Error &error); 167 168 virtual bool 169 CloseFile (lldb::user_id_t fd, 170 lldb_private::Error &error); 171 172 virtual uint64_t 173 ReadFile (lldb::user_id_t fd, 174 uint64_t offset, 175 void *data_ptr, 176 uint64_t len, 177 lldb_private::Error &error); 178 179 virtual uint64_t 180 WriteFile (lldb::user_id_t fd, 181 uint64_t offset, 182 const void* data, 183 uint64_t len, 184 lldb_private::Error &error); 185 186 virtual lldb::user_id_t 187 GetFileSize (const lldb_private::FileSpec& file_spec); 188 189 virtual lldb_private::Error 190 PutFile (const lldb_private::FileSpec& source, 191 const lldb_private::FileSpec& destination, 192 uint32_t uid = UINT32_MAX, 193 uint32_t gid = UINT32_MAX); 194 195 virtual lldb_private::Error 196 CreateSymlink (const char *src, const char *dst); 197 198 virtual bool 199 GetFileExists (const lldb_private::FileSpec& file_spec); 200 201 virtual lldb_private::Error 202 Unlink (const char *path); 203 204 virtual lldb_private::Error 205 RunShellCommand (const char *command, // Shouldn't be NULL 206 const char *working_dir, // Pass NULL to use the current working directory 207 int *status_ptr, // Pass NULL if you don't want the process exit status 208 int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit 209 std::string *command_output, // Pass NULL if you don't want the command output 210 uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish 211 212 virtual void 213 CalculateTrapHandlerSymbolNames (); 214 215protected: 216 GDBRemoteCommunicationClient m_gdb_client; 217 std::string m_platform_description; // After we connect we can get a more complete description of what we are connected to 218 219private: 220 DISALLOW_COPY_AND_ASSIGN (PlatformRemoteGDBServer); 221 222}; 223 224#endif // liblldb_PlatformRemoteGDBServer_h_ 225