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 14 #include "Plugins/Platform/MacOSX/PlatformDarwin.h" 15 #include "Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h" 16 #include "lldb/Utility/ConstString.h" 17 #include "lldb/Utility/FileSpec.h" 18 19 #include "llvm/ADT/Optional.h" 20 21 class PlatformAppleSimulator : public PlatformDarwin { 22 public: 23 // Class Functions 24 static void Initialize(); 25 26 static void Terminate(); 27 28 // Class Methods 29 PlatformAppleSimulator( 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, 34 CoreSimulatorSupport::DeviceType::ProductFamilyID kind); 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, 44 CoreSimulatorSupport::DeviceType::ProductFamilyID kind, 45 bool force, const lldb_private::ArchSpec *arch); 46 47 virtual ~PlatformAppleSimulator(); 48 GetPluginName()49 lldb_private::ConstString GetPluginName() override { return m_plugin_name; } GetDescription()50 const char *GetDescription() override { return m_description; } GetPluginVersion()51 uint32_t GetPluginVersion() override { return 1; } 52 53 lldb_private::Status 54 LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override; 55 56 void GetStatus(lldb_private::Stream &strm) override; 57 58 lldb_private::Status ConnectRemote(lldb_private::Args &args) override; 59 60 lldb_private::Status DisconnectRemote() override; 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 67 bool GetSupportedArchitectureAtIndex(uint32_t idx, 68 lldb_private::ArchSpec &arch) override; 69 70 lldb_private::Status ResolveExecutable( 71 const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, 72 const lldb_private::FileSpecList *module_search_paths_ptr) override; 73 74 lldb_private::Status 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, 78 llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, 79 bool *did_create_ptr) override; 80 81 uint32_t 82 FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info, 83 lldb_private::ProcessInstanceInfoList &process_infos) override; 84 85 void AddClangModuleCompilationOptions(lldb_private::Target * target,std::vector<std::string> & options)86 AddClangModuleCompilationOptions(lldb_private::Target *target, 87 std::vector<std::string> &options) override { 88 return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType( 89 target, options, m_sdk_type); 90 } 91 92 protected: 93 const char *m_class_name; 94 const char *m_description; 95 lldb_private::ConstString m_plugin_name; 96 std::mutex m_core_sim_path_mutex; 97 llvm::Optional<lldb_private::FileSpec> m_core_simulator_framework_path; 98 llvm::Optional<CoreSimulatorSupport::Device> m_device; 99 CoreSimulatorSupport::DeviceType::ProductFamilyID m_kind; 100 101 lldb_private::FileSpec GetCoreSimulatorPath(); 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; 106 lldb_private::XcodeSDK::Type m_sdk_type; 107 108 void LoadCoreSimulator(); 109 110 #if defined(__APPLE__) 111 CoreSimulatorSupport::Device GetSimulatorDevice(); 112 #endif 113 114 private: 115 PlatformAppleSimulator(const PlatformAppleSimulator &) = delete; 116 const PlatformAppleSimulator & 117 operator=(const PlatformAppleSimulator &) = delete; 118 lldb_private::Status 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 126