blob: 98291f18247dc707f397f66c44b6707ba8e76e95 [file] [log] [blame]
Pirama Arumuga Nainard285ad02022-02-08 09:26:56 -08001//===-- SBPlatform.h --------------------------------------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_API_SBPLATFORM_H
10#define LLDB_API_SBPLATFORM_H
11
12#include "lldb/API/SBDefines.h"
13
14#include <functional>
15
16struct PlatformConnectOptions;
17struct PlatformShellCommand;
18
19namespace lldb {
20
21class SBLaunchInfo;
22
23class LLDB_API SBPlatformConnectOptions {
24public:
25 SBPlatformConnectOptions(const char *url);
26
27 SBPlatformConnectOptions(const SBPlatformConnectOptions &rhs);
28
29 ~SBPlatformConnectOptions();
30
31 SBPlatformConnectOptions &operator=(const SBPlatformConnectOptions &rhs);
32
33 const char *GetURL();
34
35 void SetURL(const char *url);
36
37 bool GetRsyncEnabled();
38
39 void EnableRsync(const char *options, const char *remote_path_prefix,
40 bool omit_remote_hostname);
41
42 void DisableRsync();
43
44 const char *GetLocalCacheDirectory();
45
46 void SetLocalCacheDirectory(const char *path);
47
48protected:
49 PlatformConnectOptions *m_opaque_ptr;
50};
51
52class LLDB_API SBPlatformShellCommand {
53public:
54 SBPlatformShellCommand(const char *shell, const char *shell_command);
55 SBPlatformShellCommand(const char *shell_command);
56
57 SBPlatformShellCommand(const SBPlatformShellCommand &rhs);
58
59 SBPlatformShellCommand &operator=(const SBPlatformShellCommand &rhs);
60
61 ~SBPlatformShellCommand();
62
63 void Clear();
64
65 const char *GetShell();
66
67 void SetShell(const char *shell);
68
69 const char *GetCommand();
70
71 void SetCommand(const char *shell_command);
72
73 const char *GetWorkingDirectory();
74
75 void SetWorkingDirectory(const char *path);
76
77 uint32_t GetTimeoutSeconds();
78
79 void SetTimeoutSeconds(uint32_t sec);
80
81 int GetSignal();
82
83 int GetStatus();
84
85 const char *GetOutput();
86
87protected:
88 friend class SBPlatform;
89
90 PlatformShellCommand *m_opaque_ptr;
91};
92
93class LLDB_API SBPlatform {
94public:
95 SBPlatform();
96
97 SBPlatform(const char *platform_name);
98
99 SBPlatform(const SBPlatform &rhs);
100
101 SBPlatform &operator=(const SBPlatform &rhs);
102
103 ~SBPlatform();
104
105 static SBPlatform GetHostPlatform();
106
107 explicit operator bool() const;
108
109 bool IsValid() const;
110
111 void Clear();
112
113 const char *GetWorkingDirectory();
114
115 bool SetWorkingDirectory(const char *path);
116
117 const char *GetName();
118
119 SBError ConnectRemote(SBPlatformConnectOptions &connect_options);
120
121 void DisconnectRemote();
122
123 bool IsConnected();
124
125 // The following functions will work if the platform is connected
126 const char *GetTriple();
127
128 const char *GetHostname();
129
130 const char *GetOSBuild();
131
132 const char *GetOSDescription();
133
134 uint32_t GetOSMajorVersion();
135
136 uint32_t GetOSMinorVersion();
137
138 uint32_t GetOSUpdateVersion();
139
140 SBError Put(SBFileSpec &src, SBFileSpec &dst);
141
142 SBError Get(SBFileSpec &src, SBFileSpec &dst);
143
144 SBError Install(SBFileSpec &src, SBFileSpec &dst);
145
146 SBError Run(SBPlatformShellCommand &shell_command);
147
148 SBError Launch(SBLaunchInfo &launch_info);
149
150 SBError Kill(const lldb::pid_t pid);
151
152 SBError
153 MakeDirectory(const char *path,
154 uint32_t file_permissions = eFilePermissionsDirectoryDefault);
155
156 uint32_t GetFilePermissions(const char *path);
157
158 SBError SetFilePermissions(const char *path, uint32_t file_permissions);
159
160 SBUnixSignals GetUnixSignals() const;
161
162 /// Return the environment variables of the remote platform connection
163 /// process.
164 ///
165 /// \return
166 /// An lldb::SBEnvironment object which is a copy of the platform's
167 /// environment.
168 SBEnvironment GetEnvironment();
169
170protected:
171 friend class SBDebugger;
172 friend class SBTarget;
173
174 lldb::PlatformSP GetSP() const;
175
176 void SetSP(const lldb::PlatformSP &platform_sp);
177
178 SBError ExecuteConnected(
179 const std::function<lldb_private::Status(const lldb::PlatformSP &)>
180 &func);
181
182 lldb::PlatformSP m_opaque_sp;
183};
184
185} // namespace lldb
186
187#endif // LLDB_API_SBPLATFORM_H