@@ -114,6 +114,7 @@ ProcessMachCore::ProcessMachCore(lldb::TargetSP target_sp,
114
114
: PostMortemProcess(target_sp, listener_sp, core_file), m_core_aranges(),
115
115
m_core_range_infos(), m_core_module_sp(),
116
116
m_dyld_addr(LLDB_INVALID_ADDRESS),
117
+ m_dyld_all_image_infos_addr(LLDB_INVALID_ADDRESS),
117
118
m_mach_kernel_addr(LLDB_INVALID_ADDRESS) {}
118
119
119
120
// Destructor
@@ -320,6 +321,9 @@ bool ProcessMachCore::LoadBinariesViaMetadata() {
320
321
} else if (type == ObjectFile::eBinaryTypeUser) {
321
322
m_dyld_addr = objfile_binary_value;
322
323
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 ();
323
327
} else {
324
328
const bool force_symbol_search = true ;
325
329
const bool notify = true ;
@@ -466,6 +470,7 @@ void ProcessMachCore::LoadBinariesViaExhaustiveSearch() {
466
470
addr_t saved_user_dyld_addr = m_dyld_addr;
467
471
m_mach_kernel_addr = LLDB_INVALID_ADDRESS;
468
472
m_dyld_addr = LLDB_INVALID_ADDRESS;
473
+ m_dyld_all_image_infos_addr = LLDB_INVALID_ADDRESS;
469
474
470
475
addr_t better_kernel_address =
471
476
DynamicLoaderDarwinKernel::SearchForDarwinKernel (this );
@@ -507,6 +512,12 @@ void ProcessMachCore::LoadBinariesAndSetDYLD() {
507
512
" image at 0x%" PRIx64,
508
513
__FUNCTION__, m_dyld_addr);
509
514
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 ();
510
521
}
511
522
} else {
512
523
if (m_dyld_addr != LLDB_INVALID_ADDRESS) {
@@ -515,6 +526,11 @@ void ProcessMachCore::LoadBinariesAndSetDYLD() {
515
526
" image at 0x%" PRIx64,
516
527
__FUNCTION__, m_dyld_addr);
517
528
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);
518
534
} else if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS) {
519
535
LLDB_LOGF (log,
520
536
" ProcessMachCore::%s: Using kernel "
@@ -763,19 +779,32 @@ void ProcessMachCore::Initialize() {
763
779
}
764
780
765
781
addr_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.
768
792
if (GetCorefilePreference () == eKernelCorefile) {
769
- if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS) {
793
+ if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS)
770
794
return m_mach_kernel_addr;
771
- }
772
- return m_dyld_addr;
795
+ if (m_dyld_addr != LLDB_INVALID_ADDRESS)
796
+ return m_dyld_addr;
773
797
} else {
774
- if (m_dyld_addr != LLDB_INVALID_ADDRESS) {
798
+ if (m_dyld_addr != LLDB_INVALID_ADDRESS)
775
799
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;
778
802
}
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;
779
808
}
780
809
781
810
lldb_private::ObjectFile *ProcessMachCore::GetCoreObjectFile () {
0 commit comments