@@ -114,6 +114,7 @@ ProcessMachCore::ProcessMachCore(lldb::TargetSP target_sp,
114114 : PostMortemProcess(target_sp, listener_sp, core_file), m_core_aranges(),
115115 m_core_range_infos(), m_core_module_sp(),
116116 m_dyld_addr(LLDB_INVALID_ADDRESS),
117+ m_dyld_all_image_infos_addr(LLDB_INVALID_ADDRESS),
117118 m_mach_kernel_addr(LLDB_INVALID_ADDRESS) {}
118119
119120// Destructor
@@ -320,6 +321,9 @@ bool ProcessMachCore::LoadBinariesViaMetadata() {
320321 } else if (type == ObjectFile::eBinaryTypeUser) {
321322 m_dyld_addr = objfile_binary_value;
322323 m_dyld_plugin_name = DynamicLoaderMacOSXDYLD::GetPluginNameStatic ();
324+ } else if (type == ObjectFile::eBinaryTypeUserAllImageInfos) {
325+ m_dyld_all_image_infos_addr = objfile_binary_value;
326+ m_dyld_plugin_name = DynamicLoaderMacOSXDYLD::GetPluginNameStatic ();
323327 } else {
324328 const bool force_symbol_search = true ;
325329 const bool notify = true ;
@@ -466,6 +470,7 @@ void ProcessMachCore::LoadBinariesViaExhaustiveSearch() {
466470 addr_t saved_user_dyld_addr = m_dyld_addr;
467471 m_mach_kernel_addr = LLDB_INVALID_ADDRESS;
468472 m_dyld_addr = LLDB_INVALID_ADDRESS;
473+ m_dyld_all_image_infos_addr = LLDB_INVALID_ADDRESS;
469474
470475 addr_t better_kernel_address =
471476 DynamicLoaderDarwinKernel::SearchForDarwinKernel (this );
@@ -507,6 +512,12 @@ void ProcessMachCore::LoadBinariesAndSetDYLD() {
507512 " image at 0x%" PRIx64,
508513 __FUNCTION__, m_dyld_addr);
509514 m_dyld_plugin_name = DynamicLoaderMacOSXDYLD::GetPluginNameStatic ();
515+ } else if (m_dyld_all_image_infos_addr != LLDB_INVALID_ADDRESS) {
516+ LLDB_LOGF (log,
517+ " ProcessMachCore::%s: Using user process dyld "
518+ " dyld_all_image_infos at 0x%" PRIx64,
519+ __FUNCTION__, m_dyld_all_image_infos_addr);
520+ m_dyld_plugin_name = DynamicLoaderMacOSXDYLD::GetPluginNameStatic ();
510521 }
511522 } else {
512523 if (m_dyld_addr != LLDB_INVALID_ADDRESS) {
@@ -515,6 +526,11 @@ void ProcessMachCore::LoadBinariesAndSetDYLD() {
515526 " image at 0x%" PRIx64,
516527 __FUNCTION__, m_dyld_addr);
517528 m_dyld_plugin_name = DynamicLoaderMacOSXDYLD::GetPluginNameStatic ();
529+ } else if (m_dyld_all_image_infos_addr != LLDB_INVALID_ADDRESS) {
530+ LLDB_LOGF (log,
531+ " ProcessMachCore::%s: Using user process dyld "
532+ " dyld_all_image_infos at 0x%" PRIx64,
533+ __FUNCTION__, m_dyld_all_image_infos_addr);
518534 } else if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS) {
519535 LLDB_LOGF (log,
520536 " ProcessMachCore::%s: Using kernel "
@@ -763,19 +779,32 @@ void ProcessMachCore::Initialize() {
763779}
764780
765781addr_t ProcessMachCore::GetImageInfoAddress () {
766- // If we found both a user-process dyld and a kernel binary, we need to
767- // decide which to prefer.
782+ // The DynamicLoader plugin will call back in to this Process
783+ // method to find the virtual address of one of these:
784+ // 1. The xnu mach kernel binary Mach-O header
785+ // 2. The dyld binary Mach-O header
786+ // 3. dyld's dyld_all_image_infos object
787+ //
788+ // DynamicLoaderMacOSX will accept either the dyld Mach-O header
789+ // address or the dyld_all_image_infos interchangably, no need
790+ // to distinguish between them. It disambiguates by the Mach-O
791+ // file magic number at the start.
768792 if (GetCorefilePreference () == eKernelCorefile) {
769- if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS) {
793+ if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS)
770794 return m_mach_kernel_addr;
771- }
772- return m_dyld_addr;
795+ if (m_dyld_addr != LLDB_INVALID_ADDRESS)
796+ return m_dyld_addr;
773797 } else {
774- if (m_dyld_addr != LLDB_INVALID_ADDRESS) {
798+ if (m_dyld_addr != LLDB_INVALID_ADDRESS)
775799 return m_dyld_addr;
776- }
777- return m_mach_kernel_addr;
800+ if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS)
801+ return m_mach_kernel_addr;
778802 }
803+
804+ // m_dyld_addr and m_mach_kernel_addr both
805+ // invalid, return m_dyld_all_image_infos_addr
806+ // in case it has a useful value.
807+ return m_dyld_all_image_infos_addr;
779808}
780809
781810lldb_private::ObjectFile *ProcessMachCore::GetCoreObjectFile () {
0 commit comments