1 //===-- PlatformPOSIX.h -----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_PlatformPOSIX_h_
11 #define liblldb_PlatformPOSIX_h_
18 // Other libraries and framework includes
20 #include "lldb/Interpreter/Options.h"
21 #include "lldb/Target/Platform.h"
23 class PlatformPOSIX : public lldb_private::Platform {
25 PlatformPOSIX(bool is_host);
27 ~PlatformPOSIX() override;
29 //------------------------------------------------------------
30 // lldb_private::Platform functions
31 //------------------------------------------------------------
33 bool GetModuleSpec(const lldb_private::FileSpec &module_file_spec,
34 const lldb_private::ArchSpec &arch,
35 lldb_private::ModuleSpec &module_spec) override;
37 lldb_private::OptionGroupOptions *
38 GetConnectionOptions(lldb_private::CommandInterpreter &interpreter) override;
40 const char *GetHostname() override;
42 const char *GetUserName(uint32_t uid) override;
44 const char *GetGroupName(uint32_t gid) override;
46 lldb_private::Status 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;
51 lldb::user_id_t OpenFile(const lldb_private::FileSpec &file_spec,
52 uint32_t flags, uint32_t mode,
53 lldb_private::Status &error) override;
55 bool CloseFile(lldb::user_id_t fd, lldb_private::Status &error) override;
57 uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
58 uint64_t dst_len, lldb_private::Status &error) override;
60 uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
61 uint64_t src_len, lldb_private::Status &error) override;
63 lldb::user_id_t GetFileSize(const lldb_private::FileSpec &file_spec) override;
66 CreateSymlink(const lldb_private::FileSpec &src,
67 const lldb_private::FileSpec &dst) override;
70 GetFile(const lldb_private::FileSpec &source,
71 const lldb_private::FileSpec &destination) override;
73 lldb_private::FileSpec GetRemoteWorkingDirectory() override;
76 SetRemoteWorkingDirectory(const lldb_private::FileSpec &working_dir) override;
78 bool GetRemoteOSVersion() override;
80 bool GetRemoteOSBuildString(std::string &s) override;
82 bool GetRemoteOSKernelDescription(std::string &s) override;
84 lldb_private::ArchSpec GetRemoteSystemArchitecture() override;
86 const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
88 size_t GetEnvironment(lldb_private::StringList &environment) override;
90 bool IsConnected() const override;
92 lldb_private::Status RunShellCommand(
93 const char *command, // Shouldn't be nullptr
94 const lldb_private::FileSpec &working_dir, // Pass empty FileSpec to use
95 // the current working
97 int *status_ptr, // Pass nullptr if you don't want the process exit status
98 int *signo_ptr, // Pass nullptr if you don't want the signal that caused
99 // the process to exit
101 *command_output, // Pass nullptr if you don't want the command output
102 uint32_t timeout_sec)
103 override; // Timeout in seconds to wait for shell program to finish
105 lldb_private::Status ResolveExecutable(
106 const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
107 const lldb_private::FileSpecList *module_search_paths_ptr) override;
110 GetFileWithUUID(const lldb_private::FileSpec &platform_file,
111 const lldb_private::UUID *uuid,
112 lldb_private::FileSpec &local_file) override;
114 bool GetProcessInfo(lldb::pid_t pid, lldb_private::ProcessInstanceInfo &proc_info) override;
116 uint32_t FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
117 lldb_private::ProcessInstanceInfoList &process_infos) override;
119 lldb_private::Status MakeDirectory(const lldb_private::FileSpec &file_spec,
120 uint32_t mode) override;
123 GetFilePermissions(const lldb_private::FileSpec &file_spec,
124 uint32_t &file_permissions) override;
127 SetFilePermissions(const lldb_private::FileSpec &file_spec,
128 uint32_t file_permissions) override;
130 bool GetFileExists(const lldb_private::FileSpec &file_spec) override;
132 lldb_private::Status Unlink(const lldb_private::FileSpec &file_spec) override;
135 LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
137 lldb_private::Status KillProcess(const lldb::pid_t pid) override;
139 lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info,
140 lldb_private::Debugger &debugger,
141 lldb_private::Target *target, // Can be nullptr, if
142 // nullptr create a new
145 lldb_private::Status &error) override;
147 lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
148 lldb_private::Debugger &debugger,
149 lldb_private::Target *target, // Can be nullptr,
154 lldb_private::Status &error) override;
156 std::string GetPlatformSpecificConnectionInformation() override;
158 bool CalculateMD5(const lldb_private::FileSpec &file_spec, uint64_t &low,
159 uint64_t &high) override;
161 void CalculateTrapHandlerSymbolNames() override;
163 lldb_private::Status ConnectRemote(lldb_private::Args &args) override;
165 lldb_private::Status DisconnectRemote() override;
167 uint32_t DoLoadImage(lldb_private::Process *process,
168 const lldb_private::FileSpec &remote_file,
169 lldb_private::Status &error) override;
171 lldb_private::Status UnloadImage(lldb_private::Process *process,
172 uint32_t image_token) override;
174 lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
175 llvm::StringRef plugin_name,
176 lldb_private::Debugger &debugger,
177 lldb_private::Target *target,
178 lldb_private::Status &error) override;
180 size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
181 lldb_private::Status &error) override;
183 lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override;
186 std::unique_ptr<lldb_private::OptionGroupPlatformRSync>
187 m_option_group_platform_rsync;
188 std::unique_ptr<lldb_private::OptionGroupPlatformSSH>
189 m_option_group_platform_ssh;
190 std::unique_ptr<lldb_private::OptionGroupPlatformCaching>
191 m_option_group_platform_caching;
193 std::map<lldb_private::CommandInterpreter *,
194 std::unique_ptr<lldb_private::OptionGroupOptions>>
196 lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a
197 // remote POSIX-compliant OS
200 EvaluateLibdlExpression(lldb_private::Process *process, const char *expr_cstr,
201 llvm::StringRef expr_prefix,
202 lldb::ValueObjectSP &result_valobj_sp);
205 llvm::StringRef GetLibdlFunctionDeclarations(lldb_private::Process *process);
208 DISALLOW_COPY_AND_ASSIGN(PlatformPOSIX);
211 #endif // liblldb_PlatformPOSIX_h_