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 error.SetErrorStringWithFormat(
"'src' argument doesn't exist: '%s'",
537 return platform_sp->Install(src.
ref(), dst.
ref());
540 error.SetErrorStringWithFormat(
"'src' argument doesn't exist: '%s'",
550 const char *command = shell_command.
GetCommand();
552 return Status(
"invalid shell command (empty)");
555 std::string platform_working_dir =
556 platform_sp->GetWorkingDirectory().GetPath();
557 if (!platform_working_dir.empty())
558 shell_command.SetWorkingDirectory(platform_working_dir.c_str());
560 return platform_sp->RunShellCommand(
586 if (platform_sp->IsConnected()) {
589 ProcessSP process_sp = platform_sp->Attach(info, debugger.
ref(),
590 target.
GetSP().get(), status);
591 error.SetError(status);
595 error.SetErrorString(
"not connected");
599 error.SetErrorString(
"invalid platform");
605 if (platform_sp->IsConnected()) {
609 error.SetErrorString(
"not connected");
613 error.SetErrorString(
"invalid platform");
620 return platform_sp->KillProcess(pid);
627 const auto platform_sp(
GetSP());
629 if (platform_sp->IsConnected())
630 sb_error.
ref() = func(platform_sp);
646 platform_sp->MakeDirectory(
FileSpec(path), file_permissions);
658 uint32_t file_permissions = 0;
659 platform_sp->GetFilePermissions(
FileSpec(path), file_permissions);
660 return file_permissions;
666 uint32_t file_permissions) {
673 platform_sp->SetFilePermissions(
FileSpec(path), file_permissions);
683 if (
auto platform_sp =
GetSP())
705 return SBError(
"invalid platform");
709 platform_sp->SetLocateModuleCallback(
nullptr);
717 platform_sp->SetLocateModuleCallback(
718 [callback, callback_baton](
const ModuleSpec &module_spec,
725 SBError error = callback(callback_baton, module_spec_sb,
726 module_file_spec_sb, symbol_file_spec_sb);
728 if (
error.Success()) {
729 module_file_spec = module_file_spec_sb.
ref();
730 symbol_file_spec = symbol_file_spec_sb.
ref();
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT()
#define LLDB_INSTRUMENT_VA(...)
lldb_private::ProcessAttachInfo & ref()
lldb_private::Debugger & ref() const
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
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.
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