1 //===-- PlatformPOSIX.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_PlatformPOSIX_h_ 11 #define liblldb_PlatformPOSIX_h_ 12 13 // C Includes 14 // C++ Includes 15 #include <map> 16 #include <memory> 17 18 // Other libraries and framework includes 19 // Project includes 20 #include "lldb/Interpreter/Options.h" 21 #include "lldb/Target/Platform.h" 22 23 class PlatformPOSIX : public lldb_private::Platform { 24 public: 25 PlatformPOSIX(bool is_host); 26 27 ~PlatformPOSIX() override; 28 29 //------------------------------------------------------------ 30 // lldb_private::Platform functions 31 //------------------------------------------------------------ 32 33 bool GetModuleSpec(const lldb_private::FileSpec &module_file_spec, 34 const lldb_private::ArchSpec &arch, 35 lldb_private::ModuleSpec &module_spec) override; 36 37 lldb_private::OptionGroupOptions * 38 GetConnectionOptions(lldb_private::CommandInterpreter &interpreter) override; 39 40 const char *GetHostname() override; 41 42 const char *GetUserName(uint32_t uid) override; 43 44 const char *GetGroupName(uint32_t gid) override; 45 46 lldb_private::Error PutFile(const lldb_private::FileSpec &source, 47 const lldb_private::FileSpec &destination, 48 uint32_t uid = UINT32_MAX, 49 uint32_t gid = UINT32_MAX) override; 50 51 lldb::user_id_t OpenFile(const lldb_private::FileSpec &file_spec, 52 uint32_t flags, uint32_t mode, 53 lldb_private::Error &error) override; 54 55 bool CloseFile(lldb::user_id_t fd, lldb_private::Error &error) override; 56 57 uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, 58 uint64_t dst_len, lldb_private::Error &error) override; 59 60 uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, 61 uint64_t src_len, lldb_private::Error &error) override; 62 63 lldb::user_id_t GetFileSize(const lldb_private::FileSpec &file_spec) override; 64 65 lldb_private::Error CreateSymlink(const lldb_private::FileSpec &src, 66 const lldb_private::FileSpec &dst) override; 67 68 lldb_private::Error 69 GetFile(const lldb_private::FileSpec &source, 70 const lldb_private::FileSpec &destination) override; 71 72 lldb_private::FileSpec GetRemoteWorkingDirectory() override; 73 74 bool 75 SetRemoteWorkingDirectory(const lldb_private::FileSpec &working_dir) override; 76 77 bool GetRemoteOSVersion() override; 78 79 bool GetRemoteOSBuildString(std::string &s) override; 80 81 bool GetRemoteOSKernelDescription(std::string &s) override; 82 83 lldb_private::ArchSpec GetRemoteSystemArchitecture() override; 84 85 const lldb::UnixSignalsSP &GetRemoteUnixSignals() override; 86 87 size_t GetEnvironment(lldb_private::StringList &environment) override; 88 89 bool IsConnected() const override; 90 91 lldb_private::Error RunShellCommand( 92 const char *command, // Shouldn't be nullptr 93 const lldb_private::FileSpec &working_dir, // Pass empty FileSpec to use 94 // the current working 95 // directory 96 int *status_ptr, // Pass nullptr if you don't want the process exit status 97 int *signo_ptr, // Pass nullptr if you don't want the signal that caused 98 // the process to exit 99 std::string 100 *command_output, // Pass nullptr if you don't want the command output 101 uint32_t timeout_sec) 102 override; // Timeout in seconds to wait for shell program to finish 103 104 lldb_private::Error MakeDirectory(const lldb_private::FileSpec &file_spec, 105 uint32_t mode) override; 106 107 lldb_private::Error 108 GetFilePermissions(const lldb_private::FileSpec &file_spec, 109 uint32_t &file_permissions) override; 110 111 lldb_private::Error 112 SetFilePermissions(const lldb_private::FileSpec &file_spec, 113 uint32_t file_permissions) override; 114 115 bool GetFileExists(const lldb_private::FileSpec &file_spec) override; 116 117 lldb_private::Error Unlink(const lldb_private::FileSpec &file_spec) override; 118 119 lldb_private::Error 120 LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override; 121 122 lldb_private::Error KillProcess(const lldb::pid_t pid) override; 123 124 lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info, 125 lldb_private::Debugger &debugger, 126 lldb_private::Target *target, // Can be nullptr, if 127 // nullptr create a new 128 // target, else use 129 // existing one 130 lldb_private::Error &error) override; 131 132 lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info, 133 lldb_private::Debugger &debugger, 134 lldb_private::Target *target, // Can be nullptr, 135 // if nullptr 136 // create a new 137 // target, else use 138 // existing one 139 lldb_private::Error &error) override; 140 141 std::string GetPlatformSpecificConnectionInformation() override; 142 143 bool CalculateMD5(const lldb_private::FileSpec &file_spec, uint64_t &low, 144 uint64_t &high) override; 145 146 void CalculateTrapHandlerSymbolNames() override; 147 148 lldb_private::Error ConnectRemote(lldb_private::Args &args) override; 149 150 lldb_private::Error DisconnectRemote() override; 151 152 uint32_t DoLoadImage(lldb_private::Process *process, 153 const lldb_private::FileSpec &remote_file, 154 lldb_private::Error &error) override; 155 156 lldb_private::Error UnloadImage(lldb_private::Process *process, 157 uint32_t image_token) override; 158 159 lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url, 160 llvm::StringRef plugin_name, 161 lldb_private::Debugger &debugger, 162 lldb_private::Target *target, 163 lldb_private::Error &error) override; 164 165 size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger, 166 lldb_private::Error &error) override; 167 168 protected: 169 std::unique_ptr<lldb_private::OptionGroupPlatformRSync> 170 m_option_group_platform_rsync; 171 std::unique_ptr<lldb_private::OptionGroupPlatformSSH> 172 m_option_group_platform_ssh; 173 std::unique_ptr<lldb_private::OptionGroupPlatformCaching> 174 m_option_group_platform_caching; 175 176 std::map<lldb_private::CommandInterpreter *, 177 std::unique_ptr<lldb_private::OptionGroupOptions>> 178 m_options; 179 lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a 180 // remote POSIX-compliant OS 181 182 lldb_private::Error 183 EvaluateLibdlExpression(lldb_private::Process *process, const char *expr_cstr, 184 const char *expr_prefix, 185 lldb::ValueObjectSP &result_valobj_sp); 186 187 virtual const char *GetLibdlFunctionDeclarations() const; 188 189 private: 190 DISALLOW_COPY_AND_ASSIGN(PlatformPOSIX); 191 }; 192 193 #endif // liblldb_PlatformPOSIX_h_ 194