summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Target/RemoteAwarePlatform.h50
-rw-r--r--lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp137
-rw-r--r--lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h41
-rw-r--r--lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp143
-rw-r--r--lldb/source/Plugins/Platform/Windows/PlatformWindows.h45
-rw-r--r--lldb/source/Target/CMakeLists.txt1
-rw-r--r--lldb/source/Target/RemoteAwarePlatform.cpp142
7 files changed, 200 insertions, 359 deletions
diff --git a/lldb/include/lldb/Target/RemoteAwarePlatform.h b/lldb/include/lldb/Target/RemoteAwarePlatform.h
new file mode 100644
index 00000000000..6d58c84c914
--- /dev/null
+++ b/lldb/include/lldb/Target/RemoteAwarePlatform.h
@@ -0,0 +1,50 @@
+//===-- RemoteAwarePlatform.h -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_TARGET_REMOTEAWAREPLATFORM_H
+#define LLDB_TARGET_REMOTEAWAREPLATFORM_H
+
+#include "lldb/Target/Platform.h"
+
+namespace lldb_private {
+
+/// A base class for platforms which automatically want to be able to forward
+/// operations to a remote platform instance (such as PlatformRemoteGDBServer).
+class RemoteAwarePlatform : public Platform {
+public:
+ using Platform::Platform;
+
+ bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch,
+ ModuleSpec &module_spec) override;
+ Status GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
+ FileSpec &local_file) override;
+
+ bool GetRemoteOSVersion() override;
+ bool GetRemoteOSBuildString(std::string &s) override;
+ bool GetRemoteOSKernelDescription(std::string &s) override;
+ ArchSpec GetRemoteSystemArchitecture() override;
+
+ const char *GetHostname() override;
+ const char *GetUserName(uint32_t uid) override;
+ const char *GetGroupName(uint32_t gid) override;
+ lldb_private::Environment GetEnvironment() override;
+
+ bool IsConnected() const override;
+
+ bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
+ uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) override;
+ Status LaunchProcess(ProcessLaunchInfo &launch_info) override;
+
+protected:
+ lldb::PlatformSP m_remote_platform_sp;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_TARGET_REMOTEAWAREPLATFORM_H
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 27fd0747829..7b6b63e2ee5 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -40,11 +40,10 @@ using namespace lldb_private;
/// Default Constructor
//------------------------------------------------------------------
PlatformPOSIX::PlatformPOSIX(bool is_host)
- : Platform(is_host), // This is the local host platform
+ : RemoteAwarePlatform(is_host), // This is the local host platform
m_option_group_platform_rsync(new OptionGroupPlatformRSync()),
m_option_group_platform_ssh(new OptionGroupPlatformSSH()),
- m_option_group_platform_caching(new OptionGroupPlatformCaching()),
- m_remote_platform_sp() {}
+ m_option_group_platform_caching(new OptionGroupPlatformCaching()) {}
//------------------------------------------------------------------
/// Destructor.
@@ -54,16 +53,6 @@ PlatformPOSIX::PlatformPOSIX(bool is_host)
//------------------------------------------------------------------
PlatformPOSIX::~PlatformPOSIX() {}
-bool PlatformPOSIX::GetModuleSpec(const FileSpec &module_file_spec,
- const ArchSpec &arch,
- ModuleSpec &module_spec) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch,
- module_spec);
-
- return Platform::GetModuleSpec(module_file_spec, arch, module_spec);
-}
-
lldb_private::OptionGroupOptions *PlatformPOSIX::GetConnectionOptions(
lldb_private::CommandInterpreter &interpreter) {
auto iter = m_options.find(&interpreter), end = m_options.end();
@@ -79,14 +68,6 @@ lldb_private::OptionGroupOptions *PlatformPOSIX::GetConnectionOptions(
return m_options.at(&interpreter).get();
}
-bool PlatformPOSIX::IsConnected() const {
- if (IsHost())
- return true;
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->IsConnected();
- return false;
-}
-
lldb_private::Status PlatformPOSIX::RunShellCommand(
const char *command, // Shouldn't be NULL
const FileSpec &
@@ -251,38 +232,6 @@ PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec,
return error;
}
-Status PlatformPOSIX::GetFileWithUUID(const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file) {
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
- local_file);
-
- // Default to the local case
- local_file = platform_file;
- return Status();
-}
-
-bool PlatformPOSIX::GetProcessInfo(lldb::pid_t pid,
- ProcessInstanceInfo &process_info) {
- if (IsHost())
- return Platform::GetProcessInfo(pid, process_info);
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetProcessInfo(pid, process_info);
- return false;
-}
-
-uint32_t
-PlatformPOSIX::FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) {
- if (IsHost())
- return Platform::FindProcesses(match_info, process_infos);
- if (m_remote_platform_sp)
- return
- m_remote_platform_sp->FindProcesses(match_info, process_infos);
- return 0;
-}
-
Status PlatformPOSIX::MakeDirectory(const FileSpec &file_spec,
uint32_t file_permissions) {
if (m_remote_platform_sp)
@@ -649,74 +598,6 @@ bool PlatformPOSIX::SetRemoteWorkingDirectory(const FileSpec &working_dir) {
return Platform::SetRemoteWorkingDirectory(working_dir);
}
-bool PlatformPOSIX::GetRemoteOSVersion() {
- if (m_remote_platform_sp) {
- m_os_version = m_remote_platform_sp->GetOSVersion();
- return !m_os_version.empty();
- }
- return false;
-}
-
-bool PlatformPOSIX::GetRemoteOSBuildString(std::string &s) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSBuildString(s);
- s.clear();
- return false;
-}
-
-Environment PlatformPOSIX::GetEnvironment() {
- if (IsRemote()) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetEnvironment();
- return Environment();
- }
- return Host::GetEnvironment();
-}
-
-bool PlatformPOSIX::GetRemoteOSKernelDescription(std::string &s) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSKernelDescription(s);
- s.clear();
- return false;
-}
-
-// Remote Platform subclasses need to override this function
-ArchSpec PlatformPOSIX::GetRemoteSystemArchitecture() {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteSystemArchitecture();
- return ArchSpec();
-}
-
-const char *PlatformPOSIX::GetHostname() {
- if (IsHost())
- return Platform::GetHostname();
-
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetHostname();
- return NULL;
-}
-
-const char *PlatformPOSIX::GetUserName(uint32_t uid) {
- // Check the cache in Platform in case we have already looked this uid up
- const char *user_name = Platform::GetUserName(uid);
- if (user_name)
- return user_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetUserName(uid);
- return NULL;
-}
-
-const char *PlatformPOSIX::GetGroupName(uint32_t gid) {
- const char *group_name = Platform::GetGroupName(gid);
- if (group_name)
- return group_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetGroupName(gid);
- return NULL;
-}
-
Status PlatformPOSIX::ConnectRemote(Args &args) {
Status error;
if (IsHost()) {
@@ -776,20 +657,6 @@ Status PlatformPOSIX::DisconnectRemote() {
return error;
}
-Status PlatformPOSIX::LaunchProcess(ProcessLaunchInfo &launch_info) {
- Status error;
-
- if (IsHost()) {
- error = Platform::LaunchProcess(launch_info);
- } else {
- if (m_remote_platform_sp)
- error = m_remote_platform_sp->LaunchProcess(launch_info);
- else
- error.SetErrorString("the platform is not currently connected");
- }
- return error;
-}
-
lldb_private::Status PlatformPOSIX::KillProcess(const lldb::pid_t pid) {
if (IsHost())
return Platform::KillProcess(pid);
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
index f6958cae25f..9985954c4f8 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
@@ -13,9 +13,9 @@
#include <memory>
#include "lldb/Interpreter/Options.h"
-#include "lldb/Target/Platform.h"
+#include "lldb/Target/RemoteAwarePlatform.h"
-class PlatformPOSIX : public lldb_private::Platform {
+class PlatformPOSIX : public lldb_private::RemoteAwarePlatform {
public:
PlatformPOSIX(bool is_host);
@@ -25,19 +25,9 @@ public:
// lldb_private::Platform functions
//------------------------------------------------------------
- bool GetModuleSpec(const lldb_private::FileSpec &module_file_spec,
- const lldb_private::ArchSpec &arch,
- lldb_private::ModuleSpec &module_spec) override;
-
lldb_private::OptionGroupOptions *
GetConnectionOptions(lldb_private::CommandInterpreter &interpreter) override;
- const char *GetHostname() override;
-
- const char *GetUserName(uint32_t uid) override;
-
- const char *GetGroupName(uint32_t gid) override;
-
lldb_private::Status PutFile(const lldb_private::FileSpec &source,
const lldb_private::FileSpec &destination,
uint32_t uid = UINT32_MAX,
@@ -70,20 +60,8 @@ public:
bool
SetRemoteWorkingDirectory(const lldb_private::FileSpec &working_dir) override;
- bool GetRemoteOSVersion() override;
-
- bool GetRemoteOSBuildString(std::string &s) override;
-
- bool GetRemoteOSKernelDescription(std::string &s) override;
-
- lldb_private::ArchSpec GetRemoteSystemArchitecture() override;
-
const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
- lldb_private::Environment GetEnvironment() override;
-
- bool IsConnected() const override;
-
lldb_private::Status RunShellCommand(
const char *command, // Shouldn't be nullptr
const lldb_private::FileSpec &working_dir, // Pass empty FileSpec to use
@@ -100,16 +78,6 @@ public:
const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
const lldb_private::FileSpecList *module_search_paths_ptr) override;
- lldb_private::Status
- GetFileWithUUID(const lldb_private::FileSpec &platform_file,
- const lldb_private::UUID *uuid,
- lldb_private::FileSpec &local_file) override;
-
- bool GetProcessInfo(lldb::pid_t pid, lldb_private::ProcessInstanceInfo &proc_info) override;
-
- uint32_t FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
- lldb_private::ProcessInstanceInfoList &process_infos) override;
-
lldb_private::Status MakeDirectory(const lldb_private::FileSpec &file_spec,
uint32_t mode) override;
@@ -125,9 +93,6 @@ public:
lldb_private::Status Unlink(const lldb_private::FileSpec &file_spec) override;
- lldb_private::Status
- LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
-
lldb_private::Status KillProcess(const lldb::pid_t pid) override;
lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info,
@@ -189,8 +154,6 @@ protected:
std::map<lldb_private::CommandInterpreter *,
std::unique_ptr<lldb_private::OptionGroupOptions>>
m_options;
- lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a
- // remote POSIX-compliant OS
lldb_private::Status
EvaluateLibdlExpression(lldb_private::Process *process, const char *expr_cstr,
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index 3826aaab55f..9f8e3258de1 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -155,7 +155,7 @@ void PlatformWindows::Terminate(void) {
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformWindows::PlatformWindows(bool is_host) : Platform(is_host) {}
+PlatformWindows::PlatformWindows(bool is_host) : RemoteAwarePlatform(is_host) {}
//------------------------------------------------------------------
/// Destructor.
@@ -165,16 +165,6 @@ PlatformWindows::PlatformWindows(bool is_host) : Platform(is_host) {}
//------------------------------------------------------------------
PlatformWindows::~PlatformWindows() = default;
-bool PlatformWindows::GetModuleSpec(const FileSpec &module_file_spec,
- const ArchSpec &arch,
- ModuleSpec &module_spec) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch,
- module_spec);
-
- return Platform::GetModuleSpec(module_file_spec, arch, module_spec);
-}
-
Status PlatformWindows::ResolveExecutable(
const ModuleSpec &ms, lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr) {
@@ -277,52 +267,6 @@ Status PlatformWindows::ResolveExecutable(
return error;
}
-bool PlatformWindows::GetRemoteOSVersion() {
- if (m_remote_platform_sp) {
- m_os_version = m_remote_platform_sp->GetOSVersion();
- return !m_os_version.empty();
- }
- return false;
-}
-
-bool PlatformWindows::GetRemoteOSBuildString(std::string &s) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSBuildString(s);
- s.clear();
- return false;
-}
-
-bool PlatformWindows::GetRemoteOSKernelDescription(std::string &s) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSKernelDescription(s);
- s.clear();
- return false;
-}
-
-// Remote Platform subclasses need to override this function
-ArchSpec PlatformWindows::GetRemoteSystemArchitecture() {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteSystemArchitecture();
- return ArchSpec();
-}
-
-const char *PlatformWindows::GetHostname() {
- if (IsHost())
- return Platform::GetHostname();
-
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetHostname();
- return nullptr;
-}
-
-bool PlatformWindows::IsConnected() const {
- if (IsHost())
- return true;
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->IsConnected();
- return false;
-}
-
Status PlatformWindows::ConnectRemote(Args &args) {
Status error;
if (IsHost()) {
@@ -369,46 +313,6 @@ Status PlatformWindows::DisconnectRemote() {
return error;
}
-bool PlatformWindows::GetProcessInfo(lldb::pid_t pid,
- ProcessInstanceInfo &process_info) {
- bool success = false;
- if (IsHost()) {
- success = Platform::GetProcessInfo(pid, process_info);
- } else if (m_remote_platform_sp) {
- success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
- }
- return success;
-}
-
-uint32_t
-PlatformWindows::FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) {
- uint32_t match_count = 0;
- if (IsHost()) {
- // Let the base class figure out the host details
- match_count = Platform::FindProcesses(match_info, process_infos);
- } else {
- // If we are remote, we can only return results if we are connected
- if (m_remote_platform_sp)
- match_count =
- m_remote_platform_sp->FindProcesses(match_info, process_infos);
- }
- return match_count;
-}
-
-Status PlatformWindows::LaunchProcess(ProcessLaunchInfo &launch_info) {
- Status error;
- if (IsHost()) {
- error = Platform::LaunchProcess(launch_info);
- } else {
- if (m_remote_platform_sp)
- error = m_remote_platform_sp->LaunchProcess(launch_info);
- else
- error.SetErrorString("the platform is not currently connected");
- }
- return error;
-}
-
ProcessSP PlatformWindows::DebugProcess(ProcessLaunchInfo &launch_info,
Debugger &debugger, Target *target,
Status &error) {
@@ -488,41 +392,6 @@ lldb::ProcessSP PlatformWindows::Attach(ProcessAttachInfo &attach_info,
return process_sp;
}
-const char *PlatformWindows::GetUserName(uint32_t uid) {
- // Check the cache in Platform in case we have already looked this uid up
- const char *user_name = Platform::GetUserName(uid);
- if (user_name)
- return user_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetUserName(uid);
- return nullptr;
-}
-
-const char *PlatformWindows::GetGroupName(uint32_t gid) {
- const char *group_name = Platform::GetGroupName(gid);
- if (group_name)
- return group_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetGroupName(gid);
- return nullptr;
-}
-
-Status PlatformWindows::GetFileWithUUID(const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file) {
- if (IsRemote()) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
- local_file);
- }
-
- // Default to the local case
- local_file = platform_file;
- return Status();
-}
-
Status PlatformWindows::GetSharedModule(
const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
@@ -572,16 +441,6 @@ void PlatformWindows::GetStatus(Stream &strm) {
bool PlatformWindows::CanDebugProcess() { return true; }
-Environment PlatformWindows::GetEnvironment() {
- if (IsRemote()) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetEnvironment();
- return Environment();
- }
-
- return Host::GetEnvironment();
-}
-
ConstString PlatformWindows::GetFullNameForDylib(ConstString basename) {
if (basename.IsEmpty())
return basename;
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.h b/lldb/source/Plugins/Platform/Windows/PlatformWindows.h
index 3b831487e2b..dc42998aabc 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.h
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.h
@@ -9,11 +9,11 @@
#ifndef liblldb_PlatformWindows_h_
#define liblldb_PlatformWindows_h_
-#include "lldb/Target/Platform.h"
+#include "lldb/Target/RemoteAwarePlatform.h"
namespace lldb_private {
-class PlatformWindows : public Platform {
+class PlatformWindows : public RemoteAwarePlatform {
public:
PlatformWindows(bool is_host);
@@ -40,10 +40,6 @@ public:
//------------------------------------------------------------
// lldb_private::Platform functions
//------------------------------------------------------------
- bool GetModuleSpec(const lldb_private::FileSpec &module_file_spec,
- const lldb_private::ArchSpec &arch,
- lldb_private::ModuleSpec &module_spec) override;
-
Status
ResolveExecutable(const lldb_private::ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
@@ -53,37 +49,10 @@ public:
return GetPluginDescriptionStatic(IsHost());
}
- bool GetRemoteOSVersion() override;
-
- bool GetRemoteOSBuildString(std::string &s) override;
-
- bool GetRemoteOSKernelDescription(std::string &s) override;
-
- // Remote Platform subclasses need to override this function
- lldb_private::ArchSpec GetRemoteSystemArchitecture() override;
-
- bool IsConnected() const override;
-
lldb_private::Status ConnectRemote(lldb_private::Args &args) override;
lldb_private::Status DisconnectRemote() override;
- const char *GetHostname() override;
-
- const char *GetUserName(uint32_t uid) override;
-
- const char *GetGroupName(uint32_t gid) override;
-
- bool GetProcessInfo(lldb::pid_t pid,
- lldb_private::ProcessInstanceInfo &proc_info) override;
-
- uint32_t
- FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
- lldb_private::ProcessInstanceInfoList &process_infos) override;
-
- lldb_private::Status
- LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
-
lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
lldb_private::Debugger &debugger,
lldb_private::Target *target,
@@ -95,11 +64,6 @@ public:
lldb_private::Status &error) override;
lldb_private::Status
- GetFileWithUUID(const lldb_private::FileSpec &platform_file,
- const lldb_private::UUID *uuid,
- lldb_private::FileSpec &local_file) 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,
@@ -113,16 +77,11 @@ public:
bool CanDebugProcess() override;
- Environment GetEnvironment() override;
-
// FIXME not sure what the _sigtramp equivalent would be on this platform
void CalculateTrapHandlerSymbolNames() override {}
ConstString GetFullNameForDylib(ConstString basename) override;
-protected:
- lldb::PlatformSP m_remote_platform_sp;
-
private:
DISALLOW_COPY_AND_ASSIGN(PlatformWindows);
};
diff --git a/lldb/source/Target/CMakeLists.txt b/lldb/source/Target/CMakeLists.txt
index b1bbbc46905..9c944f98d0c 100644
--- a/lldb/source/Target/CMakeLists.txt
+++ b/lldb/source/Target/CMakeLists.txt
@@ -21,6 +21,7 @@ add_lldb_library(lldbTarget
QueueList.cpp
RegisterContext.cpp
RegisterNumber.cpp
+ RemoteAwarePlatform.cpp
SectionLoadHistory.cpp
SectionLoadList.cpp
StackFrame.cpp
diff --git a/lldb/source/Target/RemoteAwarePlatform.cpp b/lldb/source/Target/RemoteAwarePlatform.cpp
new file mode 100644
index 00000000000..451211b5355
--- /dev/null
+++ b/lldb/source/Target/RemoteAwarePlatform.cpp
@@ -0,0 +1,142 @@
+//===-- RemoteAwarePlatform.cpp ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Target/RemoteAwarePlatform.h"
+#include "lldb/Host/Host.h"
+
+using namespace lldb_private;
+
+bool RemoteAwarePlatform::GetModuleSpec(const FileSpec &module_file_spec,
+ const ArchSpec &arch,
+ ModuleSpec &module_spec) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch,
+ module_spec);
+
+ return Platform::GetModuleSpec(module_file_spec, arch, module_spec);
+}
+
+Status RemoteAwarePlatform::GetFileWithUUID(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
+ local_file);
+
+ // Default to the local case
+ local_file = platform_file;
+ return Status();
+}
+
+bool RemoteAwarePlatform::GetRemoteOSVersion() {
+ if (m_remote_platform_sp) {
+ m_os_version = m_remote_platform_sp->GetOSVersion();
+ return !m_os_version.empty();
+ }
+ return false;
+}
+
+bool RemoteAwarePlatform::GetRemoteOSBuildString(std::string &s) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSBuildString(s);
+ s.clear();
+ return false;
+}
+
+bool RemoteAwarePlatform::GetRemoteOSKernelDescription(std::string &s) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSKernelDescription(s);
+ s.clear();
+ return false;
+}
+
+ArchSpec RemoteAwarePlatform::GetRemoteSystemArchitecture() {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteSystemArchitecture();
+ return ArchSpec();
+}
+
+const char *RemoteAwarePlatform::GetHostname() {
+ if (IsHost())
+ return Platform::GetHostname();
+
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetHostname();
+ return nullptr;
+}
+
+const char *RemoteAwarePlatform::GetUserName(uint32_t uid) {
+ // Check the cache in Platform in case we have already looked this uid up
+ const char *user_name = Platform::GetUserName(uid);
+ if (user_name)
+ return user_name;
+
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetUserName(uid);
+ return nullptr;
+}
+
+const char *RemoteAwarePlatform::GetGroupName(uint32_t gid) {
+ const char *group_name = Platform::GetGroupName(gid);
+ if (group_name)
+ return group_name;
+
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetGroupName(gid);
+ return nullptr;
+}
+
+Environment RemoteAwarePlatform::GetEnvironment() {
+ if (IsRemote()) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetEnvironment();
+ return Environment();
+ }
+ return Host::GetEnvironment();
+}
+
+bool RemoteAwarePlatform::IsConnected() const {
+ if (IsHost())
+ return true;
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->IsConnected();
+ return false;
+}
+
+bool RemoteAwarePlatform::GetProcessInfo(lldb::pid_t pid,
+ ProcessInstanceInfo &process_info) {
+ if (IsHost())
+ return Platform::GetProcessInfo(pid, process_info);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetProcessInfo(pid, process_info);
+ return false;
+}
+
+uint32_t
+RemoteAwarePlatform::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ if (IsHost())
+ return Platform::FindProcesses(match_info, process_infos);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->FindProcesses(match_info, process_infos);
+ return 0;
+}
+
+Status RemoteAwarePlatform::LaunchProcess(ProcessLaunchInfo &launch_info) {
+ Status error;
+
+ if (IsHost()) {
+ error = Platform::LaunchProcess(launch_info);
+ } else {
+ if (m_remote_platform_sp)
+ error = m_remote_platform_sp->LaunchProcess(launch_info);
+ else
+ error.SetErrorString("the platform is not currently connected");
+ }
+ return error;
+}
OpenPOWER on IntegriCloud