From 60e58967f9ca3f4947a2953f5450d623f4cd9aa1 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Fri, 3 May 2013 22:28:10 +0000 Subject: [PATCH] Small adjustment to PlatformDarwinKernel::ExamineKextForMatchingUUID to help performance -- if the FileSpec we're examining does not contain the UUID we're looking for, don't bother examining the file any further. llvm-svn: 181063 --- .../Platform/MacOSX/PlatformDarwinKernel.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp index 740c60f17d4d..6b6b80306083 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -630,10 +630,18 @@ PlatformDarwinKernel::ExamineKextForMatchingUUID (const FileSpec &kext_bundle_pa ModuleSpec exe_spec (exe_file); exe_spec.GetUUID() = uuid; exe_spec.GetArchitecture() = arch; - error = ModuleList::GetSharedModule (exe_spec, exe_module_sp, NULL, NULL, NULL); - if (exe_module_sp && exe_module_sp->GetObjectFile()) + + // First try to create a ModuleSP with the file / arch and see if the UUID matches. + // If that fails (this exec file doesn't have the correct uuid), don't call GetSharedModule + // (which may call in to the DebugSymbols framework and therefore can be slow.) + ModuleSP module_sp (new Module (exe_file, arch)); + if (module_sp && module_sp->GetObjectFile() && module_sp->MatchesModuleSpec (exe_spec)) { - return error; + error = ModuleList::GetSharedModule (exe_spec, exe_module_sp, NULL, NULL, NULL); + if (exe_module_sp && exe_module_sp->GetObjectFile()) + { + return error; + } } exe_module_sp.reset(); }