1 //===-- SBPlatform.h --------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SBPlatform_h_
10 #define LLDB_SBPlatform_h_
12 #include "lldb/API/SBDefines.h"
16 struct PlatformConnectOptions;
17 struct PlatformShellCommand;
23 class LLDB_API SBPlatformConnectOptions {
25 SBPlatformConnectOptions(const char *url);
27 SBPlatformConnectOptions(const SBPlatformConnectOptions &rhs);
29 ~SBPlatformConnectOptions();
31 void operator=(const SBPlatformConnectOptions &rhs);
35 void SetURL(const char *url);
37 bool GetRsyncEnabled();
39 void EnableRsync(const char *options, const char *remote_path_prefix,
40 bool omit_remote_hostname);
44 const char *GetLocalCacheDirectory();
46 void SetLocalCacheDirectory(const char *path);
49 PlatformConnectOptions *m_opaque_ptr;
52 class LLDB_API SBPlatformShellCommand {
54 SBPlatformShellCommand(const char *shell_command);
56 SBPlatformShellCommand(const SBPlatformShellCommand &rhs);
58 ~SBPlatformShellCommand();
62 const char *GetCommand();
64 void SetCommand(const char *shell_command);
66 const char *GetWorkingDirectory();
68 void SetWorkingDirectory(const char *path);
70 uint32_t GetTimeoutSeconds();
72 void SetTimeoutSeconds(uint32_t sec);
78 const char *GetOutput();
81 friend class SBPlatform;
83 PlatformShellCommand *m_opaque_ptr;
86 class LLDB_API SBPlatform {
90 SBPlatform(const char *platform_name);
94 explicit operator bool() const;
100 const char *GetWorkingDirectory();
102 bool SetWorkingDirectory(const char *path);
104 const char *GetName();
106 SBError ConnectRemote(SBPlatformConnectOptions &connect_options);
108 void DisconnectRemote();
112 // The following functions will work if the platform is connected
113 const char *GetTriple();
115 const char *GetHostname();
117 const char *GetOSBuild();
119 const char *GetOSDescription();
121 uint32_t GetOSMajorVersion();
123 uint32_t GetOSMinorVersion();
125 uint32_t GetOSUpdateVersion();
127 SBError Put(SBFileSpec &src, SBFileSpec &dst);
129 SBError Get(SBFileSpec &src, SBFileSpec &dst);
131 SBError Install(SBFileSpec &src, SBFileSpec &dst);
133 SBError Run(SBPlatformShellCommand &shell_command);
135 SBError Launch(SBLaunchInfo &launch_info);
137 SBError Kill(const lldb::pid_t pid);
140 MakeDirectory(const char *path,
141 uint32_t file_permissions = eFilePermissionsDirectoryDefault);
143 uint32_t GetFilePermissions(const char *path);
145 SBError SetFilePermissions(const char *path, uint32_t file_permissions);
147 SBUnixSignals GetUnixSignals() const;
150 friend class SBDebugger;
151 friend class SBTarget;
153 lldb::PlatformSP GetSP() const;
155 void SetSP(const lldb::PlatformSP &platform_sp);
157 SBError ExecuteConnected(
158 const std::function<lldb_private::Status(const lldb::PlatformSP &)>
161 lldb::PlatformSP m_opaque_sp;
166 #endif // LLDB_SBPlatform_h_