Skip to content

Commit c557706

Browse files
authored
Merge pull request #241 from jasonmolenda/r50523558-kernel-double-read-script-fix
Reordering KextImageInfo::LoadImageUsingMemoryModule
2 parents 608c7fc + 0bd0718 commit c557706

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -794,25 +794,23 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
794794
module_spec.GetArchitecture() = target.GetArchitecture();
795795

796796
// For the kernel, we really do need an on-disk file copy of the binary
797-
// to do anything useful. This will force a clal to
797+
// to do anything useful. This will force a call to dsymForUUID if it
798+
// exists, instead of depending on the DebugSymbols preferences being
799+
// set.
798800
if (IsKernel()) {
799801
if (Symbols::DownloadObjectAndSymbolFile(module_spec, true)) {
800802
if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {
801803
m_module_sp = std::make_shared<Module>(module_spec.GetFileSpec(),
802804
target.GetArchitecture());
803-
if (m_module_sp.get() &&
804-
m_module_sp->MatchesModuleSpec(module_spec)) {
805-
ModuleList loaded_module_list;
806-
loaded_module_list.Append(m_module_sp);
807-
target.ModulesDidLoad(loaded_module_list);
808-
}
809805
}
810806
}
811807
}
812808

813809
// If the current platform is PlatformDarwinKernel, create a ModuleSpec
814810
// with the filename set to be the bundle ID for this kext, e.g.
815811
// "com.apple.filesystems.msdosfs", and ask the platform to find it.
812+
// PlatformDarwinKernel does a special scan for kexts on the local
813+
// system.
816814
PlatformSP platform_sp(target.GetPlatform());
817815
if (!m_module_sp && platform_sp) {
818816
ConstString platform_name(platform_sp->GetPluginName());
@@ -821,7 +819,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
821819
if (platform_name == g_platform_name) {
822820
ModuleSpec kext_bundle_module_spec(module_spec);
823821
FileSpec kext_filespec(m_name.c_str());
824-
FileSpecList search_paths = target.GetExecutableSearchPaths();
822+
FileSpecList search_paths = target.GetExecutableSearchPaths();
825823
kext_bundle_module_spec.GetFileSpec() = kext_filespec;
826824
platform_sp->GetSharedModule(kext_bundle_module_spec, process,
827825
m_module_sp, &search_paths, nullptr,
@@ -852,7 +850,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
852850
// UUIDs
853851
if (m_module_sp) {
854852
if (m_uuid.IsValid() && m_module_sp->GetUUID() == m_uuid) {
855-
target.GetImages().AppendIfNeeded(m_module_sp);
853+
target.GetImages().AppendIfNeeded(m_module_sp, false);
856854
if (IsKernel() &&
857855
target.GetExecutableModulePointer() != m_module_sp.get()) {
858856
target.SetExecutableModule(m_module_sp, eLoadDependentsNo);
@@ -951,6 +949,15 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
951949
s->Flush();
952950
}
953951
}
952+
953+
// Notify the target about the module being added;
954+
// set breakpoints, load dSYM scripts, etc. as needed.
955+
if (is_loaded && m_module_sp) {
956+
ModuleList loaded_module_list;
957+
loaded_module_list.Append(m_module_sp);
958+
target.ModulesDidLoad(loaded_module_list);
959+
}
960+
954961
return is_loaded;
955962
}
956963

0 commit comments

Comments
 (0)