Skip to content

Commit 8db8a4e

Browse files
committed
Clean up conditional, don't set load binaries twice
Follow Alex Langford's feedback to my patch from https://reviews.llvm.org/D145547 , and fix a side issue I noticed while testing this, where binaries loaded via LC_NOTE metadata were loaded in the Target twice unnecessarily.
1 parent 0f2f378 commit 8db8a4e

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,11 +812,10 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
812812
}
813813
}
814814

815-
if (m_module_sp && m_uuid.IsValid() && m_module_sp->GetUUID() == m_uuid) {
816-
ObjectFileMachO *ondisk_objfile_macho =
817-
llvm::dyn_cast_or_null<ObjectFileMachO>(
818-
m_module_sp ? m_module_sp->GetObjectFile() : nullptr);
819-
if (ondisk_objfile_macho) {
815+
if (m_module_sp && m_uuid.IsValid() && m_module_sp->GetUUID() == m_uuid &&
816+
m_module_sp->GetObjectFile()) {
817+
if (ObjectFileMachO *ondisk_objfile_macho =
818+
llvm::dyn_cast<ObjectFileMachO>(m_module_sp->GetObjectFile())) {
820819
if (!IsKernel() && !ondisk_objfile_macho->IsKext()) {
821820
// We have a non-kext, non-kernel binary. If we already have this
822821
// loaded in the Target with load addresses, don't re-load it again.

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7032,6 +7032,8 @@ bool ObjectFileMachO::LoadCoreFileImages(lldb_private::Process &process) {
70327032
&process, image.filename, image.uuid, image.load_address,
70337033
false /* value_is_offset */, image.currently_executing,
70347034
false /* notify */);
7035+
if (module_sp)
7036+
continue;
70357037
}
70367038

70377039
// If we have a slide, we need to find the original binary
@@ -7042,6 +7044,8 @@ bool ObjectFileMachO::LoadCoreFileImages(lldb_private::Process &process) {
70427044
&process, image.filename, image.uuid, image.slide,
70437045
true /* value_is_offset */, image.currently_executing,
70447046
false /* notify */);
7047+
if (module_sp)
7048+
continue;
70457049
}
70467050

70477051
// Try to find the binary by UUID or filename on the local

0 commit comments

Comments
 (0)