forked from OSchip/llvm-project
[lldb-server] Add remote platform capabilities for Windows
Summary: Implement a few routines for Windows to support some basic process interaction and file system operations. Reviewers: zturner, llvm-commits, labath, jingham Reviewed By: labath Subscribers: emaste, jdoerfert, Hui, labath, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D56232 llvm-svn: 354010
This commit is contained in:
parent
023dd1eefa
commit
d504fe20e3
|
@ -21,6 +21,41 @@ public:
|
|||
|
||||
bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch,
|
||||
ModuleSpec &module_spec) override;
|
||||
|
||||
lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags,
|
||||
uint32_t mode, Status &error) override;
|
||||
|
||||
bool CloseFile(lldb::user_id_t fd, Status &error) override;
|
||||
|
||||
uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
|
||||
uint64_t dst_len, Status &error) override;
|
||||
|
||||
uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
|
||||
uint64_t src_len, Status &error) override;
|
||||
|
||||
lldb::user_id_t GetFileSize(const FileSpec &file_spec) override;
|
||||
|
||||
Status CreateSymlink(const FileSpec &src, const FileSpec &dst) override;
|
||||
|
||||
bool GetFileExists(const FileSpec &file_spec) override;
|
||||
|
||||
Status Unlink(const FileSpec &file_spec) override;
|
||||
|
||||
FileSpec GetRemoteWorkingDirectory() override;
|
||||
|
||||
bool SetRemoteWorkingDirectory(const FileSpec &working_dir) override;
|
||||
|
||||
Status MakeDirectory(const FileSpec &file_spec, uint32_t mode) override;
|
||||
|
||||
Status GetFilePermissions(const FileSpec &file_spec,
|
||||
uint32_t &file_permissions) override;
|
||||
|
||||
Status SetFilePermissions(const FileSpec &file_spec,
|
||||
uint32_t file_permissions) override;
|
||||
|
||||
bool CalculateMD5(const FileSpec &file_spec, uint64_t &low,
|
||||
uint64_t &high) override;
|
||||
|
||||
Status GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
|
||||
FileSpec &local_file) override;
|
||||
|
||||
|
@ -29,6 +64,11 @@ public:
|
|||
bool GetRemoteOSKernelDescription(std::string &s) override;
|
||||
ArchSpec GetRemoteSystemArchitecture() override;
|
||||
|
||||
Status RunShellCommand(const char *command, const FileSpec &working_dir,
|
||||
int *status_ptr, int *signo_ptr,
|
||||
std::string *command_output,
|
||||
const Timeout<std::micro> &timeout) override;
|
||||
|
||||
const char *GetHostname() override;
|
||||
const char *GetUserName(uint32_t uid) override;
|
||||
const char *GetGroupName(uint32_t gid) override;
|
||||
|
@ -39,8 +79,16 @@ public:
|
|||
bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
|
||||
uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
|
||||
ProcessInstanceInfoList &process_infos) override;
|
||||
|
||||
lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
|
||||
llvm::StringRef plugin_name,
|
||||
Debugger &debugger, Target *target,
|
||||
Status &error) override;
|
||||
|
||||
Status LaunchProcess(ProcessLaunchInfo &launch_info) override;
|
||||
|
||||
Status KillProcess(const lldb::pid_t pid) override;
|
||||
|
||||
protected:
|
||||
lldb::PlatformSP m_remote_platform_sp;
|
||||
};
|
||||
|
|
|
@ -68,28 +68,6 @@ lldb_private::OptionGroupOptions *PlatformPOSIX::GetConnectionOptions(
|
|||
return m_options.at(&interpreter).get();
|
||||
}
|
||||
|
||||
lldb_private::Status PlatformPOSIX::RunShellCommand(
|
||||
const char *command, // Shouldn't be NULL
|
||||
const FileSpec &
|
||||
working_dir, // Pass empty FileSpec to use the current working directory
|
||||
int *status_ptr, // Pass NULL if you don't want the process exit status
|
||||
int *signo_ptr, // Pass NULL if you don't want the signal that caused the
|
||||
// process to exit
|
||||
std::string
|
||||
*command_output, // Pass NULL if you don't want the command output
|
||||
const Timeout<std::micro> &timeout) {
|
||||
if (IsHost())
|
||||
return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr,
|
||||
command_output, timeout);
|
||||
else {
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->RunShellCommand(
|
||||
command, working_dir, status_ptr, signo_ptr, command_output, timeout);
|
||||
else
|
||||
return Status("unable to run a remote command without a platform");
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec,
|
||||
lldb::ModuleSP &exe_module_sp,
|
||||
|
@ -232,73 +210,6 @@ PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec,
|
|||
return error;
|
||||
}
|
||||
|
||||
Status PlatformPOSIX::MakeDirectory(const FileSpec &file_spec,
|
||||
uint32_t file_permissions) {
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->MakeDirectory(file_spec, file_permissions);
|
||||
else
|
||||
return Platform::MakeDirectory(file_spec, file_permissions);
|
||||
}
|
||||
|
||||
Status PlatformPOSIX::GetFilePermissions(const FileSpec &file_spec,
|
||||
uint32_t &file_permissions) {
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->GetFilePermissions(file_spec,
|
||||
file_permissions);
|
||||
else
|
||||
return Platform::GetFilePermissions(file_spec, file_permissions);
|
||||
}
|
||||
|
||||
Status PlatformPOSIX::SetFilePermissions(const FileSpec &file_spec,
|
||||
uint32_t file_permissions) {
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->SetFilePermissions(file_spec,
|
||||
file_permissions);
|
||||
else
|
||||
return Platform::SetFilePermissions(file_spec, file_permissions);
|
||||
}
|
||||
|
||||
lldb::user_id_t PlatformPOSIX::OpenFile(const FileSpec &file_spec,
|
||||
uint32_t flags, uint32_t mode,
|
||||
Status &error) {
|
||||
if (IsHost())
|
||||
return FileCache::GetInstance().OpenFile(file_spec, flags, mode, error);
|
||||
else if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->OpenFile(file_spec, flags, mode, error);
|
||||
else
|
||||
return Platform::OpenFile(file_spec, flags, mode, error);
|
||||
}
|
||||
|
||||
bool PlatformPOSIX::CloseFile(lldb::user_id_t fd, Status &error) {
|
||||
if (IsHost())
|
||||
return FileCache::GetInstance().CloseFile(fd, error);
|
||||
else if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->CloseFile(fd, error);
|
||||
else
|
||||
return Platform::CloseFile(fd, error);
|
||||
}
|
||||
|
||||
uint64_t PlatformPOSIX::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
|
||||
uint64_t dst_len, Status &error) {
|
||||
if (IsHost())
|
||||
return FileCache::GetInstance().ReadFile(fd, offset, dst, dst_len, error);
|
||||
else if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->ReadFile(fd, offset, dst, dst_len, error);
|
||||
else
|
||||
return Platform::ReadFile(fd, offset, dst, dst_len, error);
|
||||
}
|
||||
|
||||
uint64_t PlatformPOSIX::WriteFile(lldb::user_id_t fd, uint64_t offset,
|
||||
const void *src, uint64_t src_len,
|
||||
Status &error) {
|
||||
if (IsHost())
|
||||
return FileCache::GetInstance().WriteFile(fd, offset, src, src_len, error);
|
||||
else if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->WriteFile(fd, offset, src, src_len, error);
|
||||
else
|
||||
return Platform::WriteFile(fd, offset, src, src_len, error);
|
||||
}
|
||||
|
||||
static uint32_t chown_file(Platform *platform, const char *path,
|
||||
uint32_t uid = UINT32_MAX,
|
||||
uint32_t gid = UINT32_MAX) {
|
||||
|
@ -387,45 +298,6 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source,
|
|||
return Platform::PutFile(source, destination, uid, gid);
|
||||
}
|
||||
|
||||
lldb::user_id_t PlatformPOSIX::GetFileSize(const FileSpec &file_spec) {
|
||||
if (IsHost()) {
|
||||
uint64_t Size;
|
||||
if (llvm::sys::fs::file_size(file_spec.GetPath(), Size))
|
||||
return 0;
|
||||
return Size;
|
||||
} else if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->GetFileSize(file_spec);
|
||||
else
|
||||
return Platform::GetFileSize(file_spec);
|
||||
}
|
||||
|
||||
Status PlatformPOSIX::CreateSymlink(const FileSpec &src, const FileSpec &dst) {
|
||||
if (IsHost())
|
||||
return FileSystem::Instance().Symlink(src, dst);
|
||||
else if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->CreateSymlink(src, dst);
|
||||
else
|
||||
return Platform::CreateSymlink(src, dst);
|
||||
}
|
||||
|
||||
bool PlatformPOSIX::GetFileExists(const FileSpec &file_spec) {
|
||||
if (IsHost())
|
||||
return FileSystem::Instance().Exists(file_spec);
|
||||
else if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->GetFileExists(file_spec);
|
||||
else
|
||||
return Platform::GetFileExists(file_spec);
|
||||
}
|
||||
|
||||
Status PlatformPOSIX::Unlink(const FileSpec &file_spec) {
|
||||
if (IsHost())
|
||||
return llvm::sys::fs::remove(file_spec.GetPath());
|
||||
else if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->Unlink(file_spec);
|
||||
else
|
||||
return Platform::Unlink(file_spec);
|
||||
}
|
||||
|
||||
lldb_private::Status PlatformPOSIX::GetFile(
|
||||
const lldb_private::FileSpec &source, // remote file path
|
||||
const lldb_private::FileSpec &destination) // local file path
|
||||
|
@ -569,35 +441,12 @@ std::string PlatformPOSIX::GetPlatformSpecificConnectionInformation() {
|
|||
return "";
|
||||
}
|
||||
|
||||
bool PlatformPOSIX::CalculateMD5(const FileSpec &file_spec, uint64_t &low,
|
||||
uint64_t &high) {
|
||||
if (IsHost())
|
||||
return Platform::CalculateMD5(file_spec, low, high);
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->CalculateMD5(file_spec, low, high);
|
||||
return false;
|
||||
}
|
||||
|
||||
const lldb::UnixSignalsSP &PlatformPOSIX::GetRemoteUnixSignals() {
|
||||
if (IsRemote() && m_remote_platform_sp)
|
||||
return m_remote_platform_sp->GetRemoteUnixSignals();
|
||||
return Platform::GetRemoteUnixSignals();
|
||||
}
|
||||
|
||||
FileSpec PlatformPOSIX::GetRemoteWorkingDirectory() {
|
||||
if (IsRemote() && m_remote_platform_sp)
|
||||
return m_remote_platform_sp->GetRemoteWorkingDirectory();
|
||||
else
|
||||
return Platform::GetRemoteWorkingDirectory();
|
||||
}
|
||||
|
||||
bool PlatformPOSIX::SetRemoteWorkingDirectory(const FileSpec &working_dir) {
|
||||
if (IsRemote() && m_remote_platform_sp)
|
||||
return m_remote_platform_sp->SetRemoteWorkingDirectory(working_dir);
|
||||
else
|
||||
return Platform::SetRemoteWorkingDirectory(working_dir);
|
||||
}
|
||||
|
||||
Status PlatformPOSIX::ConnectRemote(Args &args) {
|
||||
Status error;
|
||||
if (IsHost()) {
|
||||
|
@ -657,16 +506,6 @@ Status PlatformPOSIX::DisconnectRemote() {
|
|||
return error;
|
||||
}
|
||||
|
||||
lldb_private::Status PlatformPOSIX::KillProcess(const lldb::pid_t pid) {
|
||||
if (IsHost())
|
||||
return Platform::KillProcess(pid);
|
||||
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->KillProcess(pid);
|
||||
|
||||
return Status("the platform is not currently connected");
|
||||
}
|
||||
|
||||
lldb::ProcessSP PlatformPOSIX::Attach(ProcessAttachInfo &attach_info,
|
||||
Debugger &debugger, Target *target,
|
||||
Status &error) {
|
||||
|
@ -1200,19 +1039,6 @@ Status PlatformPOSIX::UnloadImage(lldb_private::Process *process,
|
|||
return Status();
|
||||
}
|
||||
|
||||
lldb::ProcessSP PlatformPOSIX::ConnectProcess(llvm::StringRef connect_url,
|
||||
llvm::StringRef plugin_name,
|
||||
lldb_private::Debugger &debugger,
|
||||
lldb_private::Target *target,
|
||||
lldb_private::Status &error) {
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->ConnectProcess(connect_url, plugin_name,
|
||||
debugger, target, error);
|
||||
|
||||
return Platform::ConnectProcess(connect_url, plugin_name, debugger, target,
|
||||
error);
|
||||
}
|
||||
|
||||
llvm::StringRef
|
||||
PlatformPOSIX::GetLibdlFunctionDeclarations(lldb_private::Process *process) {
|
||||
return R"(
|
||||
|
|
|
@ -33,68 +33,16 @@ public:
|
|||
uint32_t uid = UINT32_MAX,
|
||||
uint32_t gid = UINT32_MAX) override;
|
||||
|
||||
lldb::user_id_t OpenFile(const lldb_private::FileSpec &file_spec,
|
||||
uint32_t flags, uint32_t mode,
|
||||
lldb_private::Status &error) override;
|
||||
|
||||
bool CloseFile(lldb::user_id_t fd, lldb_private::Status &error) override;
|
||||
|
||||
uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
|
||||
uint64_t dst_len, lldb_private::Status &error) override;
|
||||
|
||||
uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
|
||||
uint64_t src_len, lldb_private::Status &error) override;
|
||||
|
||||
lldb::user_id_t GetFileSize(const lldb_private::FileSpec &file_spec) override;
|
||||
|
||||
lldb_private::Status
|
||||
CreateSymlink(const lldb_private::FileSpec &src,
|
||||
const lldb_private::FileSpec &dst) override;
|
||||
|
||||
lldb_private::Status
|
||||
GetFile(const lldb_private::FileSpec &source,
|
||||
const lldb_private::FileSpec &destination) override;
|
||||
|
||||
lldb_private::FileSpec GetRemoteWorkingDirectory() override;
|
||||
|
||||
bool
|
||||
SetRemoteWorkingDirectory(const lldb_private::FileSpec &working_dir) override;
|
||||
|
||||
const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
|
||||
|
||||
lldb_private::Status RunShellCommand(
|
||||
const char *command, // Shouldn't be nullptr
|
||||
const lldb_private::FileSpec &working_dir, // Pass empty FileSpec to use
|
||||
// the current working
|
||||
// directory
|
||||
int *status_ptr, // Pass nullptr if you don't want the process exit status
|
||||
int *signo_ptr, // Pass nullptr if you don't want the signal that caused
|
||||
// the process to exit
|
||||
std::string
|
||||
*command_output, // Pass nullptr if you don't want the command output
|
||||
const lldb_private::Timeout<std::micro> &timeout) override;
|
||||
|
||||
lldb_private::Status ResolveExecutable(
|
||||
const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
|
||||
const lldb_private::FileSpecList *module_search_paths_ptr) override;
|
||||
|
||||
lldb_private::Status MakeDirectory(const lldb_private::FileSpec &file_spec,
|
||||
uint32_t mode) override;
|
||||
|
||||
lldb_private::Status
|
||||
GetFilePermissions(const lldb_private::FileSpec &file_spec,
|
||||
uint32_t &file_permissions) override;
|
||||
|
||||
lldb_private::Status
|
||||
SetFilePermissions(const lldb_private::FileSpec &file_spec,
|
||||
uint32_t file_permissions) override;
|
||||
|
||||
bool GetFileExists(const lldb_private::FileSpec &file_spec) override;
|
||||
|
||||
lldb_private::Status Unlink(const lldb_private::FileSpec &file_spec) override;
|
||||
|
||||
lldb_private::Status KillProcess(const lldb::pid_t pid) override;
|
||||
|
||||
lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info,
|
||||
lldb_private::Debugger &debugger,
|
||||
lldb_private::Target *target, // Can be nullptr, if
|
||||
|
@ -114,9 +62,6 @@ public:
|
|||
|
||||
std::string GetPlatformSpecificConnectionInformation() override;
|
||||
|
||||
bool CalculateMD5(const lldb_private::FileSpec &file_spec, uint64_t &low,
|
||||
uint64_t &high) override;
|
||||
|
||||
void CalculateTrapHandlerSymbolNames() override;
|
||||
|
||||
lldb_private::Status ConnectRemote(lldb_private::Args &args) override;
|
||||
|
@ -132,12 +77,6 @@ public:
|
|||
lldb_private::Status UnloadImage(lldb_private::Process *process,
|
||||
uint32_t image_token) override;
|
||||
|
||||
lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
|
||||
llvm::StringRef plugin_name,
|
||||
lldb_private::Debugger &debugger,
|
||||
lldb_private::Target *target,
|
||||
lldb_private::Status &error) override;
|
||||
|
||||
size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
|
||||
lldb_private::Status &error) override;
|
||||
|
||||
|
|
|
@ -197,8 +197,9 @@ Status PlatformWindows::ResolveExecutable(
|
|||
}
|
||||
} else {
|
||||
if (m_remote_platform_sp) {
|
||||
error = GetCachedExecutable(resolved_module_spec, exe_module_sp, nullptr,
|
||||
*m_remote_platform_sp);
|
||||
error =
|
||||
GetCachedExecutable(resolved_module_spec, exe_module_sp,
|
||||
module_search_paths_ptr, *m_remote_platform_sp);
|
||||
} else {
|
||||
// We may connect to a process and use the provided executable (Don't use
|
||||
// local $PATH).
|
||||
|
@ -233,7 +234,8 @@ Status PlatformWindows::ResolveExecutable(
|
|||
idx, resolved_module_spec.GetArchitecture());
|
||||
++idx) {
|
||||
error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
|
||||
nullptr, nullptr, nullptr);
|
||||
module_search_paths_ptr, nullptr,
|
||||
nullptr);
|
||||
// Did we find an executable using one of the
|
||||
if (error.Success()) {
|
||||
if (exe_module_sp && exe_module_sp->GetObjectFile())
|
||||
|
@ -335,6 +337,14 @@ ProcessSP PlatformWindows::DebugProcess(ProcessLaunchInfo &launch_info,
|
|||
// plugin, and PlatformWindows::DebugProcess is just a pass-through to get to
|
||||
// the process plugin.
|
||||
|
||||
if (IsRemote()) {
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->DebugProcess(launch_info, debugger, target,
|
||||
error);
|
||||
else
|
||||
error.SetErrorString("the platform is not currently connected");
|
||||
}
|
||||
|
||||
if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) {
|
||||
// This is a process attach. Don't need to launch anything.
|
||||
ProcessAttachInfo attach_info(launch_info);
|
||||
|
@ -392,34 +402,6 @@ lldb::ProcessSP PlatformWindows::Attach(ProcessAttachInfo &attach_info,
|
|||
return process_sp;
|
||||
}
|
||||
|
||||
Status PlatformWindows::GetSharedModule(
|
||||
const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
|
||||
const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
|
||||
bool *did_create_ptr) {
|
||||
Status error;
|
||||
module_sp.reset();
|
||||
|
||||
if (IsRemote()) {
|
||||
// If we have a remote platform always, let it try and locate the shared
|
||||
// module first.
|
||||
if (m_remote_platform_sp) {
|
||||
error = m_remote_platform_sp->GetSharedModule(
|
||||
module_spec, process, module_sp, module_search_paths_ptr,
|
||||
old_module_sp_ptr, did_create_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (!module_sp) {
|
||||
// Fall back to the local platform and find the file locally
|
||||
error = Platform::GetSharedModule(module_spec, process, module_sp,
|
||||
module_search_paths_ptr,
|
||||
old_module_sp_ptr, did_create_ptr);
|
||||
}
|
||||
if (module_sp)
|
||||
module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
|
||||
return error;
|
||||
}
|
||||
|
||||
bool PlatformWindows::GetSupportedArchitectureAtIndex(uint32_t idx,
|
||||
ArchSpec &arch) {
|
||||
static SupportedArchList architectures;
|
||||
|
@ -435,7 +417,7 @@ void PlatformWindows::GetStatus(Stream &strm) {
|
|||
|
||||
#ifdef _WIN32
|
||||
llvm::VersionTuple version = HostInfo::GetOSVersion();
|
||||
strm << "Host: Windows " << version.getAsString() << '\n';
|
||||
strm << " Host: Windows " << version.getAsString() << '\n';
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -63,13 +63,6 @@ public:
|
|||
lldb_private::Target *target,
|
||||
lldb_private::Status &error) override;
|
||||
|
||||
lldb_private::Status
|
||||
GetSharedModule(const lldb_private::ModuleSpec &module_spec,
|
||||
lldb_private::Process *process, lldb::ModuleSP &module_sp,
|
||||
const lldb_private::FileSpecList *module_search_paths_ptr,
|
||||
lldb::ModuleSP *old_module_sp_ptr,
|
||||
bool *did_create_ptr) override;
|
||||
|
||||
bool GetSupportedArchitectureAtIndex(uint32_t idx,
|
||||
lldb_private::ArchSpec &arch) override;
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "lldb/Target/RemoteAwarePlatform.h"
|
||||
#include "lldb/Host/FileCache.h"
|
||||
#include "lldb/Host/FileSystem.h"
|
||||
#include "lldb/Host/Host.h"
|
||||
|
||||
using namespace lldb_private;
|
||||
|
@ -21,6 +23,139 @@ bool RemoteAwarePlatform::GetModuleSpec(const FileSpec &module_file_spec,
|
|||
return Platform::GetModuleSpec(module_file_spec, arch, module_spec);
|
||||
}
|
||||
|
||||
Status RemoteAwarePlatform::RunShellCommand(
|
||||
const char *command, const FileSpec &working_dir, int *status_ptr,
|
||||
int *signo_ptr, std::string *command_output,
|
||||
const Timeout<std::micro> &timeout) {
|
||||
if (IsHost())
|
||||
return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr,
|
||||
command_output, timeout);
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->RunShellCommand(
|
||||
command, working_dir, status_ptr, signo_ptr, command_output, timeout);
|
||||
return Status("unable to run a remote command without a platform");
|
||||
}
|
||||
|
||||
Status RemoteAwarePlatform::MakeDirectory(const FileSpec &file_spec,
|
||||
uint32_t file_permissions) {
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->MakeDirectory(file_spec, file_permissions);
|
||||
return Platform::MakeDirectory(file_spec, file_permissions);
|
||||
}
|
||||
|
||||
Status RemoteAwarePlatform::GetFilePermissions(const FileSpec &file_spec,
|
||||
uint32_t &file_permissions) {
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->GetFilePermissions(file_spec,
|
||||
file_permissions);
|
||||
return Platform::GetFilePermissions(file_spec, file_permissions);
|
||||
}
|
||||
|
||||
Status RemoteAwarePlatform::SetFilePermissions(const FileSpec &file_spec,
|
||||
uint32_t file_permissions) {
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->SetFilePermissions(file_spec,
|
||||
file_permissions);
|
||||
return Platform::SetFilePermissions(file_spec, file_permissions);
|
||||
}
|
||||
|
||||
lldb::user_id_t RemoteAwarePlatform::OpenFile(const FileSpec &file_spec,
|
||||
uint32_t flags, uint32_t mode,
|
||||
Status &error) {
|
||||
if (IsHost())
|
||||
return FileCache::GetInstance().OpenFile(file_spec, flags, mode, error);
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->OpenFile(file_spec, flags, mode, error);
|
||||
return Platform::OpenFile(file_spec, flags, mode, error);
|
||||
}
|
||||
|
||||
bool RemoteAwarePlatform::CloseFile(lldb::user_id_t fd, Status &error) {
|
||||
if (IsHost())
|
||||
return FileCache::GetInstance().CloseFile(fd, error);
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->CloseFile(fd, error);
|
||||
return Platform::CloseFile(fd, error);
|
||||
}
|
||||
|
||||
uint64_t RemoteAwarePlatform::ReadFile(lldb::user_id_t fd, uint64_t offset,
|
||||
void *dst, uint64_t dst_len,
|
||||
Status &error) {
|
||||
if (IsHost())
|
||||
return FileCache::GetInstance().ReadFile(fd, offset, dst, dst_len, error);
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->ReadFile(fd, offset, dst, dst_len, error);
|
||||
return Platform::ReadFile(fd, offset, dst, dst_len, error);
|
||||
}
|
||||
|
||||
uint64_t RemoteAwarePlatform::WriteFile(lldb::user_id_t fd, uint64_t offset,
|
||||
const void *src, uint64_t src_len,
|
||||
Status &error) {
|
||||
if (IsHost())
|
||||
return FileCache::GetInstance().WriteFile(fd, offset, src, src_len, error);
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->WriteFile(fd, offset, src, src_len, error);
|
||||
return Platform::WriteFile(fd, offset, src, src_len, error);
|
||||
}
|
||||
|
||||
lldb::user_id_t RemoteAwarePlatform::GetFileSize(const FileSpec &file_spec) {
|
||||
if (IsHost()) {
|
||||
uint64_t Size;
|
||||
if (llvm::sys::fs::file_size(file_spec.GetPath(), Size))
|
||||
return 0;
|
||||
return Size;
|
||||
}
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->GetFileSize(file_spec);
|
||||
return Platform::GetFileSize(file_spec);
|
||||
}
|
||||
|
||||
Status RemoteAwarePlatform::CreateSymlink(const FileSpec &src,
|
||||
const FileSpec &dst) {
|
||||
if (IsHost())
|
||||
return FileSystem::Instance().Symlink(src, dst);
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->CreateSymlink(src, dst);
|
||||
return Platform::CreateSymlink(src, dst);
|
||||
}
|
||||
|
||||
bool RemoteAwarePlatform::GetFileExists(const FileSpec &file_spec) {
|
||||
if (IsHost())
|
||||
return FileSystem::Instance().Exists(file_spec);
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->GetFileExists(file_spec);
|
||||
return Platform::GetFileExists(file_spec);
|
||||
}
|
||||
|
||||
Status RemoteAwarePlatform::Unlink(const FileSpec &file_spec) {
|
||||
if (IsHost())
|
||||
return llvm::sys::fs::remove(file_spec.GetPath());
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->Unlink(file_spec);
|
||||
return Platform::Unlink(file_spec);
|
||||
}
|
||||
|
||||
bool RemoteAwarePlatform::CalculateMD5(const FileSpec &file_spec, uint64_t &low,
|
||||
uint64_t &high) {
|
||||
if (IsHost())
|
||||
return Platform::CalculateMD5(file_spec, low, high);
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->CalculateMD5(file_spec, low, high);
|
||||
return false;
|
||||
}
|
||||
|
||||
FileSpec RemoteAwarePlatform::GetRemoteWorkingDirectory() {
|
||||
if (IsRemote() && m_remote_platform_sp)
|
||||
return m_remote_platform_sp->GetRemoteWorkingDirectory();
|
||||
return Platform::GetRemoteWorkingDirectory();
|
||||
}
|
||||
|
||||
bool RemoteAwarePlatform::SetRemoteWorkingDirectory(
|
||||
const FileSpec &working_dir) {
|
||||
if (IsRemote() && m_remote_platform_sp)
|
||||
return m_remote_platform_sp->SetRemoteWorkingDirectory(working_dir);
|
||||
return Platform::SetRemoteWorkingDirectory(working_dir);
|
||||
}
|
||||
|
||||
Status RemoteAwarePlatform::GetFileWithUUID(const FileSpec &platform_file,
|
||||
const UUID *uuid_ptr,
|
||||
FileSpec &local_file) {
|
||||
|
@ -64,7 +199,6 @@ ArchSpec RemoteAwarePlatform::GetRemoteSystemArchitecture() {
|
|||
const char *RemoteAwarePlatform::GetHostname() {
|
||||
if (IsHost())
|
||||
return Platform::GetHostname();
|
||||
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->GetHostname();
|
||||
return nullptr;
|
||||
|
@ -127,6 +261,18 @@ RemoteAwarePlatform::FindProcesses(const ProcessInstanceInfoMatch &match_info,
|
|||
return 0;
|
||||
}
|
||||
|
||||
lldb::ProcessSP RemoteAwarePlatform::ConnectProcess(llvm::StringRef connect_url,
|
||||
llvm::StringRef plugin_name,
|
||||
Debugger &debugger,
|
||||
Target *target,
|
||||
Status &error) {
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->ConnectProcess(connect_url, plugin_name,
|
||||
debugger, target, error);
|
||||
return Platform::ConnectProcess(connect_url, plugin_name, debugger, target,
|
||||
error);
|
||||
}
|
||||
|
||||
Status RemoteAwarePlatform::LaunchProcess(ProcessLaunchInfo &launch_info) {
|
||||
Status error;
|
||||
|
||||
|
@ -140,3 +286,11 @@ Status RemoteAwarePlatform::LaunchProcess(ProcessLaunchInfo &launch_info) {
|
|||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
Status RemoteAwarePlatform::KillProcess(const lldb::pid_t pid) {
|
||||
if (IsHost())
|
||||
return Platform::KillProcess(pid);
|
||||
if (m_remote_platform_sp)
|
||||
return m_remote_platform_sp->KillProcess(pid);
|
||||
return Status("the platform is not currently connected");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue