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/SmallVector.h" |
21 | #include "llvm/ADT/StringRef.h" |
22 | #include "llvm/TargetParser/Triple.h" |
23 | |
24 | #include <mutex> |
25 | #include <optional> |
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 | std::string sdk_name_primary, std::string sdk_name_secondary, |
53 | XcodeSDK::Type sdk_type, |
54 | CoreSimulatorSupport::DeviceType::ProductFamilyID kind); |
55 | |
56 | static lldb::PlatformSP |
57 | CreateInstance(const char *class_name, const char *description, |
58 | ConstString plugin_name, |
59 | llvm::SmallVector<llvm::Triple::ArchType, 4> supported_arch, |
60 | llvm::Triple::OSType preferred_os, |
61 | llvm::SmallVector<llvm::Triple::OSType, 4> supported_os, |
62 | llvm::SmallVector<llvm::StringRef, 4> supported_triples, |
63 | std::string sdk_name_primary, std::string sdk_name_secondary, |
64 | XcodeSDK::Type sdk_type, |
65 | CoreSimulatorSupport::DeviceType::ProductFamilyID kind, |
66 | bool force, const ArchSpec *arch); |
67 | |
68 | ~PlatformAppleSimulator() override; |
69 | |
70 | llvm::StringRef GetPluginName() override { |
71 | return m_plugin_name.GetStringRef(); |
72 | } |
73 | llvm::StringRef GetDescription() override { return m_description; } |
74 | |
75 | Status LaunchProcess(ProcessLaunchInfo &launch_info) override; |
76 | |
77 | void GetStatus(Stream &strm) override; |
78 | |
79 | Status ConnectRemote(Args &args) override; |
80 | |
81 | Status DisconnectRemote() override; |
82 | |
83 | lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, |
84 | Debugger &debugger, Target &target, |
85 | Status &error) override; |
86 | |
87 | std::vector<ArchSpec> |
88 | GetSupportedArchitectures(const ArchSpec &process_host_arch) override; |
89 | |
90 | Status |
91 | ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, |
92 | const FileSpecList *module_search_paths_ptr) override; |
93 | |
94 | Status GetSharedModule(const ModuleSpec &module_spec, Process *process, |
95 | lldb::ModuleSP &module_sp, |
96 | const FileSpecList *module_search_paths_ptr, |
97 | llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, |
98 | bool *did_create_ptr) override; |
99 | |
100 | uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, |
101 | ProcessInstanceInfoList &process_infos) override; |
102 | |
103 | void |
104 | AddClangModuleCompilationOptions(Target *target, |
105 | std::vector<std::string> &options) override { |
106 | return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType( |
107 | target, options, sdk_type: m_sdk_type); |
108 | } |
109 | |
110 | protected: |
111 | const char *m_class_name; |
112 | const char *m_description; |
113 | ConstString m_plugin_name; |
114 | std::mutex m_core_sim_path_mutex; |
115 | std::optional<FileSpec> m_core_simulator_framework_path; |
116 | std::optional<CoreSimulatorSupport::Device> m_device; |
117 | CoreSimulatorSupport::DeviceType::ProductFamilyID m_kind; |
118 | |
119 | FileSpec GetCoreSimulatorPath(); |
120 | |
121 | llvm::StringRef GetSDKFilepath(); |
122 | |
123 | llvm::Triple::OSType m_os_type = llvm::Triple::UnknownOS; |
124 | llvm::SmallVector<llvm::StringRef, 4> m_supported_triples = {}; |
125 | std::string m_sdk_name_primary; |
126 | std::string m_sdk_name_secondary; |
127 | bool m_have_searched_for_sdk = false; |
128 | llvm::StringRef m_sdk; |
129 | XcodeSDK::Type m_sdk_type; |
130 | |
131 | void LoadCoreSimulator(); |
132 | |
133 | #if defined(__APPLE__) |
134 | CoreSimulatorSupport::Device GetSimulatorDevice(); |
135 | #endif |
136 | |
137 | private: |
138 | PlatformAppleSimulator(const PlatformAppleSimulator &) = delete; |
139 | const PlatformAppleSimulator & |
140 | operator=(const PlatformAppleSimulator &) = delete; |
141 | Status |
142 | |
143 | GetSymbolFile(const FileSpec &platform_file, const UUID *uuid_ptr, |
144 | FileSpec &local_file); |
145 | }; |
146 | |
147 | } // namespace lldb_private |
148 | |
149 | #endif // LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMAPPLESIMULATOR_H |
150 | |