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