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_
16 #include "lldb/Interpreter/Options.h"
17 #include "lldb/Target/Platform.h"
19 class PlatformPOSIX : public lldb_private::Platform {
21 PlatformPOSIX(bool is_host);
23 ~PlatformPOSIX() override;
25 //------------------------------------------------------------
26 // lldb_private::Platform functions
27 //------------------------------------------------------------
29 bool GetModuleSpec(const lldb_private::FileSpec &module_file_spec,
30 const lldb_private::ArchSpec &arch,
31 lldb_private::ModuleSpec &module_spec) override;
33 lldb_private::OptionGroupOptions *
34 GetConnectionOptions(lldb_private::CommandInterpreter &interpreter) override;
36 const char *GetHostname() override;
38 const char *GetUserName(uint32_t uid) override;
40 const char *GetGroupName(uint32_t gid) override;
42 lldb_private::Status PutFile(const lldb_private::FileSpec &source,
43 const lldb_private::FileSpec &destination,
44 uint32_t uid = UINT32_MAX,
45 uint32_t gid = UINT32_MAX) override;
47 lldb::user_id_t OpenFile(const lldb_private::FileSpec &file_spec,
48 uint32_t flags, uint32_t mode,
49 lldb_private::Status &error) override;
51 bool CloseFile(lldb::user_id_t fd, lldb_private::Status &error) override;
53 uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
54 uint64_t dst_len, lldb_private::Status &error) override;
56 uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
57 uint64_t src_len, lldb_private::Status &error) override;
59 lldb::user_id_t GetFileSize(const lldb_private::FileSpec &file_spec) override;
62 CreateSymlink(const lldb_private::FileSpec &src,
63 const lldb_private::FileSpec &dst) override;
66 GetFile(const lldb_private::FileSpec &source,
67 const lldb_private::FileSpec &destination) override;
69 lldb_private::FileSpec GetRemoteWorkingDirectory() override;
72 SetRemoteWorkingDirectory(const lldb_private::FileSpec &working_dir) override;
74 bool GetRemoteOSVersion() override;
76 bool GetRemoteOSBuildString(std::string &s) override;
78 bool GetRemoteOSKernelDescription(std::string &s) override;
80 lldb_private::ArchSpec GetRemoteSystemArchitecture() override;
82 const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
84 lldb_private::Environment GetEnvironment() override;
86 bool IsConnected() const override;
88 lldb_private::Status RunShellCommand(
89 const char *command, // Shouldn't be nullptr
90 const lldb_private::FileSpec &working_dir, // Pass empty FileSpec to use
91 // the current working
93 int *status_ptr, // Pass nullptr if you don't want the process exit status
94 int *signo_ptr, // Pass nullptr if you don't want the signal that caused
95 // the process to exit
97 *command_output, // Pass nullptr if you don't want the command output
98 const lldb_private::Timeout<std::micro> &timeout) override;
100 lldb_private::Status ResolveExecutable(
101 const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
102 const lldb_private::FileSpecList *module_search_paths_ptr) override;
105 GetFileWithUUID(const lldb_private::FileSpec &platform_file,
106 const lldb_private::UUID *uuid,
107 lldb_private::FileSpec &local_file) override;
109 bool GetProcessInfo(lldb::pid_t pid, lldb_private::ProcessInstanceInfo &proc_info) override;
111 uint32_t FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
112 lldb_private::ProcessInstanceInfoList &process_infos) override;
114 lldb_private::Status MakeDirectory(const lldb_private::FileSpec &file_spec,
115 uint32_t mode) override;
118 GetFilePermissions(const lldb_private::FileSpec &file_spec,
119 uint32_t &file_permissions) override;
122 SetFilePermissions(const lldb_private::FileSpec &file_spec,
123 uint32_t file_permissions) override;
125 bool GetFileExists(const lldb_private::FileSpec &file_spec) override;
127 lldb_private::Status Unlink(const lldb_private::FileSpec &file_spec) override;
130 LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
132 lldb_private::Status KillProcess(const lldb::pid_t pid) override;
134 lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info,
135 lldb_private::Debugger &debugger,
136 lldb_private::Target *target, // Can be nullptr, if
137 // nullptr create a new
140 lldb_private::Status &error) override;
142 lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
143 lldb_private::Debugger &debugger,
144 lldb_private::Target *target, // Can be nullptr,
149 lldb_private::Status &error) override;
151 std::string GetPlatformSpecificConnectionInformation() override;
153 bool CalculateMD5(const lldb_private::FileSpec &file_spec, uint64_t &low,
154 uint64_t &high) override;
156 void CalculateTrapHandlerSymbolNames() override;
158 lldb_private::Status ConnectRemote(lldb_private::Args &args) override;
160 lldb_private::Status DisconnectRemote() override;
162 uint32_t DoLoadImage(lldb_private::Process *process,
163 const lldb_private::FileSpec &remote_file,
164 const std::vector<std::string> *paths,
165 lldb_private::Status &error,
166 lldb_private::FileSpec *loaded_image) override;
168 lldb_private::Status UnloadImage(lldb_private::Process *process,
169 uint32_t image_token) override;
171 lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
172 llvm::StringRef plugin_name,
173 lldb_private::Debugger &debugger,
174 lldb_private::Target *target,
175 lldb_private::Status &error) override;
177 size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
178 lldb_private::Status &error) override;
180 lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override;
183 std::unique_ptr<lldb_private::OptionGroupPlatformRSync>
184 m_option_group_platform_rsync;
185 std::unique_ptr<lldb_private::OptionGroupPlatformSSH>
186 m_option_group_platform_ssh;
187 std::unique_ptr<lldb_private::OptionGroupPlatformCaching>
188 m_option_group_platform_caching;
190 std::map<lldb_private::CommandInterpreter *,
191 std::unique_ptr<lldb_private::OptionGroupOptions>>
193 lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a
194 // remote POSIX-compliant OS
197 EvaluateLibdlExpression(lldb_private::Process *process, const char *expr_cstr,
198 llvm::StringRef expr_prefix,
199 lldb::ValueObjectSP &result_valobj_sp);
201 std::unique_ptr<lldb_private::UtilityFunction>
202 MakeLoadImageUtilityFunction(lldb_private::ExecutionContext &exe_ctx,
203 lldb_private::Status &error);
206 llvm::StringRef GetLibdlFunctionDeclarations(lldb_private::Process *process);
209 DISALLOW_COPY_AND_ASSIGN(PlatformPOSIX);
212 #endif // liblldb_PlatformPOSIX_h_