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 
12 #include <mutex>
13 
17 #include "lldb/Utility/FileSpec.h"
18 
19 #include "llvm/ADT/Optional.h"
20 
22 public:
23  // Class Functions
24  static void Initialize();
25 
26  static void Terminate();
27 
28  // Class Methods
30  const char *class_name, const char *description,
31  lldb_private::ConstString plugin_name, llvm::Triple::OSType preferred_os,
32  llvm::SmallVector<llvm::StringRef, 4> supported_triples,
33  llvm::StringRef sdk, lldb_private::XcodeSDK::Type sdk_type,
35 
36  static lldb::PlatformSP
37  CreateInstance(const char *class_name, const char *description,
38  lldb_private::ConstString plugin_name,
39  llvm::SmallVector<llvm::Triple::ArchType, 4> supported_arch,
40  llvm::Triple::OSType preferred_os,
41  llvm::SmallVector<llvm::Triple::OSType, 4> supported_os,
42  llvm::SmallVector<llvm::StringRef, 4> supported_triples,
43  llvm::StringRef sdk, lldb_private::XcodeSDK::Type sdk_type,
45  bool force, const lldb_private::ArchSpec *arch);
46 
47  virtual ~PlatformAppleSimulator();
48 
50  const char *GetDescription() override { return m_description; }
51  uint32_t GetPluginVersion() override { return 1; }
52 
54  LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
55 
56  void GetStatus(lldb_private::Stream &strm) override;
57 
59 
61 
62  lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
63  lldb_private::Debugger &debugger,
64  lldb_private::Target *target,
65  lldb_private::Status &error) override;
66 
68  lldb_private::ArchSpec &arch) override;
69 
71  const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
72  const lldb_private::FileSpecList *module_search_paths_ptr) override;
73 
75  GetSharedModule(const lldb_private::ModuleSpec &module_spec,
76  lldb_private::Process *process, lldb::ModuleSP &module_sp,
77  const lldb_private::FileSpecList *module_search_paths_ptr,
79  bool *did_create_ptr) override;
80 
81  uint32_t
83  lldb_private::ProcessInstanceInfoList &process_infos) override;
84 
85  void
87  std::vector<std::string> &options) override {
89  target, options, m_sdk_type);
90  }
91 
92 protected:
93  const char *m_class_name;
94  const char *m_description;
97  llvm::Optional<lldb_private::FileSpec> m_core_simulator_framework_path;
98  llvm::Optional<CoreSimulatorSupport::Device> m_device;
100 
102 
103  llvm::Triple::OSType m_os_type = llvm::Triple::UnknownOS;
104  llvm::SmallVector<llvm::StringRef, 4> m_supported_triples = {};
105  llvm::StringRef m_sdk;
107 
108  void LoadCoreSimulator();
109 
110 #if defined(__APPLE__)
111  CoreSimulatorSupport::Device GetSimulatorDevice();
112 #endif
113 
114 private:
116  const PlatformAppleSimulator &
117  operator=(const PlatformAppleSimulator &) = delete;
119 
120  GetSymbolFile(const lldb_private::FileSpec &platform_file,
121  const lldb_private::UUID *uuid_ptr,
122  lldb_private::FileSpec &local_file);
123 };
124 
125 #endif // LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMAPPLESIMULATOR_H
PlatformAppleSimulator::m_core_sim_path_mutex
std::mutex m_core_sim_path_mutex
Definition: PlatformAppleSimulator.h:96
lldb_private::UUID
Definition: UUID.h:23
PlatformAppleSimulator::DebugProcess
lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info, lldb_private::Debugger &debugger, lldb_private::Target *target, lldb_private::Status &error) override
Subclasses do not need to implement this function as it uses the Platform::LaunchProcess() followed b...
Definition: PlatformAppleSimulator.cpp:180
lldb_private::ArchSpec
Definition: ArchSpec.h:33
PlatformAppleSimulator::GetPluginVersion
uint32_t GetPluginVersion() override
Definition: PlatformAppleSimulator.h:51
PlatformAppleSimulator::operator=
const PlatformAppleSimulator & operator=(const PlatformAppleSimulator &)=delete
PlatformAppleSimulator::m_sdk_type
lldb_private::XcodeSDK::Type m_sdk_type
Definition: PlatformAppleSimulator.h:106
PlatformAppleSimulator
Definition: PlatformAppleSimulator.h:21
PlatformAppleSimulator::GetStatus
void GetStatus(lldb_private::Stream &strm) override
Report the current status for this platform.
Definition: PlatformAppleSimulator.cpp:82
PlatformAppleSimulator::~PlatformAppleSimulator
virtual ~PlatformAppleSimulator()
Destructor.
Definition: PlatformAppleSimulator.cpp:53
lldb_private::Process
Definition: Process.h:342
PlatformAppleSimulator::DisconnectRemote
lldb_private::Status DisconnectRemote() override
Definition: PlatformAppleSimulator.cpp:169
lldb_private::ProcessInstanceInfoMatch
Definition: ProcessInfo.h:165
PlatformAppleSimulator::Initialize
static void Initialize()
Definition: PlatformAppleSimulator.cpp:664
PlatformAppleSimulator::m_kind
CoreSimulatorSupport::DeviceType::ProductFamilyID m_kind
Definition: PlatformAppleSimulator.h:99
PlatformAppleSimulator::GetSharedModule
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, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr) override
Definition: PlatformAppleSimulator.cpp:461
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Args
Definition: Args.h:33
lldb_private::Target
Definition: Target.h:445
PlatformDarwin
Definition: PlatformDarwin.h:25
lldb_private::FileSpec
Definition: FileSpec.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
PlatformAppleSimulator::CreateInstance
static lldb::PlatformSP CreateInstance(const char *class_name, const char *description, lldb_private::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, llvm::StringRef sdk, lldb_private::XcodeSDK::Type sdk_type, CoreSimulatorSupport::DeviceType::ProductFamilyID kind, bool force, const lldb_private::ArchSpec *arch)
Definition: PlatformAppleSimulator.cpp:277
PlatformAppleSimulator::GetSupportedArchitectureAtIndex
bool GetSupportedArchitectureAtIndex(uint32_t idx, lldb_private::ArchSpec &arch) override
Get the platform's supported architectures in the order in which they should be searched.
Definition: PlatformAppleSimulator.cpp:269
PlatformiOSSimulatorCoreSimulatorSupport.h
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
PlatformDarwin::AddClangModuleCompilationOptionsForSDKType
void AddClangModuleCompilationOptionsForSDKType(lldb_private::Target *target, std::vector< std::string > &options, lldb_private::XcodeSDK::Type sdk_type)
Definition: PlatformDarwin.cpp:1513
PlatformAppleSimulator::ConnectRemote
lldb_private::Status ConnectRemote(lldb_private::Args &args) override
Definition: PlatformAppleSimulator.cpp:130
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::Debugger
Definition: Debugger.h:70
PlatformAppleSimulator::GetSymbolFile
lldb_private::Status GetSymbolFile(const lldb_private::FileSpec &platform_file, const lldb_private::UUID *uuid_ptr, lldb_private::FileSpec &local_file)
Definition: PlatformAppleSimulator.cpp:428
PlatformAppleSimulator::GetDescription
const char * GetDescription() override
Definition: PlatformAppleSimulator.h:50
PlatformAppleSimulator::GetCoreSimulatorPath
lldb_private::FileSpec GetCoreSimulatorPath()
Definition: PlatformAppleSimulator.cpp:226
PlatformAppleSimulator::PlatformAppleSimulator
PlatformAppleSimulator(const char *class_name, const char *description, lldb_private::ConstString plugin_name, llvm::Triple::OSType preferred_os, llvm::SmallVector< llvm::StringRef, 4 > supported_triples, llvm::StringRef sdk, lldb_private::XcodeSDK::Type sdk_type, CoreSimulatorSupport::DeviceType::ProductFamilyID kind)
Default Constructor.
Definition: PlatformAppleSimulator.cpp:38
lldb_private::ModuleSpec
Definition: ModuleSpec.h:26
lldb_private::Status
Definition: Status.h:44
PlatformAppleSimulator::ResolveExecutable
lldb_private::Status ResolveExecutable(const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr) override
Definition: PlatformAppleSimulator.cpp:352
uint32_t
lldb_private::XcodeSDK::Type
Type
Different types of Xcode SDKs.
Definition: XcodeSDK.h:29
CoreSimulatorSupport::DeviceType::ProductFamilyID
ProductFamilyID
Definition: PlatformiOSSimulatorCoreSimulatorSupport.h:72
PlatformAppleSimulator::LaunchProcess
lldb_private::Status LaunchProcess(lldb_private::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:55
CoreSimulatorSupport::Device
Definition: PlatformiOSSimulatorCoreSimulatorSupport.h:136
PlatformAppleSimulator::m_os_type
llvm::Triple::OSType m_os_type
Definition: PlatformAppleSimulator.h:103
PlatformAppleSimulator::m_core_simulator_framework_path
llvm::Optional< lldb_private::FileSpec > m_core_simulator_framework_path
Definition: PlatformAppleSimulator.h:97
PlatformAppleSimulator::Terminate
static void Terminate()
Definition: PlatformAppleSimulator.cpp:673
PlatformAppleSimulator::GetPluginName
lldb_private::ConstString GetPluginName() override
Definition: PlatformAppleSimulator.h:49
PlatformAppleSimulator::m_supported_triples
llvm::SmallVector< llvm::StringRef, 4 > m_supported_triples
Definition: PlatformAppleSimulator.h:104
PlatformAppleSimulator::FindProcesses
uint32_t FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info, lldb_private::ProcessInstanceInfoList &process_infos) override
Attach to an existing process by process name.
Definition: PlatformAppleSimulator.cpp:489
PlatformAppleSimulator::m_sdk
llvm::StringRef m_sdk
Definition: PlatformAppleSimulator.h:105
FileSpec.h
ConstString.h
PlatformAppleSimulator::AddClangModuleCompilationOptions
void AddClangModuleCompilationOptions(lldb_private::Target *target, std::vector< std::string > &options) override
Definition: PlatformAppleSimulator.h:86
llvm::SmallVectorImpl
Definition: Disassembler.h:42
PlatformAppleSimulator::m_description
const char * m_description
Definition: PlatformAppleSimulator.h:94
PlatformAppleSimulator::m_class_name
const char * m_class_name
Definition: PlatformAppleSimulator.h:93
PlatformAppleSimulator::m_device
llvm::Optional< CoreSimulatorSupport::Device > m_device
Definition: PlatformAppleSimulator.h:98
lldb_private::ProcessInstanceInfoList
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
Definition: Host.h:30
PlatformAppleSimulator::LoadCoreSimulator
void LoadCoreSimulator()
Definition: PlatformAppleSimulator.cpp:241
PlatformAppleSimulator::m_plugin_name
lldb_private::ConstString m_plugin_name
Definition: PlatformAppleSimulator.h:95
PlatformDarwin.h