24#include "llvm/Support/FileSystem.h"
51 llvm::StringRef shell_command) {
52 if (!shell_interpreter.empty())
53 m_shell = shell_interpreter.str();
55 if (!
m_shell.empty() && !shell_command.empty())
60 if (!shell_command.empty())
122 const char *options,
const char *remote_path_prefix,
123 bool omit_hostname_from_remote_path) {
125 omit_hostname_from_remote_path);
129 omit_hostname_from_remote_path;
130 if (remote_path_prefix && remote_path_prefix[0])
135 if (options && options[0])
164 const char *shell_command)
212 if (shell_interpreter && shell_interpreter[0])
229 if (shell_command && shell_command[0])
318 return host_platform;
323 return this->
operator bool();
325SBPlatform::operator bool()
const {
328 return m_opaque_sp.get() !=
nullptr;
340 PlatformSP platform_sp(
GetSP());
355 PlatformSP platform_sp(
GetSP());
357 return platform_sp->GetWorkingDirectory().GetPathAsConstString().AsCString();
364 PlatformSP platform_sp(
GetSP());
367 platform_sp->SetWorkingDirectory(
FileSpec(path));
369 platform_sp->SetWorkingDirectory(
FileSpec());
379 PlatformSP platform_sp(
GetSP());
380 if (platform_sp && connect_options.
GetURL()) {
383 sb_error.
ref() = platform_sp->ConnectRemote(args);
393 PlatformSP platform_sp(
GetSP());
395 platform_sp->DisconnectRemote();
401 PlatformSP platform_sp(
GetSP());
403 return platform_sp->IsConnected();
410 PlatformSP platform_sp(
GetSP());
412 ArchSpec arch(platform_sp->GetSystemArchitecture());
425 PlatformSP platform_sp(
GetSP());
427 std::string s = platform_sp->GetOSBuildString().value_or(
"");
440 PlatformSP platform_sp(
GetSP());
442 std::string s = platform_sp->GetOSKernelDescription().value_or(
"");
455 PlatformSP platform_sp(
GetSP());
464 llvm::VersionTuple version;
465 if (PlatformSP platform_sp =
GetSP())
466 version = platform_sp->GetOSVersion();
467 return version.empty() ?
UINT32_MAX : version.getMajor();
473 llvm::VersionTuple version;
474 if (PlatformSP platform_sp =
GetSP())
475 version = platform_sp->GetOSVersion();
476 return version.getMinor().value_or(
UINT32_MAX);
482 llvm::VersionTuple version;
483 if (PlatformSP platform_sp =
GetSP())
484 version = platform_sp->GetOSVersion();
485 return version.getSubminor().value_or(
UINT32_MAX);
490 if (PlatformSP platform_sp =
GetSP())
491 platform_sp->SetSDKRootDirectory(
ConstString(sysroot));
498 PlatformSP platform_sp(
GetSP());
500 sb_error.
ref() = platform_sp->GetFile(src.
ref(), dst.
ref());
511 uint32_t permissions = FileSystem::Instance().GetPermissions(src.ref());
512 if (permissions == 0) {
513 if (FileSystem::Instance().IsDirectory(src.ref()))
514 permissions = eFilePermissionsDirectoryDefault;
516 permissions = eFilePermissionsFileDefault;
519 return platform_sp->PutFile(src.
ref(), dst.
ref(), permissions);
523 error.SetErrorStringWithFormat(
"'src' argument doesn't exist: '%s'",
533 return platform_sp->Install(src.
ref(), dst.
ref());
536 error.SetErrorStringWithFormat(
"'src' argument doesn't exist: '%s'",
545 [&](
const lldb::PlatformSP &platform_sp) {
546 const char *command = shell_command.
GetCommand();
548 return Status(
"invalid shell command (empty)");
551 std::string platform_working_dir =
552 platform_sp->GetWorkingDirectory().GetPath();
553 if (!platform_working_dir.empty())
554 shell_command.SetWorkingDirectory(platform_working_dir.c_str());
556 return platform_sp->RunShellCommand(
579 return platform_sp->KillProcess(pid);
584 const std::function<
Status(
const lldb::PlatformSP &)> &func) {
586 const auto platform_sp(
GetSP());
588 if (platform_sp->IsConnected())
589 sb_error.
ref() = func(platform_sp);
602 PlatformSP platform_sp(
GetSP());
605 platform_sp->MakeDirectory(
FileSpec(path), file_permissions);
615 PlatformSP platform_sp(
GetSP());
618 platform_sp->GetFilePermissions(
FileSpec(path), file_permissions);
619 return file_permissions;
629 PlatformSP platform_sp(
GetSP());
632 platform_sp->SetFilePermissions(
FileSpec(path), file_permissions);
642 if (
auto platform_sp =
GetSP())
650 PlatformSP platform_sp(
GetSP());
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT()
#define LLDB_INSTRUMENT_VA(...)
void SetErrorString(const char *err_str)
lldb_private::Status & ref()
const lldb_private::FileSpec & ref() const
void set_ref(const lldb_private::ProcessLaunchInfo &info)
const lldb_private::ProcessLaunchInfo & ref() const
An architecture specification class.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
A command line argument class.
void AppendArgument(llvm::StringRef arg_str, char quote_char='\0')
Appends a new argument to the end of the list argument list.
A uniqued constant string class.
void SetCString(const char *cstr)
Set the C string value.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
const char * GetCString() const
Get the string value as a C string.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
A class that represents a running process on the host machine.