1 //===-- PlatformRemoteiOS.h -------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef liblldb_PlatformRemoteiOS_h_
11 #define liblldb_PlatformRemoteiOS_h_
12 
13 // C Includes
14 // C++ Includes
15 #include <string>
16 
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/Host/FileSpec.h"
20 #include "PlatformDarwin.h"
21 
22 class PlatformRemoteiOS : public PlatformDarwin
23 {
24 public:
25     PlatformRemoteiOS ();
26 
27     ~PlatformRemoteiOS() override;
28 
29     //------------------------------------------------------------
30     // Class Functions
31     //------------------------------------------------------------
32     static lldb::PlatformSP
33     CreateInstance (bool force, const lldb_private::ArchSpec *arch);
34 
35     static void
36     Initialize ();
37 
38     static void
39     Terminate ();
40 
41     static lldb_private::ConstString
42     GetPluginNameStatic ();
43 
44     static const char *
45     GetDescriptionStatic();
46 
47     //------------------------------------------------------------
48     // lldb_private::PluginInterface functions
49     //------------------------------------------------------------
50     lldb_private::ConstString
51     GetPluginName() override
52     {
53         return GetPluginNameStatic();
54     }
55 
56     uint32_t
57     GetPluginVersion() override
58     {
59         return 1;
60     }
61 
62     //------------------------------------------------------------
63     // lldb_private::Platform functions
64     //------------------------------------------------------------
65     lldb_private::Error
66     ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
67                        lldb::ModuleSP &module_sp,
68                        const lldb_private::FileSpecList *module_search_paths_ptr) override;
69 
70     const char *
71     GetDescription () override
72     {
73         return GetDescriptionStatic();
74     }
75 
76     void
77     GetStatus (lldb_private::Stream &strm) override;
78 
79     virtual lldb_private::Error
80     GetSymbolFile (const lldb_private::FileSpec &platform_file,
81                    const lldb_private::UUID *uuid_ptr,
82                    lldb_private::FileSpec &local_file);
83 
84     lldb_private::Error
85     GetSharedModule (const lldb_private::ModuleSpec &module_spec,
86                      lldb_private::Process* process,
87                      lldb::ModuleSP &module_sp,
88                      const lldb_private::FileSpecList *module_search_paths_ptr,
89                      lldb::ModuleSP *old_module_sp_ptr,
90                      bool *did_create_ptr) override;
91 
92     bool
93     GetSupportedArchitectureAtIndex (uint32_t idx,
94                                      lldb_private::ArchSpec &arch) override;
95 
96     void
97     AddClangModuleCompilationOptions (lldb_private::Target *target, std::vector<std::string> &options) override
98     {
99         return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(target, options, PlatformDarwin::SDKType::iPhoneOS);
100     }
101 
102 protected:
103     struct SDKDirectoryInfo
104     {
105         SDKDirectoryInfo (const lldb_private::FileSpec &sdk_dir_spec);
106         lldb_private::FileSpec directory;
107         lldb_private::ConstString build;
108         uint32_t version_major;
109         uint32_t version_minor;
110         uint32_t version_update;
111         bool user_cached;
112     };
113 
114     typedef std::vector<SDKDirectoryInfo> SDKDirectoryInfoCollection;
115 
116     SDKDirectoryInfoCollection m_sdk_directory_infos;
117     std::string m_device_support_directory;
118     std::string m_device_support_directory_for_os_version;
119     std::string m_build_update;
120     uint32_t m_last_module_sdk_idx;
121     uint32_t m_connected_module_sdk_idx;
122 
123     bool
124     UpdateSDKDirectoryInfosIfNeeded();
125 
126     const char *
127     GetDeviceSupportDirectory();
128 
129     const char *
130     GetDeviceSupportDirectoryForOSVersion();
131 
132     const SDKDirectoryInfo *
133     GetSDKDirectoryForLatestOSVersion ();
134 
135     const SDKDirectoryInfo *
136     GetSDKDirectoryForCurrentOSVersion ();
137 
138     static lldb_private::FileSpec::EnumerateDirectoryResult
139     GetContainedFilesIntoVectorOfStringsCallback (void *baton,
140                                                   lldb_private::FileSpec::FileType file_type,
141                                                   const lldb_private::FileSpec &file_spec);
142 
143     uint32_t
144     FindFileInAllSDKs (const char *platform_file_path,
145                        lldb_private::FileSpecList &file_list);
146 
147     bool
148     GetFileInSDK (const char *platform_file_path,
149                   uint32_t sdk_idx,
150                   lldb_private::FileSpec &local_file);
151 
152     bool
153     GetFileInSDKRoot (const char *platform_file_path,
154                       const char *sdkroot_path,
155                       bool symbols_dirs_only,
156                       lldb_private::FileSpec &local_file);
157 
158     uint32_t
159     FindFileInAllSDKs (const lldb_private::FileSpec &platform_file,
160                        lldb_private::FileSpecList &file_list);
161 
162     uint32_t
163     GetConnectedSDKIndex ();
164 
165     // Get index of SDK in SDKDirectoryInfoCollection by its pointer and return UINT32_MAX if that SDK not found.
166     uint32_t
167     GetSDKIndexBySDKDirectoryInfo (const SDKDirectoryInfo *sdk_info);
168 
169 private:
170     DISALLOW_COPY_AND_ASSIGN (PlatformRemoteiOS);
171 };
172 
173 #endif // liblldb_PlatformRemoteiOS_h_
174