summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/RemoteAwarePlatform.cpp
diff options
context:
space:
mode:
authorAaron Smith <aaron.smith@microsoft.com>2019-02-14 05:34:46 +0000
committerAaron Smith <aaron.smith@microsoft.com>2019-02-14 05:34:46 +0000
commitd504fe20e38f38b9ede69217b352a6bfae04da6e (patch)
tree37fec89454a032de59394c8047526b669bbf5f11 /lldb/source/Target/RemoteAwarePlatform.cpp
parent023dd1eefad3c3b41633e0644df2e0d29f66d728 (diff)
downloadbcm5719-llvm-d504fe20e38f38b9ede69217b352a6bfae04da6e.tar.gz
bcm5719-llvm-d504fe20e38f38b9ede69217b352a6bfae04da6e.zip
[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
Diffstat (limited to 'lldb/source/Target/RemoteAwarePlatform.cpp')
-rw-r--r--lldb/source/Target/RemoteAwarePlatform.cpp156
1 files changed, 155 insertions, 1 deletions
diff --git a/lldb/source/Target/RemoteAwarePlatform.cpp b/lldb/source/Target/RemoteAwarePlatform.cpp
index 451211b5355..04cb6cedccf 100644
--- a/lldb/source/Target/RemoteAwarePlatform.cpp
+++ b/lldb/source/Target/RemoteAwarePlatform.cpp
@@ -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");
+}
OpenPOWER on IntegriCloud