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 "Plugins/Platform/MacOSX/PlatformDarwin.h" 13 #include "Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h" 14 #include "lldb/Utility/ConstString.h" 15 #include "lldb/Utility/FileSpec.h" 16 #include "lldb/Utility/ProcessInfo.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 40 class PlatformAppleSimulator : public PlatformDarwin { 41 public: 42 // Class Functions 43 static void Initialize(); 44 45 static void Terminate(); 46 47 // Class Methods 48 PlatformAppleSimulator( 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, 53 CoreSimulatorSupport::DeviceType::ProductFamilyID kind); 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 llvm::StringRef sdk, XcodeSDK::Type sdk_type, 63 CoreSimulatorSupport::DeviceType::ProductFamilyID kind, 64 bool force, const ArchSpec *arch); 65 66 virtual ~PlatformAppleSimulator(); 67 68 llvm::StringRef GetPluginName() override { 69 return m_plugin_name.GetStringRef(); 70 } 71 llvm::StringRef GetDescription() override { return m_description; } 72 73 Status LaunchProcess(ProcessLaunchInfo &launch_info) override; 74 75 void GetStatus(Stream &strm) override; 76 77 Status ConnectRemote(Args &args) override; 78 79 Status DisconnectRemote() override; 80 81 lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, 82 Debugger &debugger, Target &target, 83 Status &error) override; 84 85 std::vector<ArchSpec> 86 GetSupportedArchitectures(const ArchSpec &process_host_arch) override; 87 88 Status 89 ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, 90 const FileSpecList *module_search_paths_ptr) override; 91 92 Status GetSharedModule(const ModuleSpec &module_spec, Process *process, 93 lldb::ModuleSP &module_sp, 94 const FileSpecList *module_search_paths_ptr, 95 llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, 96 bool *did_create_ptr) override; 97 98 uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, 99 ProcessInstanceInfoList &process_infos) override; 100 101 void 102 AddClangModuleCompilationOptions(Target *target, 103 std::vector<std::string> &options) override { 104 return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType( 105 target, options, m_sdk_type); 106 } 107 108 protected: 109 const char *m_class_name; 110 const char *m_description; 111 ConstString m_plugin_name; 112 std::mutex m_core_sim_path_mutex; 113 llvm::Optional<FileSpec> m_core_simulator_framework_path; 114 llvm::Optional<CoreSimulatorSupport::Device> m_device; 115 CoreSimulatorSupport::DeviceType::ProductFamilyID m_kind; 116 117 FileSpec GetCoreSimulatorPath(); 118 119 llvm::Triple::OSType m_os_type = llvm::Triple::UnknownOS; 120 llvm::SmallVector<llvm::StringRef, 4> m_supported_triples = {}; 121 llvm::StringRef m_sdk; 122 XcodeSDK::Type m_sdk_type; 123 124 void LoadCoreSimulator(); 125 126 #if defined(__APPLE__) 127 CoreSimulatorSupport::Device GetSimulatorDevice(); 128 #endif 129 130 private: 131 PlatformAppleSimulator(const PlatformAppleSimulator &) = delete; 132 const PlatformAppleSimulator & 133 operator=(const PlatformAppleSimulator &) = delete; 134 Status 135 136 GetSymbolFile(const FileSpec &platform_file, const UUID *uuid_ptr, 137 FileSpec &local_file); 138 }; 139 140 } // namespace lldb_private 141 142 #endif // LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMAPPLESIMULATOR_H 143