1 //===-- PlatformDarwinKernel.h ----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_PlatformDarwinKernel_h_
11 #define liblldb_PlatformDarwinKernel_h_
13 #include "lldb/Core/ConstString.h"
15 #if defined(__APPLE__) // This Plugin uses the Mac-specific
16 // source/Host/macosx/cfcpp utilities
20 // Other libraries and framework includes
21 #include "lldb/Host/FileSpec.h"
24 #include "PlatformDarwin.h"
26 class PlatformDarwinKernel : public PlatformDarwin {
28 //------------------------------------------------------------
30 //------------------------------------------------------------
31 static lldb::PlatformSP CreateInstance(bool force,
32 const lldb_private::ArchSpec *arch);
34 static void DebuggerInitialize(lldb_private::Debugger &debugger);
36 static void Initialize();
38 static void Terminate();
40 static lldb_private::ConstString GetPluginNameStatic();
42 static const char *GetDescriptionStatic();
44 //------------------------------------------------------------
46 //------------------------------------------------------------
47 PlatformDarwinKernel(lldb_private::LazyBool is_ios_debug_session);
49 virtual ~PlatformDarwinKernel();
51 //------------------------------------------------------------
52 // lldb_private::PluginInterface functions
53 //------------------------------------------------------------
54 lldb_private::ConstString GetPluginName() override {
55 return GetPluginNameStatic();
58 uint32_t GetPluginVersion() override { return 1; }
60 //------------------------------------------------------------
61 // lldb_private::Platform functions
62 //------------------------------------------------------------
63 const char *GetDescription() override { return GetDescriptionStatic(); }
65 void GetStatus(lldb_private::Stream &strm) override;
68 GetSharedModule(const lldb_private::ModuleSpec &module_spec,
69 lldb_private::Process *process, lldb::ModuleSP &module_sp,
70 const lldb_private::FileSpecList *module_search_paths_ptr,
71 lldb::ModuleSP *old_module_sp_ptr,
72 bool *did_create_ptr) override;
74 bool GetSupportedArchitectureAtIndex(uint32_t idx,
75 lldb_private::ArchSpec &arch) override;
77 bool SupportsModules() override { return false; }
79 void CalculateTrapHandlerSymbolNames() override;
82 // Map from kext bundle ID ("com.apple.filesystems.exfat") to FileSpec for the
84 // the host ("/System/Library/Extensions/exfat.kext/Contents/Info.plist").
85 typedef std::multimap<lldb_private::ConstString, lldb_private::FileSpec>
87 typedef BundleIDToKextMap::iterator BundleIDToKextIterator;
89 typedef std::vector<lldb_private::FileSpec> KernelBinaryCollection;
91 // Array of directories that were searched for kext bundles (used only for
93 typedef std::vector<lldb_private::FileSpec> DirectoriesSearchedCollection;
94 typedef DirectoriesSearchedCollection::iterator DirectoriesSearchedIterator;
96 // Populate m_search_directories and m_search_directories_no_recursing vectors
98 void CollectKextAndKernelDirectories();
100 void GetUserSpecifiedDirectoriesToSearch();
102 static void AddRootSubdirsToSearchPaths(PlatformDarwinKernel *thisp,
103 const std::string &dir);
105 void AddSDKSubdirsToSearchPaths(const std::string &dir);
107 static lldb_private::FileSpec::EnumerateDirectoryResult
108 FindKDKandSDKDirectoriesInDirectory(
109 void *baton, lldb_private::FileSpec::FileType file_type,
110 const lldb_private::FileSpec &file_spec);
112 void SearchForKextsAndKernelsRecursively();
114 static lldb_private::FileSpec::EnumerateDirectoryResult
115 GetKernelsAndKextsInDirectoryWithRecursion(
116 void *baton, lldb_private::FileSpec::FileType file_type,
117 const lldb_private::FileSpec &file_spec);
119 static lldb_private::FileSpec::EnumerateDirectoryResult
120 GetKernelsAndKextsInDirectoryNoRecursion(
121 void *baton, lldb_private::FileSpec::FileType file_type,
122 const lldb_private::FileSpec &file_spec);
124 static lldb_private::FileSpec::EnumerateDirectoryResult
125 GetKernelsAndKextsInDirectoryHelper(
126 void *baton, lldb_private::FileSpec::FileType file_type,
127 const lldb_private::FileSpec &file_spec, bool recurse);
129 static void AddKextToMap(PlatformDarwinKernel *thisp,
130 const lldb_private::FileSpec &file_spec);
132 // Returns true if there is a .dSYM bundle next to the kext, or next to the
133 // binary inside the kext.
135 KextHasdSYMSibling(const lldb_private::FileSpec &kext_bundle_filepath);
137 // Returns true if there is a .dSYM bundle next to the kernel
139 KernelHasdSYMSibling(const lldb_private::FileSpec &kext_bundle_filepath);
142 ExamineKextForMatchingUUID(const lldb_private::FileSpec &kext_bundle_path,
143 const lldb_private::UUID &uuid,
144 const lldb_private::ArchSpec &arch,
145 lldb::ModuleSP &exe_module_sp);
147 // Most of the ivars are assembled under FileSpec::EnumerateDirectory calls
149 // function being called for each file/directory must be static. We'll pass a
151 // as a baton and access the ivars directly. Toss-up whether this should just
156 BundleIDToKextMap m_name_to_kext_path_map_with_dsyms; // multimap of
160 // with dSYMs next to
162 BundleIDToKextMap m_name_to_kext_path_map_without_dsyms; // multimap of
166 // without dSYMs next
168 DirectoriesSearchedCollection
169 m_search_directories; // list of directories we search for kexts/kernels
170 DirectoriesSearchedCollection
171 m_search_directories_no_recursing; // list of directories we search for
172 // kexts/kernels, no recursion
173 KernelBinaryCollection m_kernel_binaries_with_dsyms; // list of kernel
174 // binaries we found on
176 // without dSYMs next to
178 KernelBinaryCollection m_kernel_binaries_without_dsyms; // list of kernel
182 // dSYMs next to them
183 lldb_private::LazyBool m_ios_debug_session;
185 DISALLOW_COPY_AND_ASSIGN(PlatformDarwinKernel);
190 // Since DynamicLoaderDarwinKernel is compiled in for all systems, and relies on
191 // PlatformDarwinKernel for the plug-in name, we compile just the plug-in name
193 // here to avoid issues. We are tracking an internal bug to resolve this issue
195 // either not compiling in DynamicLoaderDarwinKernel for non-apple builds, or to
197 // PlatformDarwinKernel build on all systems. PlatformDarwinKernel is currently
199 // compiled on other platforms due to the use of the Mac-specific
200 // source/Host/macosx/cfcpp utilities.
202 class PlatformDarwinKernel {
203 static lldb_private::ConstString GetPluginNameStatic();
208 #endif // liblldb_PlatformDarwinKernel_h_