LLDB  mainline
PlatformAppleSimulator.h
Go to the documentation of this file.
1 //===-- PlatformAppleSimulator.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_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMAPPLESIMULATOR_H
10 #define LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMAPPLESIMULATOR_H
11 
15 #include "lldb/Utility/FileSpec.h"
17 #include "lldb/Utility/Status.h"
18 #include "lldb/Utility/XcodeSDK.h"
19 #include "lldb/lldb-forward.h"
20 #include "llvm/ADT/Optional.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "llvm/ADT/Triple.h"
24 
25 #include <mutex>
26 #include <vector>
27 
28 namespace lldb_private {
29 class ArchSpec;
30 class Args;
31 class Debugger;
32 class FileSpecList;
33 class ModuleSpec;
34 class Process;
35 class ProcessLaunchInfo;
36 class Stream;
37 class Target;
38 class UUID;
39 
41 public:
42  // Class Functions
43  static void Initialize();
44 
45  static void Terminate();
46 
47  // Class Methods
49  const char *class_name, const char *description, ConstString plugin_name,
50  llvm::Triple::OSType preferred_os,
51  llvm::SmallVector<llvm::StringRef, 4> supported_triples,
52  llvm::StringRef sdk, XcodeSDK::Type sdk_type,
54 
55  static lldb::PlatformSP
56  CreateInstance(const char *class_name, const char *description,
57  ConstString plugin_name,
58  llvm::SmallVector<llvm::Triple::ArchType, 4> supported_arch,
59  llvm::Triple::OSType preferred_os,
60  llvm::SmallVector<llvm::Triple::OSType, 4> supported_os,
61  llvm::SmallVector<llvm::StringRef, 4> supported_triples,
62  std::string sdk_name_preferred, std::string sdk_name_secondary,
63  XcodeSDK::Type sdk_type,
65  bool force, const ArchSpec *arch);
66 
67  ~PlatformAppleSimulator() override;
68 
69  llvm::StringRef GetPluginName() override {
70  return m_plugin_name.GetStringRef();
71  }
72  llvm::StringRef GetDescription() override { return m_description; }
73 
74  Status LaunchProcess(ProcessLaunchInfo &launch_info) override;
75 
76  void GetStatus(Stream &strm) override;
77 
78  Status ConnectRemote(Args &args) override;
79 
80  Status DisconnectRemote() override;
81 
82  lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info,
83  Debugger &debugger, Target &target,
84  Status &error) override;
85 
86  std::vector<ArchSpec>
87  GetSupportedArchitectures(const ArchSpec &process_host_arch) override;
88 
89  Status
90  ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
91  const FileSpecList *module_search_paths_ptr) override;
92 
93  Status GetSharedModule(const ModuleSpec &module_spec, Process *process,
94  lldb::ModuleSP &module_sp,
95  const FileSpecList *module_search_paths_ptr,
97  bool *did_create_ptr) override;
98 
100  ProcessInstanceInfoList &process_infos) override;
101 
102  void
104  std::vector<std::string> &options) override {
106  target, options, m_sdk_type);
107  }
108 
109 protected:
110  const char *m_class_name;
111  const char *m_description;
114  llvm::Optional<FileSpec> m_core_simulator_framework_path;
115  llvm::Optional<CoreSimulatorSupport::Device> m_device;
117 
119 
120  llvm::Triple::OSType m_os_type = llvm::Triple::UnknownOS;
121  llvm::SmallVector<llvm::StringRef, 4> m_supported_triples = {};
122  llvm::StringRef m_sdk;
124 
125  void LoadCoreSimulator();
126 
127 #if defined(__APPLE__)
128  CoreSimulatorSupport::Device GetSimulatorDevice();
129 #endif
130 
131 private:
133  const PlatformAppleSimulator &
134  operator=(const PlatformAppleSimulator &) = delete;
135  Status
136 
137  GetSymbolFile(const FileSpec &platform_file, const UUID *uuid_ptr,
138  FileSpec &local_file);
139 };
140 
141 } // namespace lldb_private
142 
143 #endif // LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMAPPLESIMULATOR_H
lldb_private::UUID
Definition: UUID.h:23
lldb_private::PlatformAppleSimulator::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: PlatformAppleSimulator.cpp:57
lldb_private::ArchSpec
Definition: ArchSpec.h:32
lldb_private::PlatformAppleSimulator
Definition: PlatformAppleSimulator.h:40
lldb_private::PlatformAppleSimulator::Initialize
static void Initialize()
Definition: PlatformAppleSimulator.cpp:671
lldb_private::PlatformAppleSimulator::GetSupportedArchitectures
std::vector< ArchSpec > GetSupportedArchitectures(const ArchSpec &process_host_arch) override
Get the platform's supported architectures in the order in which they should be searched.
Definition: PlatformAppleSimulator.cpp:271
lldb_private::PlatformAppleSimulator::m_sdk
llvm::StringRef m_sdk
Definition: PlatformAppleSimulator.h:122
lldb_private::PlatformAppleSimulator::GetDescription
llvm::StringRef GetDescription() override
Definition: PlatformAppleSimulator.h:72
lldb_private::Process
Definition: Process.h:338
lldb_private::PlatformAppleSimulator::~PlatformAppleSimulator
~PlatformAppleSimulator() override
Destructor.
lldb_private::ProcessInstanceInfoMatch
Definition: ProcessInfo.h:160
lldb_private::PlatformAppleSimulator::DebugProcess
lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target &target, Status &error) override
Subclasses do not need to implement this function as it uses the Platform::LaunchProcess() followed b...
Definition: PlatformAppleSimulator.cpp:183
lldb_private::PlatformAppleSimulator::AddClangModuleCompilationOptions
void AddClangModuleCompilationOptions(Target *target, std::vector< std::string > &options) override
Definition: PlatformAppleSimulator.h:103
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Args
Definition: Args.h:33
lldb_private::PlatformAppleSimulator::m_core_sim_path_mutex
std::mutex m_core_sim_path_mutex
Definition: PlatformAppleSimulator.h:113
lldb_private::PlatformAppleSimulator::m_class_name
const char * m_class_name
Definition: PlatformAppleSimulator.h:110
lldb_private::Target
Definition: Target.h:469
XcodeSDK.h
lldb_private::FileSpec
Definition: FileSpec.h:55
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
ProcessInfo.h
lldb_private::PlatformAppleSimulator::operator=
const PlatformAppleSimulator & operator=(const PlatformAppleSimulator &)=delete
lldb_private::PlatformAppleSimulator::m_plugin_name
ConstString m_plugin_name
Definition: PlatformAppleSimulator.h:112
PlatformiOSSimulatorCoreSimulatorSupport.h
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:201
lldb_private::PlatformAppleSimulator::DisconnectRemote
Status DisconnectRemote() override
Definition: PlatformAppleSimulator.cpp:171
lldb_private::LLDBLog::Process
@ Process
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::PlatformAppleSimulator::m_sdk_type
XcodeSDK::Type m_sdk_type
Definition: PlatformAppleSimulator.h:123
lldb_private::PlatformAppleSimulator::m_kind
CoreSimulatorSupport::DeviceType::ProductFamilyID m_kind
Definition: PlatformAppleSimulator.h:116
lldb_private::Debugger
Definition: Debugger.h:74
lldb_private::PlatformAppleSimulator::GetStatus
void GetStatus(Stream &strm) override
Report the current status for this platform.
Definition: PlatformAppleSimulator.cpp:84
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::PlatformAppleSimulator::Terminate
static void Terminate()
Definition: PlatformAppleSimulator.cpp:680
lldb_private::PlatformAppleSimulator::m_device
llvm::Optional< CoreSimulatorSupport::Device > m_device
Definition: PlatformAppleSimulator.h:115
lldb_private::PlatformAppleSimulator::LoadCoreSimulator
void LoadCoreSimulator()
Definition: PlatformAppleSimulator.cpp:242
lldb_private::PlatformAppleSimulator::PlatformAppleSimulator
PlatformAppleSimulator(const char *class_name, const char *description, ConstString plugin_name, llvm::Triple::OSType preferred_os, llvm::SmallVector< llvm::StringRef, 4 > supported_triples, llvm::StringRef sdk, XcodeSDK::Type sdk_type, CoreSimulatorSupport::DeviceType::ProductFamilyID kind)
Default Constructor.
Definition: PlatformAppleSimulator.cpp:40
lldb_private::PlatformAppleSimulator::m_description
const char * m_description
Definition: PlatformAppleSimulator.h:111
lldb_private::ModuleSpec
Definition: ModuleSpec.h:27
lldb_private::Status
Definition: Status.h:44
lldb_private::PlatformDarwin::AddClangModuleCompilationOptionsForSDKType
void AddClangModuleCompilationOptionsForSDKType(Target *target, std::vector< std::string > &options, XcodeSDK::Type sdk_type)
Definition: PlatformDarwin.cpp:1012
lldb_private::PlatformAppleSimulator::GetCoreSimulatorPath
FileSpec GetCoreSimulatorPath()
Definition: PlatformAppleSimulator.cpp:227
lldb_private::PlatformAppleSimulator::m_supported_triples
llvm::SmallVector< llvm::StringRef, 4 > m_supported_triples
Definition: PlatformAppleSimulator.h:121
uint32_t
lldb_private::XcodeSDK::Type
Type
Different types of Xcode SDKs.
Definition: XcodeSDK.h:29
lldb_private::PlatformAppleSimulator::ConnectRemote
Status ConnectRemote(Args &args) override
Definition: PlatformAppleSimulator.cpp:132
CoreSimulatorSupport::DeviceType::ProductFamilyID
ProductFamilyID
Definition: PlatformiOSSimulatorCoreSimulatorSupport.h:72
CoreSimulatorSupport::Device
Definition: PlatformiOSSimulatorCoreSimulatorSupport.h:136
lldb_private::PlatformAppleSimulator::m_os_type
llvm::Triple::OSType m_os_type
Definition: PlatformAppleSimulator.h:120
lldb_private::PlatformAppleSimulator::CreateInstance
static lldb::PlatformSP CreateInstance(const char *class_name, const char *description, ConstString plugin_name, llvm::SmallVector< llvm::Triple::ArchType, 4 > supported_arch, llvm::Triple::OSType preferred_os, llvm::SmallVector< llvm::Triple::OSType, 4 > supported_os, llvm::SmallVector< llvm::StringRef, 4 > supported_triples, std::string sdk_name_preferred, std::string sdk_name_secondary, XcodeSDK::Type sdk_type, CoreSimulatorSupport::DeviceType::ProductFamilyID kind, bool force, const ArchSpec *arch)
Definition: PlatformAppleSimulator.cpp:298
lldb-forward.h
Status.h
lldb_private::PlatformAppleSimulator::GetPluginName
llvm::StringRef GetPluginName() override
Definition: PlatformAppleSimulator.h:69
lldb_private::PlatformAppleSimulator::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: PlatformAppleSimulator.cpp:376
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::PlatformAppleSimulator::m_core_simulator_framework_path
llvm::Optional< FileSpec > m_core_simulator_framework_path
Definition: PlatformAppleSimulator.h:114
lldb_private::PlatformAppleSimulator::FindProcesses
uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos) override
Attach to an existing process by process name.
Definition: PlatformAppleSimulator.cpp:512
lldb_private::LLDBLog::Target
@ Target
FileSpec.h
ConstString.h
llvm::SmallVectorImpl
Definition: Disassembler.h:42
lldb_private::PlatformAppleSimulator::GetSharedModule
Status GetSharedModule(const ModuleSpec &module_spec, Process *process, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr) override
Definition: PlatformAppleSimulator.cpp:484
lldb_private::ProcessInstanceInfoList
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
Definition: Host.h:31
lldb_private::PlatformDarwin
Definition: PlatformDarwin.h:45
lldb_private::PlatformAppleSimulator::GetSymbolFile
Status GetSymbolFile(const FileSpec &platform_file, const UUID *uuid_ptr, FileSpec &local_file)
Definition: PlatformAppleSimulator.cpp:451
PlatformDarwin.h