180814287SRaphael Isemann //===-- RemoteAwarePlatform.cpp -------------------------------------------===//
252d9c62aSPavel Labath //
352d9c62aSPavel Labath // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
452d9c62aSPavel Labath // See https://llvm.org/LICENSE.txt for license information.
552d9c62aSPavel Labath // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
652d9c62aSPavel Labath //
752d9c62aSPavel Labath //===----------------------------------------------------------------------===//
852d9c62aSPavel Labath 
952d9c62aSPavel Labath #include "lldb/Target/RemoteAwarePlatform.h"
10e072b20bSPavel Labath #include "lldb/Core/Module.h"
11e072b20bSPavel Labath #include "lldb/Core/ModuleList.h"
12e072b20bSPavel Labath #include "lldb/Core/ModuleSpec.h"
13d504fe20SAaron Smith #include "lldb/Host/FileSystem.h"
1452d9c62aSPavel Labath #include "lldb/Host/Host.h"
15aa51e6a6SPavel Labath #include "lldb/Host/HostInfo.h"
16e072b20bSPavel Labath #include "lldb/Utility/StreamString.h"
1752d9c62aSPavel Labath 
1852d9c62aSPavel Labath using namespace lldb_private;
19e072b20bSPavel Labath using namespace lldb;
2052d9c62aSPavel Labath 
GetModuleSpec(const FileSpec & module_file_spec,const ArchSpec & arch,ModuleSpec & module_spec)2152d9c62aSPavel Labath bool RemoteAwarePlatform::GetModuleSpec(const FileSpec &module_file_spec,
2252d9c62aSPavel Labath                                         const ArchSpec &arch,
2352d9c62aSPavel Labath                                         ModuleSpec &module_spec) {
2452d9c62aSPavel Labath   if (m_remote_platform_sp)
2552d9c62aSPavel Labath     return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch,
2652d9c62aSPavel Labath                                                module_spec);
2752d9c62aSPavel Labath 
286afa5c40SYuri Per   return false;
2952d9c62aSPavel Labath }
3052d9c62aSPavel Labath 
ResolveExecutable(const ModuleSpec & module_spec,ModuleSP & exe_module_sp,const FileSpecList * module_search_paths_ptr)31e072b20bSPavel Labath Status RemoteAwarePlatform::ResolveExecutable(
32e072b20bSPavel Labath     const ModuleSpec &module_spec, ModuleSP &exe_module_sp,
33e072b20bSPavel Labath     const FileSpecList *module_search_paths_ptr) {
34e072b20bSPavel Labath   Status error;
35e072b20bSPavel Labath   // Nothing special to do here, just use the actual file and architecture
36e072b20bSPavel Labath 
37e072b20bSPavel Labath   char exe_path[PATH_MAX];
38e072b20bSPavel Labath   ModuleSpec resolved_module_spec(module_spec);
39e072b20bSPavel Labath 
40e072b20bSPavel Labath   if (IsHost()) {
41e072b20bSPavel Labath     // If we have "ls" as the exe_file, resolve the executable location based
42e072b20bSPavel Labath     // on the current path variables
43e072b20bSPavel Labath     if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) {
44e072b20bSPavel Labath       resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
45e072b20bSPavel Labath       resolved_module_spec.GetFileSpec().SetFile(exe_path,
46e072b20bSPavel Labath                                                  FileSpec::Style::native);
47e072b20bSPavel Labath       FileSystem::Instance().Resolve(resolved_module_spec.GetFileSpec());
48e072b20bSPavel Labath     }
49e072b20bSPavel Labath 
50e072b20bSPavel Labath     if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
51e072b20bSPavel Labath       FileSystem::Instance().ResolveExecutableLocation(
52e072b20bSPavel Labath           resolved_module_spec.GetFileSpec());
53e072b20bSPavel Labath 
54e072b20bSPavel Labath     // Resolve any executable within a bundle on MacOSX
55e072b20bSPavel Labath     Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
56e072b20bSPavel Labath 
57e072b20bSPavel Labath     if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
58e072b20bSPavel Labath       error.Clear();
59e072b20bSPavel Labath     else {
60e072b20bSPavel Labath       const uint32_t permissions = FileSystem::Instance().GetPermissions(
61e072b20bSPavel Labath           resolved_module_spec.GetFileSpec());
62e072b20bSPavel Labath       if (permissions && (permissions & eFilePermissionsEveryoneR) == 0)
63e072b20bSPavel Labath         error.SetErrorStringWithFormat(
64e072b20bSPavel Labath             "executable '%s' is not readable",
65e072b20bSPavel Labath             resolved_module_spec.GetFileSpec().GetPath().c_str());
66e072b20bSPavel Labath       else
67e072b20bSPavel Labath         error.SetErrorStringWithFormat(
68e072b20bSPavel Labath             "unable to find executable for '%s'",
69e072b20bSPavel Labath             resolved_module_spec.GetFileSpec().GetPath().c_str());
70e072b20bSPavel Labath     }
71e072b20bSPavel Labath   } else {
72e072b20bSPavel Labath     if (m_remote_platform_sp) {
73631048e8SLevon Ter-Grigoryan       return GetCachedExecutable(resolved_module_spec, exe_module_sp,
74098c01c1SPavel Labath                                  module_search_paths_ptr);
75631048e8SLevon Ter-Grigoryan     }
76631048e8SLevon Ter-Grigoryan 
77e072b20bSPavel Labath     // We may connect to a process and use the provided executable (Don't use
78e072b20bSPavel Labath     // local $PATH).
79e072b20bSPavel Labath 
80e072b20bSPavel Labath     // Resolve any executable within a bundle on MacOSX
81e072b20bSPavel Labath     Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
82e072b20bSPavel Labath 
83e072b20bSPavel Labath     if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
84e072b20bSPavel Labath       error.Clear();
85e072b20bSPavel Labath     else
86e072b20bSPavel Labath       error.SetErrorStringWithFormat("the platform is not currently "
87e072b20bSPavel Labath                                      "connected, and '%s' doesn't exist in "
88e072b20bSPavel Labath                                      "the system root.",
89e072b20bSPavel Labath                                      exe_path);
90e072b20bSPavel Labath   }
91e072b20bSPavel Labath 
92e072b20bSPavel Labath   if (error.Success()) {
93e072b20bSPavel Labath     if (resolved_module_spec.GetArchitecture().IsValid()) {
94e072b20bSPavel Labath       error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
95e072b20bSPavel Labath                                           module_search_paths_ptr, nullptr, nullptr);
96e072b20bSPavel Labath       if (error.Fail()) {
97e072b20bSPavel Labath         // If we failed, it may be because the vendor and os aren't known. If
98e072b20bSPavel Labath 	// that is the case, try setting them to the host architecture and give
99e072b20bSPavel Labath 	// it another try.
100e072b20bSPavel Labath         llvm::Triple &module_triple =
101e072b20bSPavel Labath             resolved_module_spec.GetArchitecture().GetTriple();
102e072b20bSPavel Labath         bool is_vendor_specified =
103e072b20bSPavel Labath             (module_triple.getVendor() != llvm::Triple::UnknownVendor);
104e072b20bSPavel Labath         bool is_os_specified =
105e072b20bSPavel Labath             (module_triple.getOS() != llvm::Triple::UnknownOS);
106e072b20bSPavel Labath         if (!is_vendor_specified || !is_os_specified) {
107e072b20bSPavel Labath           const llvm::Triple &host_triple =
108e072b20bSPavel Labath               HostInfo::GetArchitecture(HostInfo::eArchKindDefault).GetTriple();
109e072b20bSPavel Labath 
110e072b20bSPavel Labath           if (!is_vendor_specified)
111e072b20bSPavel Labath             module_triple.setVendorName(host_triple.getVendorName());
112e072b20bSPavel Labath           if (!is_os_specified)
113e072b20bSPavel Labath             module_triple.setOSName(host_triple.getOSName());
114e072b20bSPavel Labath 
115e072b20bSPavel Labath           error = ModuleList::GetSharedModule(resolved_module_spec,
116e072b20bSPavel Labath                                               exe_module_sp, module_search_paths_ptr, nullptr, nullptr);
117e072b20bSPavel Labath         }
118e072b20bSPavel Labath       }
119e072b20bSPavel Labath 
120e072b20bSPavel Labath       // TODO find out why exe_module_sp might be NULL
121e072b20bSPavel Labath       if (error.Fail() || !exe_module_sp || !exe_module_sp->GetObjectFile()) {
122e072b20bSPavel Labath         exe_module_sp.reset();
123e072b20bSPavel Labath         error.SetErrorStringWithFormat(
124e072b20bSPavel Labath             "'%s' doesn't contain the architecture %s",
125e072b20bSPavel Labath             resolved_module_spec.GetFileSpec().GetPath().c_str(),
126e072b20bSPavel Labath             resolved_module_spec.GetArchitecture().GetArchitectureName());
127e072b20bSPavel Labath       }
128e072b20bSPavel Labath     } else {
129e072b20bSPavel Labath       // No valid architecture was specified, ask the platform for the
130e072b20bSPavel Labath       // architectures that we should be using (in the correct order) and see
131e072b20bSPavel Labath       // if we can find a match that way
132e072b20bSPavel Labath       StreamString arch_names;
13396beb30fSPavel Labath       llvm::ListSeparator LS;
134dde487e5SJonas Devlieghere       ArchSpec process_host_arch;
135dde487e5SJonas Devlieghere       for (const ArchSpec &arch :
136dde487e5SJonas Devlieghere            GetSupportedArchitectures(process_host_arch)) {
13796beb30fSPavel Labath         resolved_module_spec.GetArchitecture() = arch;
138e072b20bSPavel Labath         error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
139e072b20bSPavel Labath                                             module_search_paths_ptr, nullptr, nullptr);
140e072b20bSPavel Labath         // Did we find an executable using one of the
141e072b20bSPavel Labath         if (error.Success()) {
142e072b20bSPavel Labath           if (exe_module_sp && exe_module_sp->GetObjectFile())
143e072b20bSPavel Labath             break;
144e072b20bSPavel Labath           else
145e072b20bSPavel Labath             error.SetErrorToGenericError();
146e072b20bSPavel Labath         }
147e072b20bSPavel Labath 
14896beb30fSPavel Labath         arch_names << LS << arch.GetArchitectureName();
149e072b20bSPavel Labath       }
150e072b20bSPavel Labath 
151e072b20bSPavel Labath       if (error.Fail() || !exe_module_sp) {
152e072b20bSPavel Labath         if (FileSystem::Instance().Readable(
153e072b20bSPavel Labath                 resolved_module_spec.GetFileSpec())) {
154a3939e15SPavel Labath           error.SetErrorStringWithFormatv(
155a3939e15SPavel Labath               "'{0}' doesn't contain any '{1}' platform architectures: {2}",
156a3939e15SPavel Labath               resolved_module_spec.GetFileSpec(), GetPluginName(),
157a3939e15SPavel Labath               arch_names.GetData());
158e072b20bSPavel Labath         } else {
159e072b20bSPavel Labath           error.SetErrorStringWithFormat(
160e072b20bSPavel Labath               "'%s' is not readable",
161e072b20bSPavel Labath               resolved_module_spec.GetFileSpec().GetPath().c_str());
162e072b20bSPavel Labath         }
163e072b20bSPavel Labath       }
164e072b20bSPavel Labath     }
165e072b20bSPavel Labath   }
166e072b20bSPavel Labath 
167e072b20bSPavel Labath   return error;
168e072b20bSPavel Labath }
169e072b20bSPavel Labath 
RunShellCommand(llvm::StringRef command,const FileSpec & working_dir,int * status_ptr,int * signo_ptr,std::string * command_output,const Timeout<std::micro> & timeout)170d504fe20SAaron Smith Status RemoteAwarePlatform::RunShellCommand(
171addb5148SMed Ismail Bennani     llvm::StringRef command, const FileSpec &working_dir, int *status_ptr,
172d504fe20SAaron Smith     int *signo_ptr, std::string *command_output,
173d504fe20SAaron Smith     const Timeout<std::micro> &timeout) {
174addb5148SMed Ismail Bennani   return RunShellCommand(llvm::StringRef(), command, working_dir, status_ptr,
175addb5148SMed Ismail Bennani                          signo_ptr, command_output, timeout);
176addb5148SMed Ismail Bennani }
177addb5148SMed Ismail Bennani 
RunShellCommand(llvm::StringRef shell,llvm::StringRef command,const FileSpec & working_dir,int * status_ptr,int * signo_ptr,std::string * command_output,const Timeout<std::micro> & timeout)178addb5148SMed Ismail Bennani Status RemoteAwarePlatform::RunShellCommand(
179addb5148SMed Ismail Bennani     llvm::StringRef shell, llvm::StringRef command, const FileSpec &working_dir,
180addb5148SMed Ismail Bennani     int *status_ptr, int *signo_ptr, std::string *command_output,
181addb5148SMed Ismail Bennani     const Timeout<std::micro> &timeout) {
182d504fe20SAaron Smith   if (m_remote_platform_sp)
183addb5148SMed Ismail Bennani     return m_remote_platform_sp->RunShellCommand(shell, command, working_dir,
184addb5148SMed Ismail Bennani                                                  status_ptr, signo_ptr,
185addb5148SMed Ismail Bennani                                                  command_output, timeout);
186*331150a4SPavel Labath   return Platform::RunShellCommand(shell, command, working_dir, status_ptr,
187*331150a4SPavel Labath                                    signo_ptr, command_output, timeout);
188d504fe20SAaron Smith }
189d504fe20SAaron Smith 
MakeDirectory(const FileSpec & file_spec,uint32_t file_permissions)190d504fe20SAaron Smith Status RemoteAwarePlatform::MakeDirectory(const FileSpec &file_spec,
191d504fe20SAaron Smith                                           uint32_t file_permissions) {
192d504fe20SAaron Smith   if (m_remote_platform_sp)
193d504fe20SAaron Smith     return m_remote_platform_sp->MakeDirectory(file_spec, file_permissions);
194d504fe20SAaron Smith   return Platform::MakeDirectory(file_spec, file_permissions);
195d504fe20SAaron Smith }
196d504fe20SAaron Smith 
GetFilePermissions(const FileSpec & file_spec,uint32_t & file_permissions)197d504fe20SAaron Smith Status RemoteAwarePlatform::GetFilePermissions(const FileSpec &file_spec,
198d504fe20SAaron Smith                                                uint32_t &file_permissions) {
199d504fe20SAaron Smith   if (m_remote_platform_sp)
200d504fe20SAaron Smith     return m_remote_platform_sp->GetFilePermissions(file_spec,
201d504fe20SAaron Smith                                                     file_permissions);
202d504fe20SAaron Smith   return Platform::GetFilePermissions(file_spec, file_permissions);
203d504fe20SAaron Smith }
204d504fe20SAaron Smith 
SetFilePermissions(const FileSpec & file_spec,uint32_t file_permissions)205d504fe20SAaron Smith Status RemoteAwarePlatform::SetFilePermissions(const FileSpec &file_spec,
206d504fe20SAaron Smith                                                uint32_t file_permissions) {
207d504fe20SAaron Smith   if (m_remote_platform_sp)
208d504fe20SAaron Smith     return m_remote_platform_sp->SetFilePermissions(file_spec,
209d504fe20SAaron Smith                                                     file_permissions);
210d504fe20SAaron Smith   return Platform::SetFilePermissions(file_spec, file_permissions);
211d504fe20SAaron Smith }
212d504fe20SAaron Smith 
OpenFile(const FileSpec & file_spec,File::OpenOptions flags,uint32_t mode,Status & error)213d504fe20SAaron Smith lldb::user_id_t RemoteAwarePlatform::OpenFile(const FileSpec &file_spec,
21462c9fe42SLawrence D'Anna                                               File::OpenOptions flags,
21562c9fe42SLawrence D'Anna                                               uint32_t mode, Status &error) {
216d504fe20SAaron Smith   if (m_remote_platform_sp)
217d504fe20SAaron Smith     return m_remote_platform_sp->OpenFile(file_spec, flags, mode, error);
218d504fe20SAaron Smith   return Platform::OpenFile(file_spec, flags, mode, error);
219d504fe20SAaron Smith }
220d504fe20SAaron Smith 
CloseFile(lldb::user_id_t fd,Status & error)221d504fe20SAaron Smith bool RemoteAwarePlatform::CloseFile(lldb::user_id_t fd, Status &error) {
222d504fe20SAaron Smith   if (m_remote_platform_sp)
223d504fe20SAaron Smith     return m_remote_platform_sp->CloseFile(fd, error);
224d504fe20SAaron Smith   return Platform::CloseFile(fd, error);
225d504fe20SAaron Smith }
226d504fe20SAaron Smith 
ReadFile(lldb::user_id_t fd,uint64_t offset,void * dst,uint64_t dst_len,Status & error)227d504fe20SAaron Smith uint64_t RemoteAwarePlatform::ReadFile(lldb::user_id_t fd, uint64_t offset,
228d504fe20SAaron Smith                                        void *dst, uint64_t dst_len,
229d504fe20SAaron Smith                                        Status &error) {
230d504fe20SAaron Smith   if (m_remote_platform_sp)
231d504fe20SAaron Smith     return m_remote_platform_sp->ReadFile(fd, offset, dst, dst_len, error);
232d504fe20SAaron Smith   return Platform::ReadFile(fd, offset, dst, dst_len, error);
233d504fe20SAaron Smith }
234d504fe20SAaron Smith 
WriteFile(lldb::user_id_t fd,uint64_t offset,const void * src,uint64_t src_len,Status & error)235d504fe20SAaron Smith uint64_t RemoteAwarePlatform::WriteFile(lldb::user_id_t fd, uint64_t offset,
236d504fe20SAaron Smith                                         const void *src, uint64_t src_len,
237d504fe20SAaron Smith                                         Status &error) {
238d504fe20SAaron Smith   if (m_remote_platform_sp)
239d504fe20SAaron Smith     return m_remote_platform_sp->WriteFile(fd, offset, src, src_len, error);
240d504fe20SAaron Smith   return Platform::WriteFile(fd, offset, src, src_len, error);
241d504fe20SAaron Smith }
242d504fe20SAaron Smith 
GetFileSize(const FileSpec & file_spec)243d504fe20SAaron Smith lldb::user_id_t RemoteAwarePlatform::GetFileSize(const FileSpec &file_spec) {
244d504fe20SAaron Smith   if (m_remote_platform_sp)
245d504fe20SAaron Smith     return m_remote_platform_sp->GetFileSize(file_spec);
246d504fe20SAaron Smith   return Platform::GetFileSize(file_spec);
247d504fe20SAaron Smith }
248d504fe20SAaron Smith 
CreateSymlink(const FileSpec & src,const FileSpec & dst)249d504fe20SAaron Smith Status RemoteAwarePlatform::CreateSymlink(const FileSpec &src,
250d504fe20SAaron Smith                                           const FileSpec &dst) {
251d504fe20SAaron Smith   if (m_remote_platform_sp)
252d504fe20SAaron Smith     return m_remote_platform_sp->CreateSymlink(src, dst);
253d504fe20SAaron Smith   return Platform::CreateSymlink(src, dst);
254d504fe20SAaron Smith }
255d504fe20SAaron Smith 
GetFileExists(const FileSpec & file_spec)256d504fe20SAaron Smith bool RemoteAwarePlatform::GetFileExists(const FileSpec &file_spec) {
257d504fe20SAaron Smith   if (m_remote_platform_sp)
258d504fe20SAaron Smith     return m_remote_platform_sp->GetFileExists(file_spec);
259d504fe20SAaron Smith   return Platform::GetFileExists(file_spec);
260d504fe20SAaron Smith }
261d504fe20SAaron Smith 
Unlink(const FileSpec & file_spec)262d504fe20SAaron Smith Status RemoteAwarePlatform::Unlink(const FileSpec &file_spec) {
263d504fe20SAaron Smith   if (m_remote_platform_sp)
264d504fe20SAaron Smith     return m_remote_platform_sp->Unlink(file_spec);
265d504fe20SAaron Smith   return Platform::Unlink(file_spec);
266d504fe20SAaron Smith }
267d504fe20SAaron Smith 
CalculateMD5(const FileSpec & file_spec,uint64_t & low,uint64_t & high)268d504fe20SAaron Smith bool RemoteAwarePlatform::CalculateMD5(const FileSpec &file_spec, uint64_t &low,
269d504fe20SAaron Smith                                        uint64_t &high) {
270d504fe20SAaron Smith   if (m_remote_platform_sp)
271d504fe20SAaron Smith     return m_remote_platform_sp->CalculateMD5(file_spec, low, high);
272*331150a4SPavel Labath   return Platform::CalculateMD5(file_spec, low, high);
273d504fe20SAaron Smith }
274d504fe20SAaron Smith 
GetRemoteWorkingDirectory()275d504fe20SAaron Smith FileSpec RemoteAwarePlatform::GetRemoteWorkingDirectory() {
276d504fe20SAaron Smith   if (IsRemote() && m_remote_platform_sp)
277d504fe20SAaron Smith     return m_remote_platform_sp->GetRemoteWorkingDirectory();
278d504fe20SAaron Smith   return Platform::GetRemoteWorkingDirectory();
279d504fe20SAaron Smith }
280d504fe20SAaron Smith 
SetRemoteWorkingDirectory(const FileSpec & working_dir)281d504fe20SAaron Smith bool RemoteAwarePlatform::SetRemoteWorkingDirectory(
282d504fe20SAaron Smith     const FileSpec &working_dir) {
283d504fe20SAaron Smith   if (IsRemote() && m_remote_platform_sp)
284d504fe20SAaron Smith     return m_remote_platform_sp->SetRemoteWorkingDirectory(working_dir);
285d504fe20SAaron Smith   return Platform::SetRemoteWorkingDirectory(working_dir);
286d504fe20SAaron Smith }
287d504fe20SAaron Smith 
GetFileWithUUID(const FileSpec & platform_file,const UUID * uuid_ptr,FileSpec & local_file)28852d9c62aSPavel Labath Status RemoteAwarePlatform::GetFileWithUUID(const FileSpec &platform_file,
28952d9c62aSPavel Labath                                             const UUID *uuid_ptr,
29052d9c62aSPavel Labath                                             FileSpec &local_file) {
29152d9c62aSPavel Labath   if (IsRemote() && m_remote_platform_sp)
29252d9c62aSPavel Labath     return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
29352d9c62aSPavel Labath                                                  local_file);
29452d9c62aSPavel Labath 
29552d9c62aSPavel Labath   // Default to the local case
29652d9c62aSPavel Labath   local_file = platform_file;
29752d9c62aSPavel Labath   return Status();
29852d9c62aSPavel Labath }
29952d9c62aSPavel Labath 
GetRemoteOSVersion()30052d9c62aSPavel Labath bool RemoteAwarePlatform::GetRemoteOSVersion() {
30152d9c62aSPavel Labath   if (m_remote_platform_sp) {
30252d9c62aSPavel Labath     m_os_version = m_remote_platform_sp->GetOSVersion();
30352d9c62aSPavel Labath     return !m_os_version.empty();
30452d9c62aSPavel Labath   }
30552d9c62aSPavel Labath   return false;
30652d9c62aSPavel Labath }
30752d9c62aSPavel Labath 
GetRemoteOSBuildString()30840e4ac3eSPavel Labath llvm::Optional<std::string> RemoteAwarePlatform::GetRemoteOSBuildString() {
30952d9c62aSPavel Labath   if (m_remote_platform_sp)
31040e4ac3eSPavel Labath     return m_remote_platform_sp->GetRemoteOSBuildString();
31140e4ac3eSPavel Labath   return llvm::None;
31252d9c62aSPavel Labath }
31352d9c62aSPavel Labath 
GetRemoteOSKernelDescription()314f5158ca4SPavel Labath llvm::Optional<std::string> RemoteAwarePlatform::GetRemoteOSKernelDescription() {
31552d9c62aSPavel Labath   if (m_remote_platform_sp)
316f5158ca4SPavel Labath     return m_remote_platform_sp->GetRemoteOSKernelDescription();
317f5158ca4SPavel Labath   return llvm::None;
31852d9c62aSPavel Labath }
31952d9c62aSPavel Labath 
GetRemoteSystemArchitecture()32052d9c62aSPavel Labath ArchSpec RemoteAwarePlatform::GetRemoteSystemArchitecture() {
32152d9c62aSPavel Labath   if (m_remote_platform_sp)
32252d9c62aSPavel Labath     return m_remote_platform_sp->GetRemoteSystemArchitecture();
32352d9c62aSPavel Labath   return ArchSpec();
32452d9c62aSPavel Labath }
32552d9c62aSPavel Labath 
GetHostname()32652d9c62aSPavel Labath const char *RemoteAwarePlatform::GetHostname() {
32752d9c62aSPavel Labath   if (m_remote_platform_sp)
32852d9c62aSPavel Labath     return m_remote_platform_sp->GetHostname();
329*331150a4SPavel Labath   return Platform::GetHostname();
33052d9c62aSPavel Labath }
33152d9c62aSPavel Labath 
GetUserIDResolver()332aa51e6a6SPavel Labath UserIDResolver &RemoteAwarePlatform::GetUserIDResolver() {
333aa51e6a6SPavel Labath   if (m_remote_platform_sp)
334aa51e6a6SPavel Labath     return m_remote_platform_sp->GetUserIDResolver();
335*331150a4SPavel Labath   return Platform::GetUserIDResolver();
33652d9c62aSPavel Labath }
33752d9c62aSPavel Labath 
GetEnvironment()33852d9c62aSPavel Labath Environment RemoteAwarePlatform::GetEnvironment() {
33952d9c62aSPavel Labath   if (m_remote_platform_sp)
34052d9c62aSPavel Labath     return m_remote_platform_sp->GetEnvironment();
341*331150a4SPavel Labath   return Platform::GetEnvironment();
34252d9c62aSPavel Labath }
34352d9c62aSPavel Labath 
IsConnected() const34452d9c62aSPavel Labath bool RemoteAwarePlatform::IsConnected() const {
345*331150a4SPavel Labath   if (m_remote_platform_sp)
34652d9c62aSPavel Labath     return m_remote_platform_sp->IsConnected();
347*331150a4SPavel Labath   return Platform::IsConnected();
34852d9c62aSPavel Labath }
34952d9c62aSPavel Labath 
GetProcessInfo(lldb::pid_t pid,ProcessInstanceInfo & process_info)35052d9c62aSPavel Labath bool RemoteAwarePlatform::GetProcessInfo(lldb::pid_t pid,
35152d9c62aSPavel Labath                                          ProcessInstanceInfo &process_info) {
35252d9c62aSPavel Labath   if (m_remote_platform_sp)
35352d9c62aSPavel Labath     return m_remote_platform_sp->GetProcessInfo(pid, process_info);
354*331150a4SPavel Labath   return Platform::GetProcessInfo(pid, process_info);
35552d9c62aSPavel Labath }
35652d9c62aSPavel Labath 
35752d9c62aSPavel Labath uint32_t
FindProcesses(const ProcessInstanceInfoMatch & match_info,ProcessInstanceInfoList & process_infos)35852d9c62aSPavel Labath RemoteAwarePlatform::FindProcesses(const ProcessInstanceInfoMatch &match_info,
35952d9c62aSPavel Labath                                    ProcessInstanceInfoList &process_infos) {
36052d9c62aSPavel Labath   if (m_remote_platform_sp)
36152d9c62aSPavel Labath     return m_remote_platform_sp->FindProcesses(match_info, process_infos);
362*331150a4SPavel Labath   return Platform::FindProcesses(match_info, process_infos);
36352d9c62aSPavel Labath }
36452d9c62aSPavel Labath 
ConnectProcess(llvm::StringRef connect_url,llvm::StringRef plugin_name,Debugger & debugger,Target * target,Status & error)365d504fe20SAaron Smith lldb::ProcessSP RemoteAwarePlatform::ConnectProcess(llvm::StringRef connect_url,
366d504fe20SAaron Smith                                                     llvm::StringRef plugin_name,
367d504fe20SAaron Smith                                                     Debugger &debugger,
368d504fe20SAaron Smith                                                     Target *target,
369d504fe20SAaron Smith                                                     Status &error) {
370d504fe20SAaron Smith   if (m_remote_platform_sp)
371d504fe20SAaron Smith     return m_remote_platform_sp->ConnectProcess(connect_url, plugin_name,
372d504fe20SAaron Smith                                                 debugger, target, error);
373d504fe20SAaron Smith   return Platform::ConnectProcess(connect_url, plugin_name, debugger, target,
374d504fe20SAaron Smith                                   error);
375d504fe20SAaron Smith }
376d504fe20SAaron Smith 
LaunchProcess(ProcessLaunchInfo & launch_info)37752d9c62aSPavel Labath Status RemoteAwarePlatform::LaunchProcess(ProcessLaunchInfo &launch_info) {
37852d9c62aSPavel Labath   if (m_remote_platform_sp)
379*331150a4SPavel Labath     return m_remote_platform_sp->LaunchProcess(launch_info);
380*331150a4SPavel Labath   return Platform::LaunchProcess(launch_info);
38152d9c62aSPavel Labath }
382d504fe20SAaron Smith 
KillProcess(const lldb::pid_t pid)383d504fe20SAaron Smith Status RemoteAwarePlatform::KillProcess(const lldb::pid_t pid) {
384d504fe20SAaron Smith   if (m_remote_platform_sp)
385d504fe20SAaron Smith     return m_remote_platform_sp->KillProcess(pid);
386*331150a4SPavel Labath   return Platform::KillProcess(pid);
387d504fe20SAaron Smith }
388463863ffSPavel Labath 
ConnectToWaitingProcesses(Debugger & debugger,Status & error)389463863ffSPavel Labath size_t RemoteAwarePlatform::ConnectToWaitingProcesses(Debugger &debugger,
390463863ffSPavel Labath                                                 Status &error) {
391463863ffSPavel Labath   if (m_remote_platform_sp)
392463863ffSPavel Labath     return m_remote_platform_sp->ConnectToWaitingProcesses(debugger, error);
393463863ffSPavel Labath   return Platform::ConnectToWaitingProcesses(debugger, error);
394463863ffSPavel Labath }
395