ModuleSP ModuleList::FindModule (const UUID &uuid) const { ModuleSP module_sp; if (uuid.IsValid()) { Mutex::Locker locker(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { if ((*pos)->GetUUID() == uuid) { module_sp = (*pos); break; } } } return module_sp; }
bool DynamicLoaderMacOSXDYLD::GetSharedCacheInformation( lldb::addr_t &base_address, UUID &uuid, LazyBool &using_shared_cache, LazyBool &private_shared_cache) { base_address = LLDB_INVALID_ADDRESS; uuid.Clear(); using_shared_cache = eLazyBoolCalculate; private_shared_cache = eLazyBoolCalculate; if (m_process) { addr_t all_image_infos = m_process->GetImageInfoAddress(); // The address returned by GetImageInfoAddress may be the address of dyld // (don't want) or it may be the address of the dyld_all_image_infos // structure (want). The first four bytes will be either the version field // (all_image_infos) or a Mach-O file magic constant. Version 13 and higher // of dyld_all_image_infos is required to get the sharedCacheUUID field. Status err; uint32_t version_or_magic = m_process->ReadUnsignedIntegerFromMemory(all_image_infos, 4, -1, err); if (version_or_magic != static_cast<uint32_t>(-1) && version_or_magic != llvm::MachO::MH_MAGIC && version_or_magic != llvm::MachO::MH_CIGAM && version_or_magic != llvm::MachO::MH_MAGIC_64 && version_or_magic != llvm::MachO::MH_CIGAM_64 && version_or_magic >= 13) { addr_t sharedCacheUUID_address = LLDB_INVALID_ADDRESS; int wordsize = m_process->GetAddressByteSize(); if (wordsize == 8) { sharedCacheUUID_address = all_image_infos + 160; // sharedCacheUUID <mach-o/dyld_images.h> } if (wordsize == 4) { sharedCacheUUID_address = all_image_infos + 84; // sharedCacheUUID <mach-o/dyld_images.h> } if (sharedCacheUUID_address != LLDB_INVALID_ADDRESS) { uuid_t shared_cache_uuid; if (m_process->ReadMemory(sharedCacheUUID_address, shared_cache_uuid, sizeof(uuid_t), err) == sizeof(uuid_t)) { uuid = UUID::fromOptionalData(shared_cache_uuid, 16); if (uuid.IsValid()) { using_shared_cache = eLazyBoolYes; } } if (version_or_magic >= 15) { // The sharedCacheBaseAddress field is the next one in the // dyld_all_image_infos struct. addr_t sharedCacheBaseAddr_address = sharedCacheUUID_address + 16; Status error; base_address = m_process->ReadUnsignedIntegerFromMemory( sharedCacheBaseAddr_address, wordsize, LLDB_INVALID_ADDRESS, error); if (error.Fail()) base_address = LLDB_INVALID_ADDRESS; } return true; } // // add // NB: sharedCacheBaseAddress is the next field in dyld_all_image_infos // after // sharedCacheUUID -- that is, 16 bytes after it, if we wanted to fetch // it. } } return false; }