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