diff options
author | Jason Molenda <jason@molenda.com> | 2023-05-16 18:15:59 -0700 |
---|---|---|
committer | Jason Molenda <jason@molenda.com> | 2023-05-16 18:15:59 -0700 |
commit | e3227e74e3bfab7c5aed07c20b515202275ce7c4 (patch) | |
tree | e8c6c058c049a0ed47d6470235d4cafb81d74557 /lldb | |
parent | d6811826371d82de074d0c3e10040114eee69897 (diff) | |
download | llvm-e3227e74e3bfab7c5aed07c20b515202275ce7c4.tar.gz |
lldb PlatformDarwinKernel make local filesystem scan lazy
Instead of doing the local filesystem scan for kexts and kernels
when the PlatformDarwinKernel is constructed, delay doing it until
the scan is needed.
Differential Revision: https://reviews.llvm.org/D150621
rdar://109186357
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp | 17 | ||||
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h | 4 |
2 files changed, 15 insertions, 6 deletions
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp index c29007fb9a34..d120ae05c82b 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -229,12 +229,8 @@ PlatformDarwinKernel::PlatformDarwinKernel( m_name_to_kext_path_map_without_dsyms(), m_search_directories(), m_search_directories_no_recursing(), m_kernel_binaries_with_dsyms(), m_kernel_binaries_without_dsyms(), m_kernel_dsyms_no_binaries(), - m_kernel_dsyms_yaas(), m_ios_debug_session(is_ios_debug_session) - -{ - CollectKextAndKernelDirectories(); - SearchForKextsAndKernelsRecursively(); -} + m_kernel_dsyms_yaas(), m_ios_debug_session(is_ios_debug_session), + m_kext_scan_flag() {} /// Destructor. /// @@ -243,6 +239,7 @@ PlatformDarwinKernel::PlatformDarwinKernel( PlatformDarwinKernel::~PlatformDarwinKernel() = default; void PlatformDarwinKernel::GetStatus(Stream &strm) { + UpdateKextandKernelsLocalScan(); Platform::GetStatus(strm); strm.Printf(" Debug session type: "); if (m_ios_debug_session == eLazyBoolYes) @@ -709,6 +706,13 @@ PlatformDarwinKernel::GetDWARFBinaryInDSYMBundle(const FileSpec &dsym_bundle) { return results; } +void PlatformDarwinKernel::UpdateKextandKernelsLocalScan() { + std::call_once(m_kext_scan_flag, [this]() { + CollectKextAndKernelDirectories(); + SearchForKextsAndKernelsRecursively(); + }); +} + Status PlatformDarwinKernel::GetSharedModule( const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, @@ -789,6 +793,7 @@ Status PlatformDarwinKernel::GetSharedModuleKernel( llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) { Status error; module_sp.reset(); + UpdateKextandKernelsLocalScan(); // First try all kernel binaries that have a dSYM next to them for (auto possible_kernel : m_kernel_binaries_with_dsyms) { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h index e28f77cd44d5..9db9c0065613 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h @@ -158,6 +158,8 @@ protected: bool LoadPlatformBinaryAndSetup(Process *process, lldb::addr_t addr, bool notify) override; + void UpdateKextandKernelsLocalScan(); + // Most of the ivars are assembled under FileSystem::EnumerateDirectory calls // where the function being called for each file/directory must be static. // We'll pass a this pointer as a baton and access the ivars directly. @@ -194,6 +196,8 @@ public: LazyBool m_ios_debug_session; + std::once_flag m_kext_scan_flag; + PlatformDarwinKernel(const PlatformDarwinKernel &) = delete; const PlatformDarwinKernel &operator=(const PlatformDarwinKernel &) = delete; }; |