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