LLDB  mainline
RemoteAwarePlatform.h
Go to the documentation of this file.
1 //===-- RemoteAwarePlatform.h -----------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_TARGET_REMOTEAWAREPLATFORM_H
10 #define LLDB_TARGET_REMOTEAWAREPLATFORM_H
11 
12 #include "lldb/Target/Platform.h"
13 
14 namespace lldb_private {
15 
16 /// A base class for platforms which automatically want to be able to forward
17 /// operations to a remote platform instance (such as PlatformRemoteGDBServer).
18 class RemoteAwarePlatform : public Platform {
19 public:
20  using Platform::Platform;
21 
22  bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch,
23  ModuleSpec &module_spec) override;
24 
25  Status
26  ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
27  const FileSpecList *module_search_paths_ptr) override;
28 
29  lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags,
30  uint32_t mode, Status &error) override;
31 
32  bool CloseFile(lldb::user_id_t fd, Status &error) override;
33 
34  uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
35  uint64_t dst_len, Status &error) override;
36 
37  uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
38  uint64_t src_len, Status &error) override;
39 
40  lldb::user_id_t GetFileSize(const FileSpec &file_spec) override;
41 
42  Status CreateSymlink(const FileSpec &src, const FileSpec &dst) override;
43 
44  bool GetFileExists(const FileSpec &file_spec) override;
45 
46  Status Unlink(const FileSpec &file_spec) override;
47 
49 
50  bool SetRemoteWorkingDirectory(const FileSpec &working_dir) override;
51 
52  Status MakeDirectory(const FileSpec &file_spec, uint32_t mode) override;
53 
54  Status GetFilePermissions(const FileSpec &file_spec,
55  uint32_t &file_permissions) override;
56 
57  Status SetFilePermissions(const FileSpec &file_spec,
58  uint32_t file_permissions) override;
59 
60  bool CalculateMD5(const FileSpec &file_spec, uint64_t &low,
61  uint64_t &high) override;
62 
63  Status GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
64  FileSpec &local_file) override;
65 
66  bool GetRemoteOSVersion() override;
67  bool GetRemoteOSBuildString(std::string &s) override;
68  bool GetRemoteOSKernelDescription(std::string &s) override;
70 
71  Status RunShellCommand(llvm::StringRef command, const FileSpec &working_dir,
72  int *status_ptr, int *signo_ptr,
73  std::string *command_output,
74  const Timeout<std::micro> &timeout) override;
75 
76  Status RunShellCommand(llvm::StringRef interpreter, llvm::StringRef command,
77  const FileSpec &working_dir, int *status_ptr,
78  int *signo_ptr, std::string *command_output,
79  const Timeout<std::micro> &timeout) override;
80 
81  const char *GetHostname() override;
84 
85  bool IsConnected() const override;
86 
87  bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
89  ProcessInstanceInfoList &process_infos) override;
90 
91  lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
92  llvm::StringRef plugin_name,
93  Debugger &debugger, Target *target,
94  Status &error) override;
95 
96  Status LaunchProcess(ProcessLaunchInfo &launch_info) override;
97 
98  Status KillProcess(const lldb::pid_t pid) override;
99 
100  size_t ConnectToWaitingProcesses(Debugger &debugger,
101  Status &error) override;
102 
103 protected:
104  lldb::PlatformSP m_remote_platform_sp;
105 };
106 
107 } // namespace lldb_private
108 
109 #endif // LLDB_TARGET_REMOTEAWAREPLATFORM_H
lldb_private::RemoteAwarePlatform::IsConnected
bool IsConnected() const override
Definition: RemoteAwarePlatform.cpp:380
lldb_private::RemoteAwarePlatform::SetFilePermissions
Status SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions) override
Definition: RemoteAwarePlatform.cpp:210
lldb_private::RemoteAwarePlatform::ConnectToWaitingProcesses
size_t ConnectToWaitingProcesses(Debugger &debugger, Status &error) override
Connect to all processes waiting for a debugger to attach.
Definition: RemoteAwarePlatform.cpp:441
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:108
lldb_private::UUID
Definition: UUID.h:23
lldb_private::RemoteAwarePlatform::CloseFile
bool CloseFile(lldb::user_id_t fd, Status &error) override
Definition: RemoteAwarePlatform.cpp:228
lldb_private::RemoteAwarePlatform::GetRemoteSystemArchitecture
ArchSpec GetRemoteSystemArchitecture() override
Definition: RemoteAwarePlatform.cpp:349
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::RemoteAwarePlatform::GetRemoteOSBuildString
bool GetRemoteOSBuildString(std::string &s) override
Definition: RemoteAwarePlatform.cpp:335
lldb_private::RemoteAwarePlatform::ConnectProcess
lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url, llvm::StringRef plugin_name, Debugger &debugger, Target *target, Status &error) override
Definition: RemoteAwarePlatform.cpp:407
lldb_private::RemoteAwarePlatform::OpenFile
lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags, uint32_t mode, Status &error) override
Definition: RemoteAwarePlatform.cpp:218
lldb_private::File::OpenOptions
OpenOptions
Definition: File.h:46
lldb_private::RemoteAwarePlatform::GetFilePermissions
Status GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions) override
Definition: RemoteAwarePlatform.cpp:202
lldb_private::RemoteAwarePlatform::LaunchProcess
Status LaunchProcess(ProcessLaunchInfo &launch_info) override
Launch a new process on a platform, not necessarily for debugging, it could be just for running the p...
Definition: RemoteAwarePlatform.cpp:419
lldb_private::ProcessInstanceInfoMatch
Definition: ProcessInfo.h:163
lldb_private::Target
Definition: Target.h:445
lldb_private::RemoteAwarePlatform::GetFileExists
bool GetFileExists(const FileSpec &file_spec) override
Definition: RemoteAwarePlatform.cpp:277
Platform.h
lldb_private::FileSpec
Definition: FileSpec.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
lldb_private::RemoteAwarePlatform::ReadFile
uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, uint64_t dst_len, Status &error) override
Definition: RemoteAwarePlatform.cpp:236
lldb_private::RemoteAwarePlatform::SetRemoteWorkingDirectory
bool SetRemoteWorkingDirectory(const FileSpec &working_dir) override
Definition: RemoteAwarePlatform.cpp:308
lldb_private::RemoteAwarePlatform::m_remote_platform_sp
lldb::PlatformSP m_remote_platform_sp
Definition: RemoteAwarePlatform.h:104
lldb_private::RemoteAwarePlatform::FindProcesses
uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos) override
Attach to an existing process by process name.
Definition: RemoteAwarePlatform.cpp:398
lldb_private::RemoteAwarePlatform::GetEnvironment
lldb_private::Environment GetEnvironment() override
Definition: RemoteAwarePlatform.cpp:371
lldb_private::Debugger
Definition: Debugger.h:70
lldb_private::RemoteAwarePlatform::Unlink
Status Unlink(const FileSpec &file_spec) override
Definition: RemoteAwarePlatform.cpp:285
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:38
lldb_private::RemoteAwarePlatform::GetProcessInfo
bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override
Definition: RemoteAwarePlatform.cpp:388
lldb_private::RemoteAwarePlatform::ResolveExecutable
Status ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr) override
Find a platform plugin for a given process.
Definition: RemoteAwarePlatform.cpp:32
lldb_private::UserIDResolver
An abstract interface for things that know how to map numeric user/group IDs into names.
Definition: UserIDResolver.h:22
lldb_private::RemoteAwarePlatform::CalculateMD5
bool CalculateMD5(const FileSpec &file_spec, uint64_t &low, uint64_t &high) override
Definition: RemoteAwarePlatform.cpp:293
lldb_private::ModuleSpec
Definition: ModuleSpec.h:26
lldb_private::RemoteAwarePlatform::GetModuleSpec
bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, ModuleSpec &module_spec) override
Definition: RemoteAwarePlatform.cpp:22
lldb_private::Status
Definition: Status.h:44
lldb_private::Timeout< std::micro >
lldb_private::RemoteAwarePlatform::MakeDirectory
Status MakeDirectory(const FileSpec &file_spec, uint32_t mode) override
Definition: RemoteAwarePlatform.cpp:195
lldb_private::Platform::Platform
Platform(bool is_host_platform)
Default Constructor.
Definition: Platform.cpp:385
lldb_private::RemoteAwarePlatform::WriteFile
uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, Status &error) override
Definition: RemoteAwarePlatform.cpp:246
uint32_t
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
lldb_private::RemoteAwarePlatform::GetFileWithUUID
Status GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid, FileSpec &local_file) override
Locate a file for a platform.
Definition: RemoteAwarePlatform.cpp:315
lldb_private::Environment
Definition: Environment.h:18
lldb_private::Platform
Definition: Platform.h:72
lldb_private::RemoteAwarePlatform::CreateSymlink
Status CreateSymlink(const FileSpec &src, const FileSpec &dst) override
Definition: RemoteAwarePlatform.cpp:268
lldb_private::RemoteAwarePlatform::GetRemoteOSVersion
bool GetRemoteOSVersion() override
Definition: RemoteAwarePlatform.cpp:327
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::RemoteAwarePlatform::GetFileSize
lldb::user_id_t GetFileSize(const FileSpec &file_spec) override
Definition: RemoteAwarePlatform.cpp:256
lldb_private::RemoteAwarePlatform::GetUserIDResolver
UserIDResolver & GetUserIDResolver() override
Definition: RemoteAwarePlatform.cpp:363
lldb_private::RemoteAwarePlatform::GetRemoteWorkingDirectory
FileSpec GetRemoteWorkingDirectory() override
Definition: RemoteAwarePlatform.cpp:302
lldb_private::RemoteAwarePlatform::GetRemoteOSKernelDescription
bool GetRemoteOSKernelDescription(std::string &s) override
Definition: RemoteAwarePlatform.cpp:342
lldb_private::RemoteAwarePlatform::KillProcess
Status KillProcess(const lldb::pid_t pid) override
Kill process on a platform.
Definition: RemoteAwarePlatform.cpp:433
lldb_private::ProcessInstanceInfoList
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
Definition: Host.h:30
lldb_private::RemoteAwarePlatform
A base class for platforms which automatically want to be able to forward operations to a remote plat...
Definition: RemoteAwarePlatform.h:18
lldb_private::RemoteAwarePlatform::GetHostname
const char * GetHostname() override
Definition: RemoteAwarePlatform.cpp:355
lldb_private::RemoteAwarePlatform::RunShellCommand
Status RunShellCommand(llvm::StringRef command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, const Timeout< std::micro > &timeout) override
Definition: RemoteAwarePlatform.cpp:173