28#include "llvm/Support/FileSystem.h"
55 llvm::StringRef shell_command) {
56 if (!shell_interpreter.empty())
57 m_shell = shell_interpreter.str();
59 if (!
m_shell.empty() && !shell_command.empty())
64 if (!shell_command.empty())
126 const char *options,
const char *remote_path_prefix,
127 bool omit_hostname_from_remote_path) {
129 omit_hostname_from_remote_path);
133 omit_hostname_from_remote_path;
134 if (remote_path_prefix && remote_path_prefix[0])
139 if (options && options[0])
168 const char *shell_command)
216 if (shell_interpreter && shell_interpreter[0])
233 if (shell_command && shell_command[0])
322 return host_platform;
327 return this->
operator bool();
329SBPlatform::operator bool()
const {
332 return m_opaque_sp.get() !=
nullptr;
361 return platform_sp->GetWorkingDirectory().GetPathAsConstString().AsCString();
371 platform_sp->SetWorkingDirectory(
FileSpec(path));
373 platform_sp->SetWorkingDirectory(
FileSpec());
384 if (platform_sp && connect_options.
GetURL()) {
387 sb_error.
ref() = platform_sp->ConnectRemote(args);
399 platform_sp->DisconnectRemote();
407 return platform_sp->IsConnected();
416 ArchSpec arch(platform_sp->GetSystemArchitecture());
431 std::string s = platform_sp->GetOSBuildString().value_or(
"");
446 std::string s = platform_sp->GetOSKernelDescription().value_or(
"");
468 llvm::VersionTuple version;
470 version = platform_sp->GetOSVersion();
471 return version.empty() ?
UINT32_MAX : version.getMajor();
477 llvm::VersionTuple version;
479 version = platform_sp->GetOSVersion();
480 return version.getMinor().value_or(
UINT32_MAX);
486 llvm::VersionTuple version;
488 version = platform_sp->GetOSVersion();
489 return version.getSubminor().value_or(
UINT32_MAX);
495 platform_sp->SetSDKRootDirectory(llvm::StringRef(sysroot).str());
504 sb_error.
ref() = platform_sp->GetFile(src.
ref(), dst.
ref());
515 uint32_t permissions = FileSystem::Instance().GetPermissions(src.ref());
516 if (permissions == 0) {
517 if (FileSystem::Instance().IsDirectory(src.ref()))
518 permissions = eFilePermissionsDirectoryDefault;
520 permissions = eFilePermissionsFileDefault;
523 return platform_sp->PutFile(src.
ref(), dst.
ref(), permissions);
527 "'src' argument doesn't exist: '%s'", src.
ref().
GetPath().c_str());
535 return platform_sp->Install(src.
ref(), dst.
ref());
539 "'src' argument doesn't exist: '%s'", src.
ref().
GetPath().c_str());
548 const char *command = shell_command.
GetCommand();
553 std::string platform_working_dir =
554 platform_sp->GetWorkingDirectory().GetPath();
555 if (!platform_working_dir.empty())
556 shell_command.SetWorkingDirectory(platform_working_dir.c_str());
558 return platform_sp->RunShellCommand(
584 if (platform_sp->IsConnected()) {
587 ProcessSP process_sp = platform_sp->Attach(info, debugger.
ref(),
588 target.
GetSP().get(), status);
589 error.SetError(std::move(status));
603 if (platform_sp->IsConnected()) {
618 return platform_sp->KillProcess(pid);
625 const auto platform_sp(
GetSP());
627 if (platform_sp->IsConnected())
628 sb_error.
ref() = func(platform_sp);
644 platform_sp->MakeDirectory(
FileSpec(path), file_permissions);
656 uint32_t file_permissions = 0;
657 platform_sp->GetFilePermissions(
FileSpec(path), file_permissions);
658 return file_permissions;
664 uint32_t file_permissions) {
671 platform_sp->SetFilePermissions(
FileSpec(path), file_permissions);
681 if (
auto platform_sp =
GetSP())
703 return SBError(
"invalid platform");
707 platform_sp->SetLocateModuleCallback(
nullptr);
715 platform_sp->SetLocateModuleCallback(
716 [callback, callback_baton](
const ModuleSpec &module_spec,
723 SBError error = callback(callback_baton, module_spec_sb,
724 module_file_spec_sb, symbol_file_spec_sb);
726 if (
error.Success()) {
727 module_file_spec = module_file_spec_sb.
ref();
728 symbol_file_spec = symbol_file_spec_sb.
ref();
731 return error.ref().Clone();
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT()
#define LLDB_INSTRUMENT_VA(...)
lldb_private::ProcessAttachInfo & ref()
lldb_private::Debugger & ref() const
lldb_private::Status & ref()
const lldb_private::FileSpec & ref() const
void set_ref(const lldb_private::ProcessLaunchInfo &info)
const lldb_private::ProcessLaunchInfo & ref() const
lldb::TargetSP GetSP() 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.
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
A class that represents a running process on the host machine.
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
lldb::SBError(* SBPlatformLocateModuleCallback)(void *baton, const lldb::SBModuleSpec &module_spec, lldb::SBFileSpec &module_file_spec, lldb::SBFileSpec &symbol_file_spec)
std::shared_ptr< lldb_private::Platform > PlatformSP
std::shared_ptr< lldb_private::Process > ProcessSP