xref: /llvm-project/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.h (revision 322b4130415ac51ba48c993dfebc9c0b38d5bc32)
1 //===-- PlatformDarwinDevice.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_PLATFORMDARWINDEVICE_H
10 #define LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMDARWINDEVICE_H
11 
12 #include "PlatformDarwin.h"
13 
14 #include "llvm/ADT/StringRef.h"
15 
16 #include <string>
17 
18 namespace lldb_private {
19 
20 /// Abstract Darwin platform with a potential device support directory.
21 class PlatformDarwinDevice : public PlatformDarwin {
22 public:
23   using PlatformDarwin::PlatformDarwin;
24   ~PlatformDarwinDevice() override;
25 
26 protected:
27   virtual Status GetSharedModuleWithLocalCache(
28       const ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
29       const FileSpecList *module_search_paths_ptr,
30       llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr);
31 
32   struct SDKDirectoryInfo {
33     SDKDirectoryInfo(const FileSpec &sdk_dir_spec);
34     FileSpec directory;
35     ConstString build;
36     llvm::VersionTuple version;
37     bool user_cached;
38   };
39 
40   typedef std::vector<SDKDirectoryInfo> SDKDirectoryInfoCollection;
41 
42   bool UpdateSDKDirectoryInfosIfNeeded();
43 
44   const SDKDirectoryInfo *GetSDKDirectoryForLatestOSVersion();
45   const SDKDirectoryInfo *GetSDKDirectoryForCurrentOSVersion();
46 
47   static FileSystem::EnumerateDirectoryResult
48   GetContainedFilesIntoVectorOfStringsCallback(void *baton,
49                                                llvm::sys::fs::file_type ft,
50                                                llvm::StringRef path);
51 
52   const char *GetDeviceSupportDirectory();
53   const char *GetDeviceSupportDirectoryForOSVersion();
54 
55   virtual llvm::StringRef GetPlatformName() = 0;
56   virtual llvm::StringRef GetDeviceSupportDirectoryName() = 0;
57 
58   std::mutex m_sdk_dir_mutex;
59   SDKDirectoryInfoCollection m_sdk_directory_infos;
60 
61 private:
62   std::string m_device_support_directory;
63   std::string m_device_support_directory_for_os_version;
64 };
65 } // namespace lldb_private
66 
67 #endif // LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMDARWINDEVICE_H
68