Skip to content

Commit 3c71bcc

Browse files
Merge pull request #6877 from jasonmolenda/platform-darwin-kernel-local-filesystem-scan-lazify-59
lldb PlatformDarwinKernel make local filesystem scan lazy
2 parents f3e0142 + faf057a commit 3c71bcc

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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(
248244
PlatformDarwinKernel::~PlatformDarwinKernel() = default;
249245

250246
void 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+
719723
Status 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) {

lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ class PlatformDarwinKernel : public PlatformDarwin {
157157
bool LoadPlatformBinaryAndSetup(Process *process, lldb::addr_t addr,
158158
bool notify) override;
159159

160+
void UpdateKextandKernelsLocalScan();
161+
160162
// Most of the ivars are assembled under FileSystem::EnumerateDirectory calls
161163
// where the function being called for each file/directory must be static.
162164
// We'll pass a this pointer as a baton and access the ivars directly.
@@ -193,6 +195,8 @@ class PlatformDarwinKernel : public PlatformDarwin {
193195

194196
LazyBool m_ios_debug_session;
195197

198+
std::once_flag m_kext_scan_flag;
199+
196200
PlatformDarwinKernel(const PlatformDarwinKernel &) = delete;
197201
const PlatformDarwinKernel &operator=(const PlatformDarwinKernel &) = delete;
198202
};

0 commit comments

Comments
 (0)