LLDB mainline
SBPlatform.h
Go to the documentation of this file.
1//===-- 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#include "lldb/API/SBProcess.h"
15
16#include <functional>
17
20class ProcessInstanceInfoMatch;
21
22namespace lldb {
23
24class SBAttachInfo;
25class SBLaunchInfo;
26
28public:
29 SBPlatformConnectOptions(const char *url);
30
32
34
36
37 const char *GetURL();
38
39 void SetURL(const char *url);
40
41 bool GetRsyncEnabled();
42
43 void EnableRsync(const char *options, const char *remote_path_prefix,
44 bool omit_remote_hostname);
45
46 void DisableRsync();
47
48 const char *GetLocalCacheDirectory();
49
50 void SetLocalCacheDirectory(const char *path);
51
52protected:
54};
55
57public:
58 SBPlatformShellCommand(const char *shell, const char *shell_command);
59 SBPlatformShellCommand(const char *shell_command);
60
62
64
66
67 void Clear();
68
69 const char *GetShell();
70
71 void SetShell(const char *shell);
72
73 const char *GetCommand();
74
75 void SetCommand(const char *shell_command);
76
77 const char *GetWorkingDirectory();
78
79 void SetWorkingDirectory(const char *path);
80
81 uint32_t GetTimeoutSeconds();
82
83 void SetTimeoutSeconds(uint32_t sec);
84
85 int GetSignal();
86
87 int GetStatus();
88
89 const char *GetOutput();
90
91protected:
92 friend class SBPlatform;
93
95};
96
98public:
99 SBPlatform();
100
101 SBPlatform(const char *platform_name);
102
103 SBPlatform(const SBPlatform &rhs);
104
105 SBPlatform &operator=(const SBPlatform &rhs);
106
108
109 static SBPlatform GetHostPlatform();
110
111 explicit operator bool() const;
112
113 bool IsValid() const;
114
115 void Clear();
116
117 const char *GetWorkingDirectory();
118
119 bool SetWorkingDirectory(const char *path);
120
121 const char *GetName();
122
123 SBError ConnectRemote(SBPlatformConnectOptions &connect_options);
124
125 void DisconnectRemote();
126
127 bool IsConnected();
128
129 // The following functions will work if the platform is connected
130 const char *GetTriple();
131
132 const char *GetHostname();
133
134 const char *GetOSBuild();
135
136 const char *GetOSDescription();
137
138 uint32_t GetOSMajorVersion();
139
140 uint32_t GetOSMinorVersion();
141
142 uint32_t GetOSUpdateVersion();
143
144 void SetSDKRoot(const char *sysroot);
145
146 SBError Put(SBFileSpec &src, SBFileSpec &dst);
147
148 SBError Get(SBFileSpec &src, SBFileSpec &dst);
149
150 SBError Install(SBFileSpec &src, SBFileSpec &dst);
151
152 SBError Run(SBPlatformShellCommand &shell_command);
153
154 SBError Launch(SBLaunchInfo &launch_info);
155
156 SBProcess Attach(SBAttachInfo &attach_info, const SBDebugger &debugger,
157 SBTarget &target, SBError &error);
158
159 SBProcessInfoList GetAllProcesses(SBError &error);
160
161 SBError Kill(const lldb::pid_t pid);
162
163 SBError
164 MakeDirectory(const char *path,
165 uint32_t file_permissions = eFilePermissionsDirectoryDefault);
166
167 uint32_t GetFilePermissions(const char *path);
168
169 SBError SetFilePermissions(const char *path, uint32_t file_permissions);
170
171 SBUnixSignals GetUnixSignals() const;
172
173 /// Return the environment variables of the remote platform connection
174 /// process.
175 ///
176 /// \return
177 /// An lldb::SBEnvironment object which is a copy of the platform's
178 /// environment.
179 SBEnvironment GetEnvironment();
180
181 /// Set a callback as an implementation for locating module in order to
182 /// implement own module cache system. For example, to leverage distributed
183 /// build system, to bypass pulling files from remote platform, or to search
184 /// symbol files from symbol servers. The target will call this callback to
185 /// get a module file and a symbol file, and it will fallback to the LLDB
186 /// implementation when this callback failed or returned non-existent file.
187 /// This callback can set either module_file_spec or symbol_file_spec, or both
188 /// module_file_spec and symbol_file_spec. The callback will be cleared if
189 /// nullptr or None is set.
190 SBError SetLocateModuleCallback(lldb::SBPlatformLocateModuleCallback callback,
191 void *callback_baton);
192
193protected:
194 friend class SBDebugger;
195 friend class SBTarget;
196
197 lldb::PlatformSP GetSP() const;
198
199 void SetSP(const lldb::PlatformSP &platform_sp);
200
201 SBError ExecuteConnected(
202 const std::function<lldb_private::Status(const lldb::PlatformSP &)>
203 &func);
204
206};
207
208} // namespace lldb
209
210#endif // LLDB_API_SBPLATFORM_H
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_API
Definition: SBDefines.h:28
static llvm::StringRef GetName(XcodeSDK::Type type)
Definition: XcodeSDK.cpp:21
PlatformConnectOptions * m_opaque_ptr
Definition: SBPlatform.h:53
PlatformShellCommand * m_opaque_ptr
Definition: SBPlatform.h:94
lldb::PlatformSP m_opaque_sp
Definition: SBPlatform.h:205
An error handling class.
Definition: Status.h:115
Definition: SBAddress.h:15
lldb::SBError(* SBPlatformLocateModuleCallback)(void *baton, const lldb::SBModuleSpec &module_spec, lldb::SBFileSpec &module_file_spec, lldb::SBFileSpec &symbol_file_spec)
Definition: SBDefines.h:146
std::shared_ptr< lldb_private::Platform > PlatformSP
Definition: lldb-forward.h:388
class LLDB_API SBAttachInfo
Definition: SBDefines.h:48
uint64_t pid_t
Definition: lldb-types.h:83
class LLDB_API SBLaunchInfo
Definition: SBDefines.h:84