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::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;
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;
55 bool CloseFile(lldb::user_id_t fd, lldb_private::Error &error) override;
57 uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
58 uint64_t dst_len, lldb_private::Error &error) override;
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;
63 lldb::user_id_t GetFileSize(const lldb_private::FileSpec &file_spec) override;
65 lldb_private::Error CreateSymlink(const lldb_private::FileSpec &src,
66 const lldb_private::FileSpec &dst) override;
69 GetFile(const lldb_private::FileSpec &source,
70 const lldb_private::FileSpec &destination) override;
72 lldb_private::FileSpec GetRemoteWorkingDirectory() override;
75 SetRemoteWorkingDirectory(const lldb_private::FileSpec &working_dir) override;
77 bool GetRemoteOSVersion() override;
79 bool GetRemoteOSBuildString(std::string &s) override;
81 bool GetRemoteOSKernelDescription(std::string &s) override;
83 lldb_private::ArchSpec GetRemoteSystemArchitecture() override;
85 const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
87 size_t GetEnvironment(lldb_private::StringList &environment) override;
89 bool IsConnected() const override;
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
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
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
104 lldb_private::Error MakeDirectory(const lldb_private::FileSpec &file_spec,
105 uint32_t mode) override;
108 GetFilePermissions(const lldb_private::FileSpec &file_spec,
109 uint32_t &file_permissions) override;
112 SetFilePermissions(const lldb_private::FileSpec &file_spec,
113 uint32_t file_permissions) override;
115 bool GetFileExists(const lldb_private::FileSpec &file_spec) override;
117 lldb_private::Error Unlink(const lldb_private::FileSpec &file_spec) override;
120 LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
122 lldb_private::Error KillProcess(const lldb::pid_t pid) override;
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
130 lldb_private::Error &error) override;
132 lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
133 lldb_private::Debugger &debugger,
134 lldb_private::Target *target, // Can be nullptr,
139 lldb_private::Error &error) override;
141 std::string GetPlatformSpecificConnectionInformation() override;
143 bool CalculateMD5(const lldb_private::FileSpec &file_spec, uint64_t &low,
144 uint64_t &high) override;
146 void CalculateTrapHandlerSymbolNames() override;
148 lldb_private::Error ConnectRemote(lldb_private::Args &args) override;
150 lldb_private::Error DisconnectRemote() override;
152 uint32_t DoLoadImage(lldb_private::Process *process,
153 const lldb_private::FileSpec &remote_file,
154 lldb_private::Error &error) override;
156 lldb_private::Error UnloadImage(lldb_private::Process *process,
157 uint32_t image_token) override;
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;
165 size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
166 lldb_private::Error &error) override;
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;
176 std::map<lldb_private::CommandInterpreter *,
177 std::unique_ptr<lldb_private::OptionGroupOptions>>
179 lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a
180 // remote POSIX-compliant OS
183 EvaluateLibdlExpression(lldb_private::Process *process, const char *expr_cstr,
184 const char *expr_prefix,
185 lldb::ValueObjectSP &result_valobj_sp);
187 virtual const char *GetLibdlFunctionDeclarations() const;
190 DISALLOW_COPY_AND_ASSIGN(PlatformPOSIX);
193 #endif // liblldb_PlatformPOSIX_h_