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