@@ -234,12 +234,8 @@ PlatformDarwinKernel::PlatformDarwinKernel(
234234 m_name_to_kext_path_map_without_dsyms(), m_search_directories(),
235235 m_search_directories_no_recursing(), m_kernel_binaries_with_dsyms(),
236236 m_kernel_binaries_without_dsyms(), m_kernel_dsyms_no_binaries(),
237- m_kernel_dsyms_yaas(), m_ios_debug_session(is_ios_debug_session)
238-
239- {
240- CollectKextAndKernelDirectories ();
241- SearchForKextsAndKernelsRecursively ();
242- }
237+ m_kernel_dsyms_yaas(), m_ios_debug_session(is_ios_debug_session),
238+ m_kext_scan_flag() {}
243239
244240// / Destructor.
245241// /
@@ -248,6 +244,7 @@ PlatformDarwinKernel::PlatformDarwinKernel(
248244PlatformDarwinKernel::~PlatformDarwinKernel () = default ;
249245
250246void PlatformDarwinKernel::GetStatus (Stream &strm) {
247+ UpdateKextandKernelsLocalScan ();
251248 Platform::GetStatus (strm);
252249 strm.Printf (" Debug session type: " );
253250 if (m_ios_debug_session == eLazyBoolYes)
@@ -716,6 +713,13 @@ PlatformDarwinKernel::GetDWARFBinaryInDSYMBundle(FileSpec dsym_bundle) {
716713 return results;
717714}
718715
716+ void PlatformDarwinKernel::UpdateKextandKernelsLocalScan () {
717+ std::call_once (m_kext_scan_flag, [this ]() {
718+ CollectKextAndKernelDirectories ();
719+ SearchForKextsAndKernelsRecursively ();
720+ });
721+ }
722+
719723Status PlatformDarwinKernel::GetSharedModule (
720724 const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
721725 const FileSpecList *module_search_paths_ptr,
@@ -796,6 +800,7 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
796800 llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
797801 Status error;
798802 module_sp.reset ();
803+ UpdateKextandKernelsLocalScan ();
799804
800805 // First try all kernel binaries that have a dSYM next to them
801806 for (auto possible_kernel : m_kernel_binaries_with_dsyms) {
0 commit comments