9#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMDARWINKERNEL_H
10#define LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMDARWINKERNEL_H
20#include "llvm/ADT/SmallVector.h"
21#include "llvm/ADT/StringRef.h"
22#include "llvm/Support/Error.h"
23#include "llvm/Support/FileSystem.h"
43 static void DebuggerInitialize(Debugger &debugger);
45 static void Initialize();
47 static void Terminate();
51 static llvm::StringRef GetDescriptionStatic();
53 PlatformDarwinKernel(
LazyBool is_ios_debug_session);
55 ~PlatformDarwinKernel()
override;
59 llvm::StringRef GetDescription()
override {
return GetDescriptionStatic(); }
61 void GetStatus(Stream &strm)
override;
63 Status GetSharedModule(
const ModuleSpec &module_spec,
Target &target,
65 llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules,
66 bool *did_create_ptr)
override;
70 std::optional<ModuleSpec> FindModuleFiles(
const ModuleSpec &module_spec,
71 const FileSpecList &search_paths,
72 StatisticsMap &statistics)
override;
75 GetSupportedArchitectures(
const ArchSpec &process_host_arch)
override;
77 bool SupportsModules()
override {
return false; }
79 void CalculateTrapHandlerSymbolNames()
override;
85 typedef std::multimap<ConstString, FileSpec> BundleIDToKextMap;
87 typedef std::vector<FileSpec> KernelBinaryCollection;
91 typedef std::vector<FileSpec> DirectoriesSearchedCollection;
92 typedef DirectoriesSearchedCollection::iterator DirectoriesSearchedIterator;
96 void CollectKextAndKernelDirectories();
98 void GetUserSpecifiedDirectoriesToSearch();
100 static void AddRootSubdirsToSearchPaths(PlatformDarwinKernel *thisp,
101 const std::string &dir);
103 void AddSDKSubdirsToSearchPaths(
const std::string &dir);
106 FindKDKandSDKDirectoriesInDirectory(
void *baton, llvm::sys::fs::file_type ft,
107 llvm::StringRef path);
109 void SearchForKextsAndKernelsRecursively();
112 GetKernelsAndKextsInDirectoryWithRecursion(
void *baton,
113 llvm::sys::fs::file_type ft,
114 llvm::StringRef path);
117 GetKernelsAndKextsInDirectoryNoRecursion(
void *baton,
118 llvm::sys::fs::file_type ft,
119 llvm::StringRef path);
122 GetKernelsAndKextsInDirectoryHelper(
void *baton, llvm::sys::fs::file_type ft,
123 llvm::StringRef path,
bool recurse);
125 static std::vector<FileSpec>
126 SearchForExecutablesRecursively(
const std::string &dir);
128 static void AddKextToMap(PlatformDarwinKernel *thisp,
129 const FileSpec &file_spec);
133 static bool KextHasdSYMSibling(
const FileSpec &kext_bundle_filepath);
136 static bool KernelHasdSYMSibling(
const FileSpec &kernel_filepath);
140 KerneldSYMHasNoSiblingBinary(
const FileSpec &kernel_dsym_filepath);
146 static std::vector<FileSpec>
147 GetDWARFBinaryInDSYMBundle(
const FileSpec &dsym_bundle);
149 llvm::Expected<lldb::ModuleSP>
150 GetSharedModuleKext(
const ModuleSpec &module_spec,
Target &target,
151 llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules,
152 bool *did_create_ptr);
154 llvm::Expected<lldb::ModuleSP>
155 GetSharedModuleKernel(
const ModuleSpec &module_spec,
Target &target,
156 llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules,
157 bool *did_create_ptr);
165 const FileSpecList &search_paths);
167 lldb::ModuleSP ExamineKextForMatchingUUID(
const FileSpec &kext_bundle_path,
169 const ArchSpec &arch);
172 bool notify)
override;
174 void UpdateKextandKernelsLocalScan();
184 BundleIDToKextMap m_name_to_kext_path_map_with_dsyms;
188 BundleIDToKextMap m_name_to_kext_path_map_without_dsyms;
191 DirectoriesSearchedCollection m_search_directories;
194 DirectoriesSearchedCollection m_search_directories_no_recursing;
198 KernelBinaryCollection m_kernel_binaries_with_dsyms;
202 KernelBinaryCollection m_kernel_binaries_without_dsyms;
205 KernelBinaryCollection m_kernel_dsyms_no_binaries;
208 KernelBinaryCollection m_kernel_dsyms_yaas;
212 std::once_flag m_kext_scan_flag;
214 PlatformDarwinKernel(
const PlatformDarwinKernel &) =
delete;
215 const PlatformDarwinKernel &operator=(
const PlatformDarwinKernel &) =
delete;
An architecture specification class.
A class to manage flag bits.
A plug-in interface definition class for debugging a process.
A stream class that can stream formatted output to a file.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Platform > PlatformSP
std::shared_ptr< lldb_private::Module > ModuleSP